Re: ESQL/C and C++??
Posted in 2000
Roman Maurer wrote:
> 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[]).
No. ESQL/C only understands C, not C++ classes. So, unless you declare
your C++
class as a struct with no member functions (ie, as a POD type), you
cannot do it. You
have to extract the members from the class into variables ESQL/C
understands.
There should be a TechInfo 5563 available at the IIUG web site with my
views on
ESQL/C and C++, and a esql++ script which allows you to do things with
C++. It is
of most importance with older versions of ESQL/C; CSDK is pretty clean.
> 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?
Yes. ESQL/C is, after all, for C, not 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.
Yes, but it is necessary.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include
Guardian of DBD::Informix v0.95 -- http://www.perl.com/CPAN
"Windows is NOT a virus: a virus is small and efficient."