Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help wanted: OCI insert with array of indicator variables

3 views
Skip to first unread message

matt.fr...@gmail.com

unread,
Jan 16, 2007, 6:57:55 AM1/16/07
to
Any help with the following would be greatly appreciated:

I'm trying to insert an array of values into a column using OCI. Some
values should be null so I thought I should use indicator variables set
to -1 to get nulls inserted for these. In the OCI docs for indicator
variables it says, "The implementation of arrays of structures also
supports the use of indicator variables and return codes. You can
declare parallel arrays of column-level indicator variables and return
codes that correspond to the arrays of information being fetched,
inserted, or updated. These arrays can have their own skip parameters,
which are specified during OCIBindArrayOfStruct() or
OCIDefineArrayOfStruct() calls. ... A one-to-one relationship between
the fields in an indicator struct and the number of select-list items
is not necessary."

Am I right to read that as saying that the indicator is at the column
level rather than the field level? If I pass a parallel array of
indicators to OCIBindByPos along with my array of column data, and set
the indskip parameter of OCIDefineArrayOfStruct to sizeof(sb2) then the
indicators that are set to -1 are ignored, and I get garbage data
rather than nulls in the fields.

Can I use indicators this way? What am I doing wrong?

thanks,
--
Matt Freestone

matt.fr...@gmail.com

unread,
Jan 16, 2007, 9:57:02 AM1/16/07
to

matt.fr...@gmail.com wrote:
<snip>

>
> Am I right to read that as saying that the indicator is at the column
> level rather than the field level? If I pass a parallel array of
> indicators to OCIBindByPos along with my array of column data, and set
> the indskip parameter of OCIDefineArrayOfStruct to sizeof(sb2) then the
> indicators that are set to -1 are ignored, and I get garbage data
> rather than nulls in the fields.
>
> Can I use indicators this way? What am I doing wrong?
>
I've solved my own problem. In case it's relevant to anyone else - you
can use an array of indicators in the way I asked about. I had a dodgy
type conversion that was stopping the values being used correctly.

cheers,
--
Matt Freestone

0 new messages