Generic DECLARE SQL-statement ???
Posted in 1993
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I'm writing an abstraction layer in C++ for the INFORMIX ESQL/C interface. I'm somewhat stuck with the problem of writing a generic DECLARE statement with respect to the cursor name. As far as I know you cannot put a DECLARE into a PREPARE statement, so I've found no way to use a C-string as a cursor name in ESQL/C. The only solution I've found is to provide a fixed number of cursors in that layer, which are used stack-like. This solution works as far nobody wants to open more cursors than I provide at the same time, but it is not what I wanted. Any suggestions ??? Thanks for any advice. --- _/_/_/_/_/ _/_/_/_/ _/_/_/_/ Michael Jatzeck _/ _/ _/ _/ michel@taz.de _/ _/_/_/_/ _/ die tageszeitung Abt.: EDV _/ _/ _/ _/ Germany _/ _/ _/ _/ 1000 Berlin 61 Phone: +30-259-02-106 _/ _/ _/ _/_/_/_/ Kochstr. 18 FAX : +30-251-06-94
In comp.databases.informix michel@taz.de writes: >I'm writing an abstraction layer in C++ for the INFORMIX ESQL/C interface. >I'm somewhat stuck with the problem of writing a generic DECLARE statement >with respect to the cursor name. As far as I know you cannot put a >DECLARE into a PREPARE statement, so I've found no way to use a C-string >as a cursor name in ESQL/C. The only solution I've found is to provide a >fixed number of cursors in that layer, which are used stack-like. This >solution works as far nobody wants to open more cursors than I provide at >the same time, but it is not what I wanted. Two possibilities: (a) Preferred, because it is supported: Use ESQL/C Version 5.00 or above, where you can use cursors with strings for names. Beware of memory leaks. (b) Non-preferred because it is (i) unsupported, and (ii) subject to change per release of ESQL/C, and (iii) you will need to fiddle with the details to get it to work correctly: You can allocate your own cursor structures -- this is C/C++ after all. You can use a single fixed name cursor/statement for all operations. Before doing any operation on any of your cursor structures, you copy it into the fixed name structure; after completing the operation, you copy the fixed name structure back over your own. The good news is that this is probably easier to automate in C++ than in C. The bad news is that you'll have to dissect the C code generated by your version of ESQL/C, and you'll have to expect the details to change when you upgrade. Beware of FREE. Beware of DESCRIBE releasing sqlda structures. Beware! And I never said anything about it. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>