[ECPG] generates bad code on declare/open - Mailing list pgsql-interfaces

From Tim Nelson
Subject [ECPG] generates bad code on declare/open
Date
Msg-id 63BD6AB4FBBED411B3E20004ACAE8B63014458@str_nt01.ecs-inc.com
Whole thread Raw
Responses Re: [ECPG] generates bad code on declare/open  (Michael Meskes <meskes@postgresql.org>)
List pgsql-interfaces
How do I handle host variables passed in the where clause
of a declared cursor?  It seems "ecpg" 2.9 takes the declare/open
and puts the resulting code near the open.  This seems to be a bad
thing if the host variable is declared in a different block or function:

Consider...

func()
{  exec sql begin declare section;     int i;  exec sql end declare section;
  exec sql declare c1 cursor for select x from y where i = :i;
}
func2()
{  exec sql open c1;
}

...yields...
  /* exec sql begin declare section */


#line 3 "a.pgc"  int  i   ;
/* exec sql end declare section */
#line 4 "a.pgc"

  /* declare c1  cursor for select  x   from y where i  = ?   */
#line 6 "a.pgc"

}
func2()
{  { ECPGdo(__LINE__, NULL, "declare c1  cursor for select  x   from y where
i
= ?  ",  ECPGt_int,&(0~V7@0~V7@^P),1L,1L,sizeof(int),  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_EORT);}
#line 10 "a.pgc"

}

Obviously the precompiler has no knowledge of the local host variable
in the other function.

Tim Nelson


pgsql-interfaces by date:

Previous
From: Tom Lane
Date:
Subject: Re: libpq doing strange things
Next
From: Benjamin.Feinstein@guardent.com
Date:
Subject: [PATCH] notify support for DBD::Pg