Re: Ugly embedded SQL behaviour

From: Craig B. Inglis <inglisc_at_lilhd.logica.com>
Date: Fri, 9 Sep 1994 09:30:05 GMT
Message-ID: <inglisc.23.000980B1_at_lilhd.logica.com>


In article <CvGn1M.Ewq_at_world.std.com> smayo_at_world.std.com (Scott A Mayo) writes:
>From: smayo_at_world.std.com (Scott A Mayo)
>Subject: Ugly embedded SQL behaviour
>Date: Thu, 1 Sep 1994 16:56:10 GMT

>I'm irritated at Oracle's embedded SQL (Pro*c) product. I
>found a bug that cost me two days on a tight schedule. I'm
>posting this so other folk won't hit the same trap.

[snip]

>It turns out that, while buf contains exactly the text
>implied by the strcpy, terminating nul character and
>all, the Execute immediate parsing didn't stop when
>it saw the nul character. It looked deeper into the
>buffer, saw the remains of other strings, and declared
>the error.

Yup Ive had such probs before. :(

>When I shrunk the size of buf, and did a memset(buf, 0, sizeof buf)
>before loading any text into buf, the problem went away. Isn't
>that special!

Oracle has little support for proper strings in Pro*C, but you could do one of  the following...

  1. add EXEC SQL VASR buf IS STRING(31999); after the delclare [ or something similar]
  2. define a null terminated string type via EXEC SQL TYPE.
  3. Use a character pointer and malloc() the memory... this works (at least in later versions of Pro*C)...

EXEC SQL BEGIN DECLARE SECTION;
char *buf;
EXEC SQL END DECLARE SECTION; The embedded code uses strlen() to acertain the string length.

>If you are considering using Oracle embedded SQL products, and
>have a choice between it and Informix, take another look at
>Informix. I've had two weeks of pain with Oracle, and have learned
>the fine art of being on hold, waiting for support people to
>get to me. The informix stuff went quite smoothly by comparison.

Oracle's not that bad, but you do need a bit of a square head to to get the most out of it (and a relational mind to figure out the crummy manuals).

I have some example DSQL Method 4 source which provides an Oracle API example which means that you dont require Pro*C and can use just standard Unix C/C++ and link in the API .o (and no, its not the diabolical DSQL4 example bundled with some Oracle versions).

But then again I'm not really an Oracle person.

Craig. Received on Fri Sep 09 1994 - 11:30:05 CEST

Original text of this message