Skip site navigation (1) Skip section navigation (2)

[ECPG] generates bad code on declare/open

From: Tim Nelson <TNELSON(at)ECS-INC(dot)com>
To: "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgresql(dot)org>
Subject: [ECPG] generates bad code on declare/open
Date: 2002-01-09 17:06:52
Message-ID: 63BD6AB4FBBED411B3E20004ACAE8B63014458@str_nt01.ecs-inc.com (view raw or flat)
Thread:
Lists: 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(at)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

Responses

pgsql-interfaces by date

Next:From: Benjamin.FeinsteinDate: 2002-01-10 00:05:53
Subject: [PATCH] notify support for DBD::Pg
Previous:From: David JoynerDate: 2002-01-09 14:01:33
Subject: libpq++

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group