Search Postgresql Archives

Re: looping through query to update column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/13/06, Jean-Christophe Roux <jcxxr@xxxxxxxxx> wrote:

Thanks for the "ctid" trick. The code below worked fine
    for rec in select * from fromemail_trades loop
        update fromemail_trades set recordid = row where ctid = rec.ctid;
        row := row -1;
    end loop;
The first line is a little different from your's:
    FOR row IN SELECT ctid, * FROM table FOR UPDATE LOOP

How important is it to specify ctid in the select and to add 'for update'?

it's not. also, without a where clause you are better off just locking
the table (lock table...).  also, the above loop is better achieved
via a single query.

merlin


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux