ESQL/C and C++??
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
I would like to use C++ in a new project, but cannot find much information regarding the use of ESQL/C with C++, apart from a couple of cryptic bug fixes - can it be done? Development platform is HP-UX 10.20 and Informix 7.3 Regards, Neil
By default , Informix uses the cc compiler when compiling a .ec file into an object. Set the environment variable INFORMIXC to point to the C++ compiler on your system and it will be used. That's about it. Works fine with us. Rudy Neil Strong wrote: > I would like to use C++ in a new project, but cannot find much information > regarding the use of ESQL/C with C++, apart from a couple of cryptic bug > fixes - can it be done? > > Development platform is HP-UX 10.20 and Informix 7.3 > > Regards, > Neil
Rudy Fernandes wrote:
>
> By default , Informix uses the cc compiler when compiling a .ec file
> into an object. Set the environment variable INFORMIXC to point to the
> C++ compiler on your system and it will be used. That's about it.
> Works fine with us.
Thanks for the tip, now I can access SQL commands in my C++ programs
without needing to link them to ESQL/C.
But is it possible to declare a class member so that it can be
directly accessible with ESQL/C++? I'd like to write something like
that:
_________________________________________
class foo
{
public:
int var
};
....
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
foo FooObj;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO 'stores7';
....
EXEC SQL
SELECT COUNT(*)
INTO :FooObj.var
FROM customer; ....
}
_________________________________________
Can this be done?
--
Pozdrav,
Roman
Roman Maurer wrote:
> class foo
> {
> public:
> int var
> };
>
> ....
>
> int main()
> {
> EXEC SQL BEGIN DECLARE SECTION;
> foo FooObj;
> EXEC SQL END DECLARE SECTION;
> EXEC SQL CONNECT TO 'stores7';
> ....
> EXEC SQL
> SELECT COUNT(*)
> INTO :FooObj.var
> FROM customer;> ....
> }
I don't think so, although I could be wrong. Datatypes within the BEGIN
DECLARE and END DECLARE may only belong to a specific set (as defined in
the manual) that ESQL understands. User-defined variables are not allowed.
Of course, you could modify your code to the following
class foo
{
public:
int var
};
....
int main()
{
foo FooObj;
EXEC SQL BEGIN DECLARE SECTION;
int l_count;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO 'stores7';
....
EXEC SQL
SELECT COUNT(*)
INTO :l_count
FROM customer;
FooObj.var=l_count;
....
}
Rudy
Rudy Fernandes wrote:
>
> > EXEC SQL BEGIN DECLARE SECTION;
> > foo FooObj;
> > EXEC SQL END DECLARE SECTION;
>
> I don't think so, although I could be wrong. Datatypes within the
> BEGIN DECLARE and END DECLARE may only belong to a specific set
> (as defined in the manual) that ESQL understands. User-defined
> variables are not allowed.
Sorry, my expressions was misleading. I don't want to access the
whole object within ESQL, just the members which are of standard
types (int, double, char[]).
So, final goal would be to write some DECLARE statements (preferably
in class declaration?), followed by the "great finale":
EXEC SQL
SELECT COUNT(*)
INTO :FooObj.var
FROM customer;
I guess this is too much to expect from ESQL/C?
> Of course, you could modify your code to the following [...]
>
> foo FooObj;
> EXEC SQL BEGIN DECLARE SECTION;
> int l_count;
> EXEC SQL END DECLARE SECTION; [...]
>
> EXEC SQL [...]
>
> FooObj.var=l_count;
Yes, this is what I did. But it's pretty cumbersome to mention all
the ESQL/C variables three times - in declaration, in SQL statement
and in assignment to class member.
--
Pozdrav,
Roman