pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
select ... for update in plpgsql
2+ messages / 2 participants
[nested] [flat]

* select ... for update in plpgsql
@ 2001-04-20 20:03 Jie Liang <jliang@ipinc.com>
  2001-04-24 10:57 ` Re: [SQL] select ... for update in plpgsql Cedar Cox <cedarc@visionforisrael.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jie Liang @ 2001-04-20 20:03 UTC (permalink / raw)
  To: pgsql-sql; pgsql-admin@postgresql.org


Hi,

I have a question about 'select ... for update';
according to the docs,
clause 'for update' will lock selected rows,
I believe it should be put into a
begin;
select ... for update;
update ...;
end; 
block.

however, if I use it in a plpgsql function,
do I need another pair of begin...end?
or say begin...end in plpgsql can lock chosen rows until
updated ALL ROWS?
if not, do you have any suggestion?



Jie LIANG

St. Bernard Software

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] select ... for update in plpgsql
  2001-04-20 20:03 select ... for update in plpgsql Jie Liang <jliang@ipinc.com>
@ 2001-04-24 10:57 ` Cedar Cox <cedarc@visionforisrael.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Cedar Cox @ 2001-04-24 10:57 UTC (permalink / raw)
  To: Jie Liang <jliang@ipinc.com>; +Cc: pgsql-sql; pgsql-admin@postgresql.org


'select ... for update' needs to be inside a transaction.  plpgsql cannot
start or end transactions.  'begin' and 'end' are not transaction
statements.  (read the docs).

-Cedar

On Fri, 20 Apr 2001, Jie Liang wrote:

> 
> Hi,
> 
> I have a question about 'select ... for update';
> according to the docs,
> clause 'for update' will lock selected rows,
> I believe it should be put into a
> begin;
> select ... for update;
> update ...;
> end; 
> block.
> 
> however, if I use it in a plpgsql function,
> do I need another pair of begin...end?
> or say begin...end in plpgsql can lock chosen rows until
> updated ALL ROWS?
> if not, do you have any suggestion?
> 
> 
> 
> Jie LIANG
> 
> St. Bernard Software
> 
> 10350 Science Center Drive
> Suite 100, San Diego, CA 92121
> Office:(858)320-4873
> 
> jliang@ipinc.com
> www.stbernard.com
> www.ipinc.com
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-04-24 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-20 20:03 select ... for update in plpgsql Jie Liang <jliang@ipinc.com>
2001-04-24 10:57 ` Cedar Cox <cedarc@visionforisrael.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