pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedTransaction: Begin, Lock
3+ messages / 2 participants
[nested] [flat]
* Transaction: Begin, Lock
@ 1999-09-13 14:58 Margarita Barvinok <brita@umich.edu>
1999-09-14 18:22 ` Re: [INTERFACES] Transaction: Begin, Lock Michael Meskes <meskes@postgreSQL.org>
0 siblings, 1 reply; 3+ messages in thread
From: Margarita Barvinok @ 1999-09-13 14:58 UTC (permalink / raw)
To: pgsql-interfaces
Hi,
I have two questions about transactions.
This is part of my C code.
EXEC SQL CONNECT TO ...
for (i=2; i<x: 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
2. How should I lock the table phonebook during this transaction?
Thank you,
-Margarita
-------------------------------
Margarita Barvinok
System Administrator II
University of Michigan
Department of Biology
-------------------------------
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] Transaction: Begin, Lock
1999-09-13 14:58 Transaction: Begin, Lock Margarita Barvinok <brita@umich.edu>
@ 1999-09-14 18:22 ` Michael Meskes <meskes@postgreSQL.org>
1999-09-15 13:02 ` Re: [INTERFACES] Transaction: Begin, Lock Margarita Barvinok <brita@umich.edu>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Meskes @ 1999-09-14 18:22 UTC (permalink / raw)
To: Margarita Barvinok <brita@umich.edu>; +Cc: pgsql-interfaces
On Mon, Sep 13, 1999 at 10:58:43AM -0400, Margarita Barvinok wrote:
> EXEC SQL CONNECT TO ...
> for (i=2; i<x: 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!
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] Transaction: Begin, Lock
1999-09-13 14:58 Transaction: Begin, Lock Margarita Barvinok <brita@umich.edu>
1999-09-14 18:22 ` Re: [INTERFACES] Transaction: Begin, Lock Michael Meskes <meskes@postgreSQL.org>
@ 1999-09-15 13:02 ` Margarita Barvinok <brita@umich.edu>
0 siblings, 0 replies; 3+ messages in thread
From: Margarita Barvinok @ 1999-09-15 13:02 UTC (permalink / raw)
To: Michael Meskes <meskes@postgreSQL.org>; +Cc: pgsql-interfaces
Michael, thank you very much.
I didn't know this.
-Margarita
On Tue, 14 Sep 1999, Michael Meskes wrote:
> > 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!
>
-------------------------------
Margarita Barvinok
System Administrator II
University of Michigan
Department of Biology
-------------------------------
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1999-09-15 13:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-13 14:58 Transaction: Begin, Lock Margarita Barvinok <brita@umich.edu>
1999-09-14 18:22 ` Michael Meskes <meskes@postgreSQL.org>
1999-09-15 13:02 ` Margarita Barvinok <brita@umich.edu>
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