Re: Embeded SQL in C++
Posted in 1997
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-684387517-880406582=:2519
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Thu, 20 Nov 1997, Siripa Sapsirin wrote:
> We have a requirement to use C++ on Unix with Informix. We never do this
> before. Is there anyone out there kind enough to give an example code
> and how to compile it? Can we use ESQL/C? Any special option when do the
> pre-compile?
See the IIUG archive (http://www.iiug.org).
Also see attachment, which I updated in early November but forgot to change
a date so I altered it again today. This contains the latest and greatest
version of the material, including some notes on 7.24 ESQL/C which has
some built in C++ support.
Yours,
Jonathan Leffler (johnl@informix.com) #include <witticism.h>
---559023410-684387517-880406582=:2519
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="TechInfo.5563"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.GSO.3.96.971124132302.2519K@anubis.mp.informix.com>
Content-Description: Revised TechInfo 5563: ESQL/C and C++
TechInfo # 5563
Short Description:
Using ESQL/C with a C++ Compiler
Long Description:
From: johnl@informix.com (Jonathan Leffler)
Date: Tuesday 12th December 1995
Updated: Monday 24th November 1997
Subject: Using ESQL/C with C++
One of the more common requests these days is:
How do I compile ESQL/C code for use with C++?
There have been a variety of answers, but not any one systematic answer.
Now there is what I believe is a definitive answer -- it's all in the
attached shell archive.
What do you get?
* Updated ESQL/C prototypes for 4.00, 4.1x, 5.0x and 7.2x
* An esql++ compiler
* A pair of patch files for modifying your standard ESQL/C compiler.
Only use these if your ESQL/C is version 4.1 or 5.x; later versions
already have the necessary change).
* A minimal test application.
* No documentation apart from this message!
What do you need to do?
* Unpack the shell archive.
* Place the esql* headers in either $INFORMIXDIR/incl (version 4)
or $INFORMIXDIR/incl/esql (version 5 or later)
* Place the esql++ script in $INFORMIXDIR/bin
* Decide which version of ESQL/C you are using and set the
ESQLC_VERSION environment variable to a value such as:
export ESQLC_VERSION=506 # 5.06.UC1
* Optionally modify esql++ to give the correct default value of
of ESQLC_VERSION.
* Decide which C++ compiler you use -- if it isn't CC, set:
export INFORMIXC=g++* Try compiling the test application:
esql++ -o testapp testmain.ec testsub.ec
* Run it against your local stores database -- it should say '2'.
What if you can't modify your INFORMIXDIR?
* Copy $INFORMIXDIR/bin/esql to somewhere where you can modify it
(eg /some/where/bin/esql)
* Patch it if necessary.
* Place the headers in another directory (eg /some/where/include).
* Modify esql++ so that:
-- arglist starts of with -I/some/where/include as one component
-- ESQL defaults to /some/where/bin/esql
* If you don't have to patch the esql script, you don't have to copy it
to /some/where/bin and you don't need to make the corresponding
modification in the esql++ script.
What about other versions of ESQL/C?
* If you are still using a pre-4.00 version of ESQL/C, the chances are
that the code which edits the 4.xx code will be useful. However, the
prototypes for the ESQL/C interface functions are not known and will
have to be determined by inspection of the generated code. Good luck!
It will probably be easier to upgrade to a later version.
* I haven't been able to test version 8.xx ESQL/C; it isn't available to
me. However, the indications are that it will need the same treatment
as the other post-5.00 implementations of ESQL/C.
* Testing with the version 9.10 ESQL/C compiler indicates that this
script is still necessary.
* Ideally, you won't need this script at all for post-9.xx versions. If
you are using some later version, you will need to revise the script so
that the case statement on $ESQLC_VERSION handles the new (presumably
4-digit) version number.
* Note that ESQL/C 7.24 has some support for C++ built in. In
particular, it preprocesses files with the .ecpp extension and then
compiles them with the C++ compiler. It may not link the object code
with the C++ compiler; if it doesn't, you'd have to do that by running
the link command it with INFORMIXC="C++ compiler" in the environment.
Which versions of ESQL/C are are known to work with this?
* The code has been tested against Informix-ESQL/C versions 4.12.UC1,
5.06.UC1, 6.00.UE1, 7.13.UC1, 7.22.UC2, 9.10.UC2 on a Sun Sparc 20
running Solaris 2.5.1 with both SUNWspro C++ SPARCompiler SC4.0.1 and
GNU G++ 2.7.2.2.
Are there any known bugs?
* Life will get very difficult if you pass arguments with quotes or
spaces in them to your compiler:
esql++ -DOPENQUOTE="'" -DSOMMAT="string with blanks" thingy.ec
I do have a solution: it is another program called escape which
deals with precisely that sort of problem.
arglist="$arglist `escape $arg`"
But that requires some more source and isn't generally necessary.
Also, the underlying esql script does not work reliably with such
arguments, so the changes needed are even m
b3JlIGV4dGVuc2l2ZS4NCg0KKiAgIFRoZSBlc3FsN18yMC5oIGhlYWRlciBp@@NL