exec sql include sqlca;

int test(thisone)
EXEC SQL BEGIN DECLARE SECTION;
  char thisone[50];
EXEC SQL END DECLARE SECTION;
{
  printf("Now the pointer is %p\n",thisone);
  EXEC SQL SELECT thisone INTO :thisone FROM t;
  printf("Now the pointer is %p %s\n",thisone,thisone);
  return 0;
}

FILE *dbgs;

main()
{
 char allocated[50];

 if ((dbgs = fopen("log", "w")) != NULL)
        ECPGdebug(1, dbgs);

 exec sql connect to mm;
 exec sql create table t (thisone char(50));
 exec sql insert into t(thisone) values ('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx');
 exec sql commit;

  printf("Now the pointer is %p\n",allocated);
 test(allocated);

 exec sql drop table t;
 exec sql commit;
 exec sql disconnect;

 if (dbgs != NULL)
       fclose(dbgs);
}
