C++ strings and host variables
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Is there a way to use strings as host variables? The example below does not compile under ESQL/C. The underlying C++ compiler is g++ (GNU gcc). ------------------------ cut --------------------- #include <stdio.h> #include <string> #include <iostream> using namespace std; int main() { EXEC SQL BEGIN DECLARE SECTION; string heslo; EXEC SQL END DECLARE SECTION; heslo = "heslo"; } -----------------------cut ----------------------- -- Milos Prudek
Milos Prudek wrote: > Is there a way to use strings as host variables? The example below does > not compile under ESQL/C. The underlying C++ compiler is g++ (GNU gcc). > > ------------------------ cut --------------------- > #include <stdio.h> > #include <string> > #include <iostream> > using namespace std; > > int main() > { > EXEC SQL BEGIN DECLARE SECTION; > string heslo; > EXEC SQL END DECLARE SECTION; > > heslo = "heslo"; > } > -----------------------cut ----------------------- ESQL/C recognizes a type called string, and translates it for you. The C++ compiler doesn't see the declaration of heslo as a C++ string at all -- the ESQL/C compiler ensures this. Look at the generated C code. Even if you worked around that, though, you'd sooner or later run into the problem that ESQL/C would not understand a C++ string. So you have to write your code that calls ESQL/C in terms that the ESQL/C compiler will understand. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>