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: Arrays of structures in Pro*C/C++

Re: Arrays of structures in Pro*C/C++

From: Stan Green, Jr. <stan_green_at_retek.com>
Date: Thu, 27 Aug 1998 10:16:12 -0400
Message-ID: <6s3pno$84l$1@news1.norlight.net>

ORcastillo wrote in message
<1998082513320200.JAA29547_at_ladder03.news.aol.com>...
>I'm wanting to use arrays of structures in some of my Pro*C/C++ programs.
>However, I haven't been able to make it work using dinamically allocated
>arrays of structures. It seems that the precompilerhas to know the array
>dimension.
>What about the OCI can it use dinamically allocated arrays of structures
>to insert/fetch data to/from the database.

Hi,

When using Pro*C/C++ you can dynamically set the size of your structures. Here is an example:

struct keyval_struct
{

    int key1;
    int value1;
} *keyval;

keyval=(struct keyval_struct *)

                malloc(sizeof(struct keyval_struct)*set_cnt);

/* fill up your array here -- e.g.,
 keyval[i].key1 = i;

            keyval[i].value1 = i*2;
*/

EXEC SQL for: num_items INSERT into test1 (key1, val1)

               values (:keyval) ;

Note that the num_items must equal to or less than set_cnt.

Hope this helps,

--Stan Received on Thu Aug 27 1998 - 09:16:12 CDT

Original text of this message

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