Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: OCIBindArrayOfStruct i cannot find my error

Re: OCIBindArrayOfStruct i cannot find my error

From: maniekp <maniekpozioma_at_poczta.onet.pl>
Date: Sat, 15 Mar 2003 00:36:24 +0100
Message-ID: <3E726778.5060603@poczta.onet.pl>


subsilver wrote:
> hi all,
>
> i have the following problem, i will import many lines from a file.
> binding and execute per line functioned super.
> now i will reduce round trips with function OCIBindArrayOfStruct()
> i look after the import into the database i see only the last line of
> the file.
> what i make wrongly ?
> thx for your help
>
> ciao subsilver
>
>
> for (int i = 0; i < counter; i++){
> bndhp[i] = (OCIBind *) 0;
> };//for
> for(int a=0;a<counter;a++){
> try {
> //1. parameter
> swdReturnCode = OCIBindByPos ((OCIStmt*) pOCIStatement,
> (OCIBind**) &bndhp[a],
> (OCIError*) ptrOCIError,
> (ub4) columnIndex[1],
> (dvoid*) lname[a],
> (sb4) (lname[a] == NULL) ? 0 : (1+strlen(lname[a])),
> (ub2) SQLT_STR,
> (dvoid*) NULL,
> (ub2*) NULL,
> (ub2*) NULL,
> (ub4) NULL, (ub4*) NULL,
> (ub4) OCI_DEFAULT
> );
> //cut errorhandling
> swdReturnCode = OCIBindArrayOfStruct(bndhp[a], ptrOCIError, s1,
> indsk[a], rlsk[a], rcsk[a]);
> //cut errorhandling
> //2.parameter
> swdReturnCode = OCIBindByPos ((OCIStmt*) pOCIStatement,
> (OCIBind**) &bndhp[a],
> (OCIError*) ptrOCIError,
> (ub4) columnIndex[1],
> (dvoid*) fname[a],
> (sb4) (fname[a] == NULL) ? 0 : (1+strlen(fname[a])),
> (ub2) SQLT_STR,
> (dvoid*) NULL,
> (ub2*) NULL,
> (ub2*) NULL,
> (ub4) NULL, (ub4*) NULL,
> (ub4) OCI_DEFAULT
> );
> //cut errorhandling
> swdReturnCode = OCIBindArrayOfStruct(bndhp[a], ptrOCIError,
> s1, indsk[a], rlsk[a], rcsk[a]);
> //cut errorhandling
>
> //3. parameter
> swdReturnCode = OCIBindByPos ((OCIStmt*) pOCIStatement,
> (OCIBind**) &bndhp[a],
> (OCIError*) ptrOCIError,
> (ub4) columnIndex[3],
> (dvoid*) &aname[a],,
> (sb4) sizeof(aname[a]),
> (ub2) SQLT_STR,
> (dvoid*) NULL,
> (ub2*) NULL,
> (ub2*) NULL,
> (ub4) NULL, (ub4*) NULL,
> (ub4) OCI_DEFAULT
> );
> //cut errorhandling
> swdReturnCode = OCIBindArrayOfStruct(bndhp[a], ptrOCIError,
> s1, indsk[a], rlsk[a], rcsk[a]);
> //cut errorhandling
>
> } catch (...) {
>
> ...
>
> }//catch
>
> };//for
> swdReturnCode = OCIStmtExecute( (OCISvcCtx* ptrOCIServiceContext,
> (OCIStmt*) pOCIStatement,
> (OCIError*) ptrOCIError,
> (ub4) 1, (ub4)
> 0, (CONST OCISnapshot*) NULL,
> (OCISnapshot *) NULL,
> (ub4) OCI_COMMIT_ON_SUCCESS
> );
> //cut errorhandling

i'm not sure, but in my opinion you have to bind only "one struct" - not all structs, and you must pass how many structs you have in OCIStmtExecute/iters parameter.

i think that array of struct is like array o scalars with one difference - in array of structs you must pass in which offset begin any field.

rougly, as follows:
- bind all columns in one (first) struct - call OCIStmtExecute with iters parameter equal counter of structs

good, luck
maniek Received on Fri Mar 14 2003 - 17:36:24 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US