Re: VARCHAR and lengths in Pro*C

From: Stephen Laverack <devsl_at_cisa.bt.co.uk>
Date: Mon, 26 Sep 1994 07:20:24 +0000
Message-ID: <Cwq720.1or_at_cisa.bt.co.uk>


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...

Steve Received on Mon Sep 26 1994 - 08:20:24 CET

Original text of this message