OCI help

From: Ben Newman <ben_at_no.spam.velara.com>
Date: Tue, 30 Jan 2001 16:56:51 GMT
Message-ID: <nnCd6.2555$CQ4.259585_at_monger.newsread.com>


I'm very new to the OCI, and am having some problems getting started, particularly with dynamic sql. Can someone tell me what I'm missing in the code below?

suppose *stmt = "select * from foo" and I have no idea what i'm going to get back. Also, assume that a valid connection has been established to the server and all handles have been allocated/initialized properly.

void getTableInfo(char *stmt, OCIError *errhp, OCIEnv *envhp, OCISvcCtx *svchp)
{
 OCIStmt *stmthp = NULL;
 OCIParam *parmhp = NULL;
 ub4 index = 1;
 ub2 type;
 text *colName;
 ub4 colNameLen;
 sb4 parmStatus;

 checkerr(errhp, OCIHandleAlloc(envhp, &stmthp, OCI_HTYPE_STMT, 0, NULL));

 checkerr(errhp, OCIStmtPrepare(stmthp,
  errhp,
  stmt,
  strlen(stmt),
  OCI_NTV_SYNTAX,
  OCI_DEFAULT)); checkerr(errhp, OCIStmtExecute( svchp,
  stmthp,
  errhp,
  1,
  0,
  NULL,
  NULL,
  OCI_DEFAULT));
/* the above call always results in "Error - ORA-24374: define not done before fetch or execute and fetch */
 ...
}

I thought I did not have to bind the variables since I don't know what the variables are going to be. How is this handled?

Thanks,

Ben Received on Tue Jan 30 2001 - 17:56:51 CET

Original text of this message