Re: Pro*C and Oracle 6

From: <rhari_at_us.oracle.com>
Date: Thu, 11 Feb 1993 19:28:17 GMT
Message-ID: <1993Feb11.112817.1_at_us.oracle.com>


In article <1993Feb11.105753.28966_at_cs.joensuu.fi>, omikko_at_cs.joensuu.fi (Olli Mikkonen) writes:
> craiga_at_spock.dis.cccd.edu (Craig Armstrong) writes:
>

>>I have a problem that is driving me nuts. I've built a SQL INSERT command
>>in a local variable (this is a C program) and try to execute it with
>>EXEC SQL EXECUTE IMMEDIATE :buf. It always come back with invalid statement.
>>I've checked all the obvious and still no luck. The command is proper in
>>syntax and should work. The command is over 255 bytes, though. I'm afraid
>>to ask, but is this a problem with Pro*C and if so, any work arounds??

>
> I suppose buf is defined as
> char buf[n];
> where n is large enough. There is a bug in Pro*C. Oracle can't always
                            ^^^^^^^^^^^^^^^^^^^^^^^
  This is not a bug. A variable defined as above will be automatically   be typed as ORACLE TYPE 1 which does not have the semantics of a 'C'   null terminated string. A TYPE 1 buffer is processed from right to left   and all spaces are stripped till the first non space character is found.   That then is the data on which the operation is performed. As C does not   gurantee the contents of some memory unless you initialize it, there   is a good chance that garbage could be manipulated by ORACLe. With   Pro* 1.4 and 1.5 you could explicitly type a variable and in this case   you would type it with a 5 which follows the symantics of a 'C' null   terminated string.

> detect end of the string when it is defined as above. Easiest
> workaround is to define buf as VARCHAR and use it accordingly.

  That will work too.

Radhakrishna Hari
rhari_at_us.oracle.com Received on Thu Feb 11 1993 - 20:28:17 CET

Original text of this message