pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel PaJaSoft Janousek <janousek@fonet.cz>
To: Dave Broudy <shaggy@broudy.net>
Cc: PgSQL Interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: [INTERFACES] ecpg cursors and scope
Date: Wed, 21 Apr 1999 12:36:59 +0200
Message-ID: <00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz> (raw)

>A) In seperate functions:
>
>func1() {
>  exec sql declare test_cur for ...
>}
>func2() {
>  exec sql declare test_cur for ... /* same or different sql */
>}
>
>B) In an if:
>
>if(...) {
>  exec sql declare test_cur for ...
>} else {
>  exec sql declare test_cur for ... /* same or different sql */
>}
>
>These both yield "cursor test_cur already defined"


    I try this too, but I got the same error... )ECPG distributed with
PostgreSQL 6.4.2)

    I think, that principly is correct contructions like this:

    if (condition)
    {
        exec sql declare cur cursor for select count (*) from tmp where
col1 - :num;
    }
    else
    {
        exec sql declare cur cursor for select count (*) from tmp;
    }
    exec sql whenever not found continue;
    exec sql open cur;
    exec sql whenever not found do break;
    while (1)
    {
        exec sql fetch in cur into :num1;
    }

    But this isn't allow too, because second exec sql declare.... - in this
line I got the same message...:-(

    One time I wrote this exec<space><space>sql - and ECPG say parse error
too, but I forgot, that bad was only this two spaces between 'exec' and
'sql'....

    Next, some 'interesting' situations I got when I use exec sql
whenever... - scope for this is not as the program running, but as the
source is parsing... - this is ...'-)

----------------------------------------------------------------------------
--
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
----------------------------------------------------------------------------
---





view thread (8+ messages)  latest in thread

Message-ID: <00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz>
Permalink:  ../00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz/
Also on:    postgresql.org/message-id/00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: janousek@fonet.cz, shaggy@broudy.net
  Subject: Re: [INTERFACES] ecpg cursors and scope
  In-Reply-To: <00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox