Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Oracle 8.1 OCI array inserts of strings
What is the correct way to do array inserts of strings?
I've been going mad trying different combinations, and I'm sure I'm missing something obvious. Unfortunately, the docs don't have any examples of array inserts...
What I've been trying to do can be summarized like this:
char * messages[2] = {"Hello, world","The British are coming" }; int mlena[2] = {strlen(messages[0]), strlen(messages[1])};
/*...*/
status = OCIBindByName (stmhp,
(OCIBind **) &bnd2hp,
errhp,
(text *) ":MESSAGE",
strlen (":MESSAGE"),
(ub1 *) *messages,
(sword) 30,
SQLT_CHR,
(dvoid *) 0,
(ub2 *) mlena,
(ub2 *) 0,
(ub4) 0,
(ub4 *) 0,
OCI_DEFAULT);
If I pass the array parameter without dereferencing it, I get total garbage in the message column. When I dereference it, I get the first message in the database, but nothing for the second. I was able to pass an array of ints, with no problem (and I didn't have to dereference that array).
So what am I missing here?
Thanks Received on Fri Aug 20 1999 - 23:45:35 CDT