Re: ESQL and function definitions
Posted in 1994
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
In article ibh@portal.gmu.edu, twallace@mason1.gmu.edu (Todd A Wallace) writes:
|I am new to ESQL, and although it has been going smoothly so far, I am
|having some problems from some shared function headers that I have just
|written:
|
|int payupdt(club, memno, amount)
|$char club[CLUB_L];
|$char memno[MEMNO_L];
|*/
|$double amount;
|
|These functions work perfectly until I try to put a previously #defined
|amount (CLUB_L) in the function header. However, the definitions work
|fine in function body.
|
|Any ideas?
The occurs because ESQL does not know what your #defines expand out to.
I believe there is a problem (well, I'll call it a problem for now) with
ESQL and cpp (the C pre-processor). This means you can't really use
#defines in statements that the pre-processor has to know about.
There are a couple of word-arounds.
Firstly - Don't use #defines in pre-processor statements. This is not as
hard as it seems. For the above example, you could declare your parameters
to the function as char *club and char *memno. In the case of
SELECT * from table where idnumber = :DEFINED_CONSTANT
you have to create a variable (eg an int) and assign it the DEFINED_CONSTANT,
so you can use the variable in the SQL statement.
As another workaround, I have seen a shell script that invokes cpp on your
esql file, and then passes it to esql. Line numbers (for debuggers) are
preserved. If you look back in this newsgroup you should be able to find this.
I don't remember who wrote it, but if anyone wants a copy, I can mail it to
you.
- Ben Kelley.
--
Ben Kelley (Good Guy) - SBC Australia Ltd. Hey wow! If your hold the
thinnet cable to your ear,
ben@syd.au.swissbank.com (Preferred) you can hear the information
kelley@il.us.swissbank.com (NeXT mail OK) 22 wheelers... (Children - don't
Phone +61 2 258 2382 ("Hello, this is Ben.") try this at home.)