pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedMultiple SQL statements within a function...
4+ messages / 4 participants
[nested] [flat]
* Multiple SQL statements within a function...
@ 2002-07-31 20:21 Marc Mitchell <marcm@eisolution.com>
2002-08-01 04:06 ` Re: Multiple SQL statements within a function... Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Marc Mitchell @ 2002-07-31 20:21 UTC (permalink / raw)
To: pgsql-admin
If you have multiple SQL statements within a single SQL or PL/PGSQL
function, are they automatically treated as a single multi-statement
transaction or does this require you to put BEGIN/COMMIT statements within
your function which itself would require you to be cognoscente of the
transactional state of your current database session.
Am assume the MST is implicit but have been looking for answer in online
docs and have been unable to confirm one way or the other. Can anyone
sight a documentation reference?
Thanks,
Marc Mitchell
Enterprise Information Solutions, Inc.
marcm@eisolution.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Multiple SQL statements within a function...
2002-07-31 20:21 Multiple SQL statements within a function... Marc Mitchell <marcm@eisolution.com>
@ 2002-08-01 04:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-08-01 04:09 ` Re: Multiple SQL statements within a function... Haroldo Stenger <hstenger@adinet.com.uy>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2002-08-01 04:06 UTC (permalink / raw)
To: Marc Mitchell <marcm@eisolution.com>; +Cc: pgsql-admin
"Marc Mitchell" <marcm@eisolution.com> writes:
> If you have multiple SQL statements within a single SQL or PL/PGSQL
> function, are they automatically treated as a single multi-statement
> transaction
Yes. The function is necessarily invoked within an interactive query
(SELECT, UPDATE, or whatever) and that establishes the transaction
context. The function cannot create a transaction boundary, because
doing so would break whatever query it was called from.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Multiple SQL statements within a function...
2002-07-31 20:21 Multiple SQL statements within a function... Marc Mitchell <marcm@eisolution.com>
2002-08-01 04:06 ` Re: Multiple SQL statements within a function... Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-08-01 04:09 ` Haroldo Stenger <hstenger@adinet.com.uy>
0 siblings, 0 replies; 4+ messages in thread
From: Haroldo Stenger @ 2002-08-01 04:09 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-admin
El jue, 01-08-2002 a las 01:06, Tom Lane escribió:
> Yes. The function is necessarily invoked within an interactive query
> (SELECT, UPDATE, or whatever) and that establishes the transaction
> context. The function cannot create a transaction boundary, because
> doing so would break whatever query it was called from.
That will change with nested transactions support, won't it?
Regards
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Multiple SQL statements within a function...
@ 2002-08-01 02:03 Ludwig Lim <lud_nowhere_man@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: Ludwig Lim @ 2002-08-01 02:03 UTC (permalink / raw)
To: pgsql-admin
>
> --- Marc Mitchell <marcm@eisolution.com> wrote:
> Am assume the MST is implicit but have been
> lookingfor answer in onlinedocs and have been
> unable to confirm one way or the other. Can anyone
> sight a documentation reference?
From the PostgreSQL 7.1.2 Manual section 23.2.
(Structure of PL/pgSQL)
"It is important not to confuse the use of BEGIN/END
for grouping statements in PL/pgSQL with the database
commands for transaction control. PL/pgSQL's BEGIN/END
are only for grouping; they do not start or end a
transaction. Functions and trigger procedures are
always executed within a transaction established by
an outer query --- they cannot start or commit
transactions, since PostgreSQL does not have nested
transactions. "
Hope that helps,
ludwig.
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-08-01 04:09 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-31 20:21 Multiple SQL statements within a function... Marc Mitchell <marcm@eisolution.com>
2002-08-01 04:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-08-01 04:09 ` Haroldo Stenger <hstenger@adinet.com.uy>
2002-08-01 02:03 Re: Multiple SQL statements within a function... Ludwig Lim <lud_nowhere_man@yahoo.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