RE: Structures in ESA/C
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Put your Structure inside the DECLARE block; like this: EXEC SQL BEGIN DECLARE SECTION; struct customer_t { int c_no; char fname[LEN]; char lname[LEN]; } CUST_REC; EXEC SQL END DECLARE SECTION; Hassan Eshtiaghi ---------- > From: Mel Haynes Jr <mhaynesjrIHATESPAM@pcisys.net> > To: informix-list@iiug.org > Subject: structures in ESQL/C > Date: Thursday, September 16, 1999 11:23 PM > > I am having a problem with structures inside a header file and using them in > an .ec file. I took this example straight from the documentation and it is > not compiling. I am trying to use a structure that is defined in a header > file, "i.h" and I am getting two errors, one where the variable is defined, > > esqlc: "sample.ec", line 12: Warning -33014: Illegal use of record/structure > 'CUST_REC'. > > and one where the variable is used, > > esqlc: "sample.ec", line 21: Error -33037: 'c_no' is not a component of > record 'cust'. > > Here is the complete code > > i.h file > > #define LEN 15 > > typedef struct customer_t { > int c_no; > char fname[LEN]; > char lname[LEN]; > } CUST_REC; > > // end i.h > > sample.ec file > > #include <stdio.h> > #define LEN 15 > $include "i.h"; // tried putting this in a declare section with no success > > void main() > { > EXEC SQL BEGIN DECLARE SECTION; > CUST_REC cust; // <- error on this line > EXEC SQL END DECLARE SECTION; > > EXEC SQL PREPARE TestPrep FROM > 'SELECT count(*) from store'; > > EXEC SQL DECLARE TestCurs CURSOR FOR TestPrep; > > EXEC SQL OPEN TestCurs; > EXEC SQL FETCH TestCurs INTO :cust.c_no; // <- error on this line > EXEC SQL CLOSE TestCurs; > EXEC SQL FREE TestCurs; > > printf( "Number of rows in the store table are: %d\\n", cust.c_no ); > } > > When I declare the structure above the main function it works fine. Is there > some setting that I am leaving out or am I just doing something wrong. Any > help will be appriciated. > > -- > Mel Haynes Jr > mailto:mhaynesjrIHATESPAM@pcisys.net > ( remove IHATESPAM to respond ) > > > >