Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> OCI: problem with passing new object (table) to PL/SQL (for bulk insert/direct path loading)
Hi,
I would like to call a PL/SQL procedure from OCI program, and this
procedure receives a new type (table of char(30)) as a parameter.
The client (OCI) application just crashes with access violation on
OCIStmtExecute() stage.
The procedure that should be called from client application, works
from SQL*plus smoothly.
I'm quite new to OCI, so could you please tell me what I'm doing wrong (or at least if my way doing things is absolutely wrong then advise smth else = preferrably with examples;).
I have:
Personal Oracle8i 8.1.7 Release
INSERT INTO tab1_collection_avs_char30 VALUES(in_char(b) );
END INSERT_FORALL_AVS_CHAR30 ;
end TEST_COLLECTION;
/
// statement preparation
errCode = OCIHandleAlloc(ociEnv, (dvoid **) &ociStmt,
OCI_HTYPE_STMT, 0, 0); errCode = OCIStmtPrepare(ociStmt, ociError, (CONST text*)procCall.c_str(), procCall.length(), OCI_NTV_SYNTAX, OCI_DEFAULT);
// binding - 1st stage
errCode = OCIBindByPos(ociStmt, &ociBind, ociError,
1, 0, 0, SQLT_NTY, 0, 0, 0, 0, 0, OCI_DEFAULT); errCode = OCITypeByName(ociEnv, ociError, ociSvcCtx, 0, 0, (CONST text*)oracleTypeName.c_str(), oracleTypeName.size(), 0, 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &tdo);
// object creation (to bind it using OCIBindObject)
OCITable *ociTable;
errCode = OCIObjectNew(ociEnv, ociError, ociSvcCtx,
OCI_TYPECODE_TABLE, tdo, 0, OCI_DURATION_DEFAULT, TRUE, (dvoid **)&ociTable);OCIString *ociString = 0;
(text*)data.c_str(), data.size(), &ociString);
errCode = OCICollAppend(ociEnv, ociError, (CONST dvoid*)ociString, (CONST dvoid*)&ociCollIndexNull, ociTable);
ociTable, &dataSize);
// binding - 2nd stage
errCode = OCIBindObject(ociBind, ociError, tdo,
(dvoid **)ociTable, (ub4*)&dataSize, 0, 0);
// execution
// VVVVVVVVVVVVV - crash over here
errCode = OCIStmtExecute(ociSvcCtx, ociStmt, ociError, 1, 0, 0, 0, OCI_DEFAULT);
if((OCI_OK(errCode) || errCode == OCI_NO_DATA) ) {
errCode = OCITransCommit(ociSvcCtx, ociError, OCI_DEFAULT); } else {
OCITransRollback(ociSvcCtx, ociError, OCI_DEFAULT); }
Thanks,
Alexandru Sclearuc
Received on Wed Jul 16 2003 - 12:05:41 CDT