|
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
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.