Re: PRO*C FETCH, is this expected behavior?

From: Tim Smith <tssmith_at_netcom.com>
Date: 2 Mar 92 03:13:25 GMT
Message-ID: <gsrhpqbtssmith_at_netcom.com>


In article <1992Mar1.162231.9265_at_aio.jsc.nasa.gov> hall_at_orion.jsc.nasa.gov (Philip Hall 283-4031) writes:
> The short answer is "yes". The imbedded SQL behavior is designed
> to be language independent. The termination of a string with a
> NULL character is a C language characteristic. You will either
> have to insert the NULL character using the <variable>.len value
> or always NULL fill your arrays before fetching.
>
> Philip Hall

I missed the original posting that Philip is responding to, but be aware that in the version 1.4 (available very soon) Pro*C and Pro*Pascal precompilers, you have a new command EXEC SQL TYPE ... This allows you to set a defined type to correspond to any ORACLE external datatype, such as STRING (datatype code 5). So in Pro*C you could do:

typedef char asciz;

EXEC SQL BEGIN DECLARE SECTION;
/* User-defined type for null-terminated strings */

    EXEC SQL TYPE asciz IS STRING(20);
    asciz emp_name[20];
    ...
EXEC SQL END DECLARE SECTION; and then do

    EXEC SQL SELECT ename INTO :emp_name FROM emp WHERE empno = 7499;

and get a null-terminated C string in the emp_name host variable.

There is also an EXEC SQL VAR ... command that let's you do external type equivalencing on a variable-by-variable basis. The VAR command is also available for the COBOL, FORTRAN, and PL/I precompilers.

--Tim (tssmith_at_netcom.com)

      (tssmith_at_oracle.com) Received on Mon Mar 02 1992 - 04:13:25 CET

Original text of this message