Help with Procedures in pgsql - Mailing list pgsql-general

From Nelio Alves Pereira Filho
Subject Help with Procedures in pgsql
Date
Msg-id 3A22A8BF.DEB13BB5@ifx.com.br
Whole thread Raw
List pgsql-general
I have the folowing procedure:

CREATE FUNCTION set_counter () RETURNS INT AS '
DECLARE
    nivel_rec record;
    new_count integer;
BEGIN
    UPDATE nivel SET count=-1;

    FOR nivel_rec IN SELECT * FROM nivel LOOP
        new_count := set_counter_row (nivel_rec);
        UPDATE nivel SET count = new_count WHERE id = nivel_rec.id;
    END LOOP;

    RETURN new_count;
END;'
LANGUAGE 'plpgsql';


I create it, but when I do 'select set_counter()', it says
IFX=# select set_counter();
ERROR:  Attribute 'nivel_rec' not found


Isn't that the right sintax to declare variables in pgsql? Does my
procedure contain any other errors that will appear later?

Thanks


--
Nelio Alves Pereira Filho
IFX Networks
Sao Paulo / Brazil

pgsql-general by date:

Previous
From: GH
Date:
Subject: Re: [HACKERS] Re: PHPBuilder article -- Postgres vs MySQL
Next
From: selkovjr@mcs.anl.gov
Date:
Subject: Re: [HACKERS] Indexing for geographic objects?