I am running 7.1.3 (ecpg 2.8.0) ....seems I need to reference each variable
into the structure for the fetch to succeed. I looked at the generated code
and it's missing the ECPGt_NO_INDICATOR lines in the call to ECPGdo.
Is this a bug? Thanks.
------------ code -------
EXEC SQL include sqlca;
main()
{
EXEC SQL BEGIN DECLARE SECTION;
struct {
char prfc_cd[21];
char prfc_entry[31];
} x;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO ecs;
printf("CONNECT = %d\n",sqlca.sqlcode);
EXEC SQL DECLARE c1 CURSOR FOR select * from pref_char;
printf("DECLARE = %d\n",sqlca.sqlcode);
EXEC SQL open c1;
printf("OPEN = %d\n",sqlca.sqlcode);
while (1) {
EXEC SQL fetch c1 into :x; /* this fails with -200 */
/* this works ...EXEC SQL fetch c1 into :x.prfc_cd,:x.prfc_entry; */
printf("FETCH %d\n",sqlca.sqlcode);
if (sqlca.sqlcode)
break;
printf("X.prfc_cd = %s X.prfc_entry = %s\n",x.prfc_cd,x.prfc_entry);
}
EXEC SQL DISCONNECT;
exit(0);
}