Help with Procedures in PL/pgsql

Started by Nelio Alves Pereira Filhoover 25 years ago1 messagesgeneral
Jump to latest

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