Re: Generic DECLARE SQL-statement ???
Posted in 1993
I'd like to add a few words to what Jonathan wrote: we have a layer of interface software that attempts this [it was originally an interface to TUXEDO/UNITS software]. WE're currently using 2.10 ESQL, because we've been UNABLE to upgrade the this scheme to 4.10. [But are engine is Online]. While this is technically compatible, Informix support must shudder each time we call with a problem. Anyway, under 4.10, for some reason, after using the same name and freeing in a few times, something gets confused, and insists that you're reusing a cursor name. In 2.10, this was permissable, but not now. Our sister project has gone to 5.0, and used the cursor name in a host variable to insure uniqueness [basically, they've combined BOTH of the suggestions below]. I'm starting to evaluate 5.0 to see if that works for us as well. The biggest concern I have, is that this code is EXCRUCIATINGLY complicated, and tied into the internals of ESQL. This has SEVERAL problems: 1). Informix support - basically, they won't help if you run into an obstacle with this approach because of the messing around with the internals. 2). Even if they would, the code can get so complicated that they don't understand what's being done. [This is not to find fault with INFORMIX - in their position, I'd probably take the same approach]. 3). last, and certainly not least: MAINTENANCE. I didn't write the code in question, I just have to get it to work. Several BRILLIANT programmers worked on it 3-4 years ago, and they only have a foggy idea of what this code does, and how it does it. Unfortunately, we have too much existing code to rip this all out, as much as I'd like to. My final word of advice is: KISS Standard disclaimers apply. Ihor Kinal att!trumpet!ijk P.S. I thought that direct C++ did not work with ESQL. Has anyone found an effective interface?? In article <25o40bINN5eu@emory.mathcs.emory.edu>, johnl@rent2.informix.com (Jonathan Leffler) writes: > 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>