Re: How are NULL arguments passed in OCI

From: Tim Smith <tssmith_at_netcom.com>
Date: Sat, 27 Feb 1993 07:15:31 GMT
Message-ID: <1993Feb27.071531.26381_at_netcom.com>


In article <C30y9K.yo_at_hugo.uucp> normi_at_hugo.uucp (Norman Dutton) writes:
>I have a version 7 OCI application that needs to pass null
>arguments. Oracle support says that some convention must
>be used and a null string is not allowed. Is this really
>true?

I assume that by "null argument" you mean a value that is to be interpreted as a SQL null, and not a null pointer, in the C sense.

Well, just in case you mean the former, you just pass a 0, cast to the appropriate type. In some earlier OCI documentation, -1 values were used to indicate null pointers. This is no longer required. Use (type *) 0. If this is what you mean, and you are using a language other than C, it gets trickier. If this is the case, email me and I'll answer offline.

In the more likely event that you mean a SQL null, the most reliable way to do this is to use an indicator variable in the bind call (obndrn, obndrv, or obndra). Pass the address of an indicator variable on the bind call, and set the value of the variable to -1 before the execute. The column in the table is then set to null (regardless of the contents of the "actual" bound variable). If the column has a NOT NULL constraint you get an error, as expected.

Hope this helps.

--Tim (tssmith_at_netcom.com) Received on Sat Feb 27 1993 - 08:15:31 CET

Original text of this message