Search Postgresql Archives

looping through query to update column

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

 



Hello,
I am trying to loop through a table to update one column

create or replace function foo() returns integer as $$
declare
    rec RECORD;
    row integer := 0;
begin
    for rec in select * from table loop
        update rec set recordid = row;
        row++;
    end loop;
    return 0;
end;
$$ language plpgsql

In pgadmin, I am getting the following error message, but that does not help me much:
ERROR:  syntax error at or near "$1" at character 9
QUERY:  update  $1  set recordid =  $2
CONTEXT:  SQL statement in PL/PgSQL function "foo" near line 6

Thanks for any help
JCR



[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