Re: [SQL] select ... for update in plpgsql

From: Cedar Cox <cedarc(at)visionforisrael(dot)com>
To: Jie Liang <jliang(at)ipinc(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: [SQL] select ... for update in plpgsql
Date: 2001-04-24 10:57:18
Message-ID: Pine.LNX.4.21.0104241353420.21572-100000@nanu.visionforisrael.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql


'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(at)ipinc(dot)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(at)postgresql(dot)org)
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jared Sulem 2001-04-24 14:23:44 Re: Restricting user access to databases
Previous Message Dan Browning 2001-04-24 06:10:28 Re: Large database help

Browse pgsql-sql by date

  From Date Subject
Next Message Francis Solomon 2001-04-24 11:54:33 RE: Timezone conversion
Previous Message Cedar Cox 2001-04-24 10:16:11 Re: Timezone conversion