Received: from tanja.fam-meskes.de (root@p3E9D3DCD.dip0.t-ipconnect.de [62.157.61.205]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA42902 for ; Tue, 14 Sep 1999 14:52:57 -0400 (EDT) (envelope-from michael@fam-meskes.de) Received: (from michael@localhost) by tanja.fam-meskes.de (8.9.3/8.9.0/Debian/GNU) id UAA05436; Tue, 14 Sep 1999 20:22:15 +0200 Date: Tue, 14 Sep 1999 20:22:15 +0200 From: Michael Meskes To: Margarita Barvinok Cc: pgsql-interfaces@postgreSQL.org Subject: Re: [INTERFACES] Transaction: Begin, Lock Message-ID: <19990914202215.A5414@gmx.net> Mail-Followup-To: Margarita Barvinok , pgsql-interfaces@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i In-Reply-To: ; from Margarita Barvinok on Mon, Sep 13, 1999 at 10:58:43AM -0400 On Mon, Sep 13, 1999 at 10:58:43AM -0400, Margarita Barvinok wrote: > EXEC SQL CONNECT TO ... > for (i=2; i strncpy(oid_c, entries[i].val, 10); /* get oid */ > oid_rec = atoi(oid_c); > EXEC SQL BEGIN WORK; > EXEC SQL DELETE FROM phonebook > WHERE oid = :oid_rec; > EXEC SQL COMMIT WORK; > } > EXEC SQL DISCONNECT; > > 1. Why i get the following message when I run this code? > NOTICE: BeginTransactionBlock and not in default state I take it you did not use 'ecpg -t' did you? The normal situation is that ecpg creates a auto-transaction mode, i.e. a transaction is started automatically. You only need to issue a COMMIT once you finish your transaction resp. a ROLLBACK if you want to cancel it. So you tell the backend to start a transaction while already inside a transaction. And that cannot work. You can either just remove the BEGIN WORK statement or you always give option '-t' to ecpg. > 2. How should I lock the table phonebook during this transaction? Why do you need that? You do not need an explicit lock for the delete to work. 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@Fam-Meskes.De | Use PostgreSQL!