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

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle 8.1 OCI array inserts of strings

Re: Oracle 8.1 OCI array inserts of strings

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sat, 21 Aug 1999 12:10:45 GMT
Message-ID: <37c096f4.1805225@newshost.us.oracle.com>


A copy of this was sent to Arien Malec <amalec_at_slip.net> (if that email address didn't require changing) On Fri, 20 Aug 1999 21:45:35 -0700, you wrote:

>What is the correct way to do array inserts of strings?
>

you don't have an array of strings below, you have an array of pointers to strings. It'll be more like

char messages[2][25] = {"Hello, world","The British are coming" }; int mlena[2] = ( sizeof(messages[0]), sizeof(messages[1]) };

>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

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sat Aug 21 1999 - 07:10:45 CDT

Original text of this message

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