Home » Developer & Programmer » Precompilers, OCI & OCCI » OCI Array binding (9i)
OCI Array binding [message #392786] Thu, 19 March 2009 05:05
Messages: 1
Registered: March 2009
Location: raom
Junior Member

Hi experts,
Could you please gimme a pointer for binding C arrays in OCI.
I'm trying to update couple of colums in a table using a stored procedure which takes column values as the argumnets.

char **key_typep,
char **key_valp,
int key_count)

ub2 tag_sz[key_count];
ub2 key_sz[key_count];

strcpy(sql_stmt,"begin update_tab(:in1, :in2); end;");

/*Allocate and prepare SQL statement */
rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_sql,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0);
rc = OCIStmtPrepare(p_sql, p_err, (unsigned char *) sql_stmt,
(ub4) sizeof(sql_stmt), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT);
if (rc != 0) {
OCIErrorGet((dvoid *)p_err, (ub4) 1, (text *) NULL, &errcode,
(unsigned char *)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Error - %.*s\n", 512, errbuf);

rc = OCIBindByName(p_sql, &p_bnd, p_err, (text *) ":in2",
strlen(":in2"), (ub1 *)key_valp, 255, SQLT_STR,(dvoid *) 0,(ub2 *)key_sz, (ub2 *) 0, (ub4)0, (ub4 *)0, OCI_DEFAULT);

rc = OCIBindByName(p_sql, &p_bnd, p_err, (text *) ":in1",
strlen(":in1"), (ub1 *)key_typep, 10, SQLT_STR,(dvoid *) 0,(ub2 *)tag_sz, (ub2 *) 0, (ub4)0, (ub4 *)0,OCI_DEFAULT);

/*Execute the SQL statment*/
rc = OCIStmtExecute(p_svc, p_sql, p_err, (ub4)key_count, (ub4) 0,

if(rc != 0) {
OCIErrorGet((dvoid *)p_err, (ub4) 1, (text *) NULL, &errcode,
(unsigned char *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Exec Error - %.*s\n", 512, errbuf);
return rc;

I expect this routine to update key_count number of rows in the table (the update_tab procedure does a set col = in2 where col2 = in1). The execution does not return any error but nothing is updated in the database. I found that the input passed to procedure is null in both bind variables(though the array contain data). Is there any thing i missed with array binding?
Previous Topic: Debian & Pro*C
Next Topic: OCI Oracle 9i Solaris and FastPath functions
Goto Forum:

Current Time: Sat Apr 01 20:54:18 CDT 2023