Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: OCIStmtExecute iters question
If I got it right, when calling execute with a select stmt and having
set
(1) nRowCount to a non zero value, you also need to allocate that many
data
items in the define call, which I don't see in your code.
(1) nRowCount as used in your code sample to OCIStmtExecute
regards
Markus
schrodinger_cat_2_at_yahoo.com wrote:
>
> I'm trying to read a string entry from several (nRowCount) rows in a
> table and I'm getting only the first entry in OCIStmtExecute. If I use
> OCIStmtFetch I get a system exception. I should not need it since I'm
> using the iters param in OCIStmtExecute... The calls that I'm using are
> below, this is prototype code so pardon the hardcoded constants. In
> cdemo82.c they use OCIStmtFetch but with objects, this should be simple
> no? I come from ODBC land so I may have some misguided notions here.
>
> Thanks,
> Tomas
>
> pszSQLCountCmd="select count(*) from table";
> pszSQLCmd="select * from table";
>
> // Prepare the count statement
> checkerr(errhp, OCIStmtPrepare(stmthp1, errhp, (unsigned char *)
> pszSQLCountCmd, (ub4) strlen((char *) pszSQLCountCmd),(ub4)
> OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
>
> // bind the input variable
> checkerr(errhp, OCIDefineByPos(stmthp1, &defnp, errhp, 1, (dvoid *)
> &nRowCount, (sword) sizeof(sword), SQLT_INT, (dvoid *) 0, (ub2 *)0,
> (ub2 *)0, OCI_DEFAULT));
>
> // execute and fetch
> status = OCIStmtExecute(svchp, stmthp1, errhp, (ub4) 1, (ub4) 0,
> (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL,
> OCI_DEFAULT);
>
> // Prepare the statement
> checkerr(errhp, OCIStmtPrepare(stmthp, errhp, (unsigned char *)
> pszSQLCmd, (ub4) strlen((char *) pszSQLCmd), (ub4) OCI_NTV_SYNTAX,
> (ub4) OCI_DEFAULT));
>
> // bind the input variable
> checkerr(errhp, OCIDefineByPos(stmthp, &defnp, errhp, nColumn, (dvoid
> *) pszFetchData,(sword) 255, SQLT_STR, (dvoid *) 0, (ub2 *)0, (ub2 *)0,
> OCI_DEFAULT));
>
> // execute and fetch
> status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) nRowCount, (ub4) 0,
> (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT);
>
> for (int i=0; i<nRowCount; i++)
> {
> status = OCIStmtFetch(stmthp, errhp, (ub4) 1, (ub4)OCI_FETCH_NEXT,
> (ub4) OCI_DEFAULT);
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Fri Sep 10 1999 - 06:45:46 CDT
![]() |
![]() |