Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

batch insert prolblems whit using ocibindbypos() and ocibindarrayofstruct()

575001Apr 28 2007 — edited Apr 29 2007
there is a table called TEST with two fields : ID and Value, i want to insert 100 records one time using ocibindbypos() and ocibindarrayofstruct(), here is the code:

//record struct
typedef struct
{
ub4 ID;
ub4 Value;
} Record;

//indicator array
typedef struct
{
sb2 sb2_ID[100];
sb2 sb2_Value[100];
} Indicators;

//field length
typedef struct
{
ub2 ub2_ID[100];
ub2 ub2_Value[100];
}FieldLenth;

//the variables
Record RecsToboInserted[100];
Indicators aIndStruct;
FieldLenth aFldLthStruct;
FieldLenth aFldLthStructRet;

//initialization
for (int i = 0; i < 100; i++)
{
RecsToboInserted.ID = i;
RecsToboInserted[i].Value = i;
}

for (int i = 0; i < 100; i++)
{
aIndStruct.sb2_ID[i] = 0;
aIndStruct.sb2_Value[i] = 0;
}

for (int i = 0; i < 100; i++)
{
aFldLthStruct.ub2_ID[i] = sizeof(ub4);
aFldLthStruct.ub2_Value[i] = sizeof(ub4);
}

for (int i = 0; i < 100; i++)
{
aFldLthStructRet.ub2_ID[i] = sizeof(ub4);
aFldLthStructRet.ub2_Value[i] = sizeof(ub4);
}

after the database is opened:

const char * strSql1 = "INSERT INTO SIMPLETEST200702 (ID, Value) VALUES(:p,:p)";

OCIStmtPrepare(m_pStmtAll, m_pErrHandle, (text*)strSql1.GetBuf(),
(ub4)strSql1.GetLength(), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT )

OCIBindByPos(m_pStmtAll, &ParamBindP[0], m_pErrHandle, 1,(dvoid*)(RecsToboInserted[0].ID), sizeof(RecsToboInserted[0].ID), (ub4)SQLT_INT,
&aIndStruct.sb2_ID[0], (ub2 *)&aFldLthStruct.ub2_ID[0],(ub2 *)&aFldLthStructRet.ub2_ID[0], 100, &retNum, OCI_DEFAULT);

OCIBindArrayOfStruct(ParamBindP[0], m_pErrHandle, sizeof(Record), sizeof(sb4), sizeof(ub4), sizeof(ub4));

OCIStmtExecute(m_pSvcHandle, m_pStmtAll, m_pErrHandle, (ub4)1,
(ub4)0, (OCISnapshot *)NULL, (OCISnapshot *)NULL, OCI_DEFAULT))


on executing OCIStmtExecute(), it retruns an errorcode ORA-01485 compile bind length different from execute bind length . so, can anybody help me ? what is wrong whit my code ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2007
Added on Apr 28 2007
1 comment
1,546 views