Home » Developer & Programmer » Precompilers, OCI & OCCI » OCIRaw Array Bind (Oracle 10.2.0.4.0 -> centOS)
OCIRaw Array Bind [message #398366] Thu, 16 April 2009 02:09 Go to next message
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 #398673 is a reply to message #398366] Fri, 17 April 2009 02:01 Go to previous messageGo to next message
vicenzo
Messages: 25
Registered: December 2007
Location: Paris
Junior Member
Hi,

Using OCIRaw, you have to use sql code SQLT_BIN not SQLT_LVB.

[Updated on: Fri, 17 April 2009 02:01]

Re: OCIRaw Array Bind [message #398701 is a reply to message #398673] Fri, 17 April 2009 03:21 Go to previous message
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.
Previous Topic:Retrieve table data from PL/SQL into OCCI
Next Topic:SQLnet + c guides?
Goto Forum:
  


Current Time: Sun Nov 8 22:04:56 CST 2009

Total time taken to generate the page: 0.02645 seconds
.:: Forum Home :: Blogger Home :: Wiki Home :: Contact :: Privacy ::.