looping through query to update column

Поиск
Список
Период
Сортировка
От Jean-Christophe Roux
Тема looping through query to update column
Дата
Msg-id 20061012231323.26267.qmail@web35305.mail.mud.yahoo.com
обсуждение исходный текст
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: Jonathan Vanasco
Дата:
Сообщение: Re: bad error message
Следующее
От: Tom Lane
Дата:
Сообщение: Re: bad error message