Re: VARCHAR and lengths in Pro*C
Date: 8 Oct 1994 22:39:04 +1000
Message-ID: <3763t8$s55_at_werple.apana.org.au>
tssmith_at_netcom.com (Tim Smith) writes:
>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)
Assume you are using Unix - try the m4 macro "define". You need to modify the makefile to run m4 prior to pre-compile the source, and remember to keep a backup copy of the original (a cautious move). It behaves very similar to CPP #define, even better in this case.
Kiet (kchau_at_werple.apana.org.au) Received on Sat Oct 08 1994 - 13:39:04 CET