ecpg - select * into structure problem - Mailing list pgsql-general

From Tim Nelson
Subject ecpg - select * into structure problem
Date
Msg-id iZ5R7.1085$vK1.98901@newsread2.prod.itd.earthlink.net
Whole thread Raw
Responses Re: ecpg - select * into structure problem
List pgsql-general
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);
}




pgsql-general by date:

Previous
From: Jason Earl
Date:
Subject: Re: Inserting the current date
Next
From: "Raul DAVIDOVICH"
Date:
Subject: problem with select after updating