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

ecpg did not precompile declare cursor

From: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
To: bernhard_rueckerl(at)yahoo(dot)de
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: ecpg did not precompile declare cursor
Date: 2002-02-20 09:21:12
Message-ID: 15475.27272.230954.548931@kelvin.csl.co.uk (view raw or flat)
Thread:
Lists: pgsql-bugs
This is expected behaviour, the 'real' code gets emitted when you OPEN
the cursor, i.e. you should be doing something like:

 EXEC SQL DECLARE demo_cur CURSOR FOR
   SELECT field1, field2
   FROM test;
 EXEC SQL OPEN demo_cur;
 if( sqlca.sqlcode != 0 )
 {
   some_error();
   return;
 }
 while( 1 )
 {
   EXEC SQL FETCH demo_cur INTO :field1, :field2;
   if( sqlca.sqlcode < 0 )
   {
     some_error();
     break;
   }
   else if( sqlca.sqlcode != 0 ) /* or == 100... */
     break;

   process_row();
 }
 EXEC SQL CLOSE demo_cur;

Bernhard Rückerl writes:
 > Hello,
 > 
 > I have downloaded postgresql 7.2 on my machine.
 > Running ecpg on my .ec-file I found that ecpg did not process 
 > the statements "exec sql declare xxx cursor for select.
 > 
 > The part in my .ec-file:
 > if ( firstcall )
 >    {
 >    calid1 = calid;
 >    EXEC SQL DECLARE CURMFDPOINT CURSOR FOR SELECT STABLE_OR_INSTABLE , 
 >             HIERARCHY , POINT_ID , X1 , P1 , X2 , P2 FROM MANIFOLD_POINTS WHERE 
 >             CAL_ID = :calid1;
 >    raiseerror( );
 >    firstcall = false;
 >    }
 > 
 > was transformed into
 > if ( firstcall )
 >    {
 >    calid1 = calid;
 >    /* declare CURMFDPOINT  cursor for select  STABLE_OR_INSTABLE  , HIERARCHY  , POINT_ID  , X1  , P1  , X2  , P2   from MANIFOLD_POINTS where CAL_ID  = ?   */
 > #line 224 "dbcontrol.ec"
 > 
 >    raiseerror( );
 >    firstcall = false;
 >    }
 > So the declare cursor statement was just commented out. As a consequence the 
 > programm terminated with sqlca.sqlcode=-602 when doing the according 
 > fetch statement.

In response to

pgsql-bugs by date

Next:From: Andy MardenDate: 2002-02-20 20:37:12
Subject: Re: Dates and year 2000
Previous:From: pgsql-bugsDate: 2002-02-20 01:20:33
Subject: Bug #597: ResultSet.next() throws NullPointerException

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