Re: How are NULL arguments passed in OCI

From: Norman Dutton <normi_at_hugo.uucp>
Date: Tue, 2 Mar 1993 16:17:03 GMT
Message-ID: <C39rwG.1Cw_at_hugo.uucp>


In article <1993Feb27.071531.26381_at_netcom.com> tssmith_at_netcom.com (Tim Smith) writes:
>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)
>
>
>

Sorry, I should have been more precise. The OCI program is calling Oracle to execute a stored procedure and null arguments are used to indicate that the stored procedure is to not do something. All these arguments are strings so I passed a null string, i.e. '\0' as the first character in the string. (The reason why I did not use some other flag is that I did not write the stored procedures, they were translated from Sybase stored procedures.) Thanks for the information anyway.

-- 
Norman Dutton;                  | uucp:    uunet!hugo!normi
D & M Associates                | Internet: hugo!normi_at_uunet.uu.net
4208 Evergreen Lane, Suite 213  | Voice: 1.703.941.7526 or 1.703.777.5677
Annandale, VA 22003             | 
Received on Tue Mar 02 1993 - 17:17:03 CET

Original text of this message