Thread: Re: [INTERFACES] ecpg cursors and scope

Re: [INTERFACES] ecpg cursors and scope

From
"Pavel PaJaSoft Janousek"
Date:
>>     I think, that principly is correct contructions like this:
>
>No, to do this you need the PREPARE statement.

   Thanks, but in PostgreSQL or ECPG manual isn't this... and I forgot
syntax from Oracle...Could you put some example (the best is the contruction
below)?

if (cond)   exec sql declare cur cursor for select count (*) from tpm;
else   exec sql declare cur cursor for select count (*) from tpm where col1 =
:cislo1;
exec sql open cur;
exec sql whenever not found break;
while (1)
{   exec sql fetch in cur into :cislo2;
}
   Thanks...

-------------------------------------------------------------------------
Pavel Janousek (PaJaSoft)                         FoNet, spol. s r. o.
Vyvoj software, sprava siti, Unix, Web, Y2K     Anenska 11, 602 00  Brno
E-mail: mailto:Janousek@FoNet.Cz                Tel.: +420  5  4324 4749
SMS:    mailto:P.Janousek@SMS.Paegas.Cz         Fax.: +420  5  4324 4751
WWW:    http://WWW.FoNet.Cz/                  E-mail: mailto:Info@FoNet.Cz
--------------------------------------------------------------------------




Re: [INTERFACES] ecpg cursors and scope

From
Michael Meskes
Date:
On Fri, Apr 23, 1999 at 10:17:03AM +0200, Pavel PaJaSoft Janousek wrote:
>     Thanks, but in PostgreSQL or ECPG manual isn't this... and I forgot

Shame on me. :-( Yes, the docs need much more work.

> syntax from Oracle...Could you put some example (the best is the contruction
> below)?

Please check the test source under .../ecpg/test.

How about this

if (cond)    strcpy(query, "select count (*) from tpm");else    strcpy(query, "select count (*) from tpm where col1 =
?");
exec sql prepare MM from :query;exec sql declare prep cursor for MM;
exec sql open prep using :cislo1;
exec sql whenever not found break;while (1){    exec sql fetch in cur into :cislo2;}
But speaking of this. It appears ecpg cannot do prepares without variables
at the moment. This is a bug. I just didn't see this so far.

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net          | Use PostgreSQL!