looping through records...

Поиск
Список
Период
Сортировка
От Bob Whitehouse
Тема looping through records...
Дата
Msg-id 019701c0c843$84474080$a6a0fea9@amsite.com
обсуждение исходный текст
Ответы Re: looping through records...  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: looping through records...  ("Albert REINER" <areiner@tph.tuwien.ac.at>)
Список pgsql-novice
I'm trying to create a function that loops through records returned from a
query. This is what I came up with but it doesn't work. Can anyone tell me
what I'm doing wrong?

CREATE FUNCTION test_loop(INT4, VARCHAR)
    RETURNS INT4
    AS 'DECLARE
        int_key ALIAS FOR $1;
        var_test VARCHAR;

    BEGIN
        var_test := $2;
        FOR row IN SELECT * FROM companies LOOP
            UPDATE companies SET name = var_test;
        END LOOP;
        RETURN int_key;
    END;'
LANGUAGE 'plpgsql';

Here's how I call the test loop and the error I get:

db=# SELECT test_loop(1, 'testing');
ERROR: parse error at or near ";"
db=#

Thanks



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

Предыдущее
От: David Olbersen
Дата:
Сообщение: Re: < Int4 - limit >
Следующее
От: Tom Lane
Дата:
Сообщение: Re: looping through records...