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

Home -> Community -> Usenet -> c.d.o.server -> enhanced DML array operations in OCI

enhanced DML array operations in OCI

From: B Adcock <wadcock2_at_home.com>
Date: 31 Oct 2002 16:41:52 -0800
Message-ID: <b436ea6e.0210311641.2ed824dd@posting.google.com>


The OCI API allows inserting an array of rows. But how do you get the error message for a given row?

The Oracle documentation says to
>> res = OCIStmtExecute(Svc,classMatch->Ins_stmt,Err,
>> classMatch->currentRowsOfData,
>> 0,NULL,NULL, OCI_BATCH_ERRORS);
>>
>> if(ds_error(res,"Insert Execution",1))
>> {
>> res = OCIAttrGet(classMatch->Ins_stmt,OCI_HTYPE_STMT,&nrow,NULL,
>>
OCI_ATTR_ROW_COUNT,Err);
>> ds_error(res,"Row offset fetch",1);
>>
>> return(0);
>> }
>>
>> /* get the number of errors */
>> OCIAttrGet (classMatch->Ins_stmt, OCI_HTYPE_STMT, &num_errs,
0,
>> OCI_ATTR_NUM_DML_ERRORS, Err);
>> printf(" insert returned %li errors*****\n", (long)num_errs);
>> if (num_errs) {
>> int i = 0;
>> ub4 error_cntr = 1;
>> ub4 row_offset = 0;
>> sb4 errcode = 0;
>> text errbuf[512];
>> /* The user can do one of two things: 1) Allocate as many
*/
>> /* error handles as number of errors and free all handles
*/
>> /* at a later time; or 2) Allocate one err handle and reuse
*/
>> /* the same handle for all the errors */
>> /*OCIError *errhndl[num_errs];*/
>> OCIError *errhndl;
>>
>> for (i = 0; i < num_errs; i++) {
>> /*OCIParamGet(Err, OCI_HTYPE_ERROR, Err, &errhndl[i],
i);*/
>> res =
>> OCIParamGet(Err,
>> OCI_HTYPE_ERROR,
>> Err,
>> (dvoid**)&errhndl,
>> (ub4)i + 1);
>> res =
>> /*OCIAttrGet (errhndl[i], OCI_HTYPE_ERROR, &row_off[i],
0, */
>> OCIAttrGet (errhndl,
>> OCI_HTYPE_ERROR,
>> &row_offset,
>> 0,
>> OCI_ATTR_DML_ROW_OFFSET,
>> Err);
>> /* get server diagnostics */
>> /* process "stack" of errors */
>> error_cntr = 1;
>> res =
>> OCIErrorGet ((dvoid *) Err,
>>
>> (ub4) error_cntr++, /* nbr of status record
*/
>> (text *) NULL,
>> &errcode,
>> errbuf,
>> (ub4) sizeof(errbuf),
>> (ub4) OCI_HTYPE_ERROR);
>> while (res == 0 && error_cntr < 20)
>> {
>> printf(" res is %i\n", (int)res);
>> printf("*****************Error %i at offset %li: %li
%s\n",
>> i,
>> (long)row_offset, (long)errcode, errbuf);
>>
>> /* get next error */
>> res =
>> OCIErrorGet ((dvoid *) Err,
>> (ub4) error_cntr++, /* nbr of status
record */
>> (text *) NULL,
>> &errcode,
>> errbuf,
>> (ub4) sizeof(errbuf),
>> (ub4) OCI_HTYPE_ERROR);
>> }
>> } /* for each error */
>> } /* if num_errs */
>>

Where just returns " ORA-24381: error(s) in array DML". How do you get the specific error?
You do a OCIAttrGet to get the row_offset, but never used the row_offset to
get the error at that offset??? This doesn't make sense. The Oracle web page talks about using a callback to reprocess the failed rows via a Update statement, but doesn't show the callback. Where is the callback?

Thanks....... Received on Thu Oct 31 2002 - 18:41:52 CST

Original text of this message

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