Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Newbie: Oracle 7.3 OCI-problem by using OBNDRA? Please help!

Newbie: Oracle 7.3 OCI-problem by using OBNDRA? Please help!

From: Thanh Binh To <tob_at_ifak.fhg.de>
Date: Wed, 05 Sep 2001 11:07:52 +0200
Message-ID: <3B95EB68.9AA99462@ifak.fhg.de>


Hi,

I am new by programming with OCI. I try to bind an array variable using OBNDRA-routine without
any success.

In an example of OCI 'obndra.c', one usually uses a static declaration like
#define DESC_LEN 20
text descrip[3][DESC_LEN] = {"Frammis", "Widget", "Thingie"};

ub2  descrip_alen[3] = {DESC_LEN, DESC_LEN, DESC_LEN};
ub2  descrip_rc[3];
ub4  descrip_cs = (ub4) 3;
ub2  descrip_indp[3];

to bind the C arrays (text array) to the PL/SQL tables   if (obndra(&cda,

(text *) ":description",

               -1,

(ub1 *) descrip,
(sword) DESC_LEN,
VARCHAR2_TYPE, -1, descrip_indp, descrip_alen, descrip_rc,
(ub4) MAX_TABLE_SIZE,
&descrip_cs,
(text *) 0,
-1, -1)) oci_error();

and append this array into the column 'description' of a table. It does work correctly!!!

But in my application, I would like to create the array variable 'descrip' dynamically because the
size of it maybe changed from case to case.

To do it I define a new array variable 'mydescription' like text **mydescription;
mydescription= (text**)malloc(3*sizeof(text*));

mydescription_alen = (ub2*)malloc(3*sizeof(ub2));
mydescription_indp = (ub2*)malloc(3*sizeof(ub2));
mydescription_rc = (ub2*)malloc(3*sizeof(ub2));
for (ii=0;ii<3;ii++){

   mydescription[ii] = (text*)malloc(DESC_LEN*sizeof(text));

   mydescription_alen[ii] = DESC_LEN;
   mydescription_indp[ii] = (ub2)0;
   mydescription_rc[ii] = (ub2)0;

}
strcpy((char*)mydescription[0],(const char*)"Frammis");
strcpy((char*)mydescription[1],(const char*)"Widget");
strcpy((char*)mydescription[2],(const char*)"Thingie");

and bind this array using the above OBNDRA-routine.

Surprisingly, my array can be not correctly appended into the field 'description'. Instead of "Frammis",
"Widget" and "Thingie" in the 1st, 2nd and 3rd row, other (control) characters are inserted. I can not
debug this problem by knowing what is happened within OBNDRA by processing my array variable

Could anyone tell if
1- I have some mistakes by declaration of mydescription? 2- how can I solve it?

Maybe the declaration **mydescription is not a 1-1-mapping of descript[3][20]??

Thanks you very much for any help.

--
Binh
----------------------------------------------------
Thanh Binh To
Institute of Automation and Communication Magdeburg
Germany
E-Mail: tob_at_ifak.fhg.de
----------------------------------------------------
Received on Wed Sep 05 2001 - 04:07:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US