Re: VARCHAR and lengths in Pro*C

From: Tim Smith <tssmith_at_netcom.com>
Date: Mon, 26 Sep 1994 16:43:55 GMT
Message-ID: <tssmithCwqx57.2u5_at_netcom.com>


devsl_at_cisa.bt.co.uk (Stephen Laverack) writes:
>Tim Smith (tssmith_at_netcom.com) wrote:
>: alanb_at_VNET.IBM.COM (Alan Beal) writes:
>: >I am trying to figure out if I can declare a VARCHAR host variable
>: >in Pro*C where the length is determined by a define rather than
>: >hard-coded. Is this possible? I am able to do this:
>: > VARCHAR field1[20];
>: >but not:
>: >#define f1_len 20
>: > ...
>: > VARCHAR field1[f1_len];
>: >Any hints?
 

>: You can do this in Pro*C 2.0 or 2.1. It is not possible in versions of
>: Pro*C earlier than 2.0. Pro*C 2.x includes a C preprocessor (with a
>: very few limitations, see the manual).
 

>: --Tim (tssmith_at_netcom.com) (tssmith_at_oracle.com)
>: Not speaking in any official capacity for Oracle Corp.
 

>If you are on Pro*C 1.x
 

>You could try feeding your code through CPP first, which will expand
>the #defines, then into Pro*C, and then into the C compiler. It is fairly
>easy to adjust the makefile for this.
 

>A couple of problems with this though: increase the IRECLEN parameter, since
>the macro expansions that can occur in CPP make very long line lengths. Also,
>write your SQL in lower case, since CPP will try to convert the uppercase
>words like NULL, etc...

Good tips. A lot of people do this. I didn't mention it, since Oracle doesn't "officially" support it. Your point about NULL is especially relevant.

--Tim (tssmith_at_netcom.com) (tssmith_at_oracle.com) Received on Mon Sep 26 1994 - 17:43:55 CET

Original text of this message