| OCIRaw Array Bind [message #398366] |
Thu, 16 April 2009 02:09  |
khansamjath Messages: 2 Registered: April 2009 |
Junior Member |
|
|
I want to insert data into a RAW column in a table. The below code snippet is used for the same
OCIRaw **l_rawPtr = new OCIRaw*[10];
for(int i=0;i<10;i++)
{ l_rawPtr[i] = NULL; }
int max = 0;
for(int i=0;i<10;i++)
{
OCIRawAssignBytes(l_environment, l_error, l_char, strlen((const char*)l_char), &l_rawPtr[i])
OCIRawAllocSize(l_environment,l_error,l_rawPtr[i],&l_l);
if(l_l > max) max = l_l;
}
OCIBind *def1 = NULL, *def2 = NULL;
sb2 m_inullIndicator[10];
if (OCIBindByPos ( l_stmt, &def1, l_error, 1, l_rawPtr, max, SQLT_LVB, (sb2*)0, (ub2 *)0,(ub2 *)0, 0, (ub4 *)0,OCI_DEFAULT) )
{
getError(l_error);
exit(0);
}
int errr = 0;
if (errr = OCIStmtExecute(l_service, l_stmt,l_error, (ub4) 10, (ub4) 0, (OCISnapshot *) NULL, (OCISnapshot *) NULL, (ub4) OCI_DEFAULT))
{
getError(l_error);
if (errr != OCI_NO_DATA) return errr;
}
When the statement is getting executed, i am getting the following error.
Error - ORA-01458: invalid length inside variable character string
Could anybody help me to fix this
|
|
|
|
| Re: OCIRaw Array Bind [message #398701 is a reply to message #398673] |
Fri, 17 April 2009 03:21  |
khansamjath Messages: 2 Registered: April 2009 |
Junior Member |
|
|
If I use SQLT_BIN, the data is stored in the different format than RAW, probably VARRAW.
The other thing i noticed was,
I have a select query on the same table, selecting the raw column. After executing the query, I used OCIParamGet() to get the Parameter Descriptor and checked for the Column Type. It corresponds to SQLT_BIN.
But if I use SQLT_BIN in OCIDefineByPos() (single row fetch), i am getting the results with the first 4 characters getting truncated. But, If I use SQLT_LVB, it gives me the proper result.
Some documentations on ORacle suggest to SQLT_LVB as well.
|
|
|