This is a multi-part message in MIME format.
--
Phil,

I haven't got the books here, but I seem to remember to make variables visible 
to the SQL, they need to be defined after some special SQL macro. I can't think 
what it is, but when i get into the office tomorrow, I'll see if I can hunt the 
thing down.

--phil

        -----Original Message-----
        From: Phil [mailto:sublime78ska@attbi.com]
        Sent: Wed 7/10/2002 8:08 PM
        To: c400-l@midrange.com
        Cc:
        Subject: RE: [C400-L] Embedded SQL - SQLC



        I posted this a few weeks ago but had no luck.  Thought I'd give it one 
more
        try :)

        Has anyone any examples of or insight to fetching
        multiple rows into a struct?  I've been following the
        example in the SQL Programming with Host Languages book
        and even keying their example on page 27 verbatim and I
        can not get it to compile.  The error I get is that the
        struct is undefined or unusable.  Unusable must be it
        because in the compile listing I can see that it was
        defined.

        I've included two versions of the code I'm trying to get to compile 
below.

        Thanks very much,

        Phil

        **ver1 (which is out of the Host Programming manual on pg 26 & 27)

          typedef _Packed struct {
            char FIRSTINIT;
            char MIDINIT;
            _Packed struct{
               short LASTNAME_LEN;
               char LASTNAME_DATA[15];
               } LASTNAME;
            float SALARY;
            float BONUS;
            float COMM;
         } empDS;

         empDS hostDS[10];

         EXEC SQL include SQLCA;

        main()
        {

             EXEC SQL
               declare CURSOR cursor for
                 select substr(firstname,1,1), midinit, lastname, salary, 
bonus,
        comm
                 from EMPLOYEE;

             EXEC SQL
               open CURSOR;

             EXEC SQL
               fetch from CURSOR into :hostDS;

           }

        **ver 2**
        #pragma mapinc("EMPLOYEE","*LIBL/EMPLOYEE(*all)","both","d",," ")
        #include "EMPLOYEE"

         SAMPLER_both_t          hostDS[10];

         EXEC SQL include SQLCA;

        main()
        {

             EXEC SQL
               declare CURSOR cursor for
                 select firstname, midinit, lastname, salary, bonus, comm
                 from EMPLOYEE;

             EXEC SQL
               open CURSOR;

             EXEC SQL
               fetch from CURSOR into :hostDS;

           }

        DDS for EMPLOYEE:

             A                                      UNIQUE
             A          R SAMPLER
             A            FIRSTNAME     10
             A            MIDINIT        1
             A            LASTNAME      15
             A            SALARY         7F
             A            BONUS          7F
             A            COMM           7F
             A          K LASTNAME




        _______________________________________________
        This is the C programming iSeries / AS400 (C400-L) mailing list
        To post a message email: C400-L@midrange.com
        To subscribe, unsubscribe, or change list options,
        visit: http://lists.midrange.com/cgi-bin/listinfo/c400-l
        or email: C400-L-request@midrange.com
        Before posting, please take a moment to review the archives
        at http://archive.midrange.com/c400-l.



--
[ winmail.dat of type application/ms-tnef deleted ]


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].