pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedLibpq and transactions
3+ messages / 2 participants
[nested] [flat]
* Libpq and transactions
@ 2004-07-06 23:50 Brijesh Shrivastav <Bshrivastav@esri.com>
0 siblings, 1 reply; 3+ messages in thread
From: Brijesh Shrivastav @ 2004-07-06 23:50 UTC (permalink / raw)
To: pgsql-interfaces
Hi!
I have a question about how transaction behaves in libpq library.
It is very clear in doc that PQexec treats each command (which could
comprise of more than one sql command) as a single transactions.
Does PQexecParams() and PQexecPrepared() also behaves the same?
Is there a way to send multiple sql commands separately through
libpq library and rollback if nth command fails. For example, Can I
insert 5 rows using PQexecParams() and rollback all 5 rows if
sixth insert fails?
Regards,
Brijesh
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Libpq and transactions
@ 2004-07-07 07:05 Tomasz Myrta <jasiek@klaster.net>
parent: Brijesh Shrivastav <Bshrivastav@esri.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tomasz Myrta @ 2004-07-07 07:05 UTC (permalink / raw)
To: Brijesh Shrivastav <Bshrivastav@esri.com>; +Cc: pgsql-interfaces
On 2004-07-07 01:50, Użytkownik Brijesh Shrivastav napisał:
> Hi!
>
> I have a question about how transaction behaves in libpq library.
> It is very clear in doc that PQexec treats each command (which could
> comprise of more than one sql command) as a single transactions.
Not exactly. PQexec treats each command as a single transaction only
when you don't add "begin" before your query. If you add "begin" before
first query - it will finish after "commit" or "rollback".
Regards,
Tomasz Myrta
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Libpq and transactions
@ 2004-07-07 16:28 Brijesh Shrivastav <Bshrivastav@esri.com>
0 siblings, 0 replies; 3+ messages in thread
From: Brijesh Shrivastav @ 2004-07-07 16:28 UTC (permalink / raw)
To: pgsql-interfaces
Thanks for clarification! I got confused with document wording.
Brijesh Shrivastav
-----Original Message-----
From: Tomasz Myrta [mailto:jasiek@klaster.net]
Sent: Wednesday, July 07, 2004 12:05 AM
To: Brijesh Shrivastav
Cc: PostgreSQL Interfaces
Subject: Re: [INTERFACES] Libpq and transactions
On 2004-07-07 01:50, Użytkownik Brijesh Shrivastav napisał:
> Hi!
>
> I have a question about how transaction behaves in libpq library.
> It is very clear in doc that PQexec treats each command (which could
> comprise of more than one sql command) as a single transactions.
Not exactly. PQexec treats each command as a single transaction only
when you don't add "begin" before your query. If you add "begin" before
first query - it will finish after "commit" or "rollback".
Regards,
Tomasz Myrta
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2004-07-07 16:28 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-06 23:50 Libpq and transactions Brijesh Shrivastav <Bshrivastav@esri.com>
2004-07-07 07:05 ` Tomasz Myrta <jasiek@klaster.net>
2004-07-07 16:28 Re: Libpq and transactions Brijesh Shrivastav <Bshrivastav@esri.com>
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