Received: from www.flamingo.cz (root@fwd.cz [194.212.23.91]) by hub.org (8.9.3/8.9.1) with ESMTP id AAA00894 for ; Thu, 22 Apr 1999 00:02:22 -0400 (EDT) (envelope-from janousek@fonet.cz) Received: from router.fonet2.cz (ts3-3.bm.cesnet.cz [194.212.133.34]) by www.flamingo.cz (8.8.8/8.8.8) with ESMTP id GAA02239; Thu, 22 Apr 1999 06:02:19 +0200 Received: from server (server.fonet2.cz [192.168.0.2]) by router.fonet2.cz (8.9.1/8.9.1) with SMTP id MAA01638; Wed, 21 Apr 1999 12:41:39 GMT Message-ID: <00ab01be8be2$e4581480$0200a8c0@server.fonet2.cz> From: "Pavel PaJaSoft Janousek" To: "Dave Broudy" Cc: "PgSQL Interfaces" Subject: Re: [INTERFACES] ecpg cursors and scope Date: Wed, 21 Apr 1999 12:36:59 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 >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 execsql - 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 ---------------------------------------------------------------------------- ---