"Kevin Nikiforuk" <Kevin.Nikiforuk@Acrodex.com> writes:
> CREATE OR REPLACE FUNCTION rgio() RETURNS integer as $$
> BEGIN
> DECLARE lv RECORD;
> FOR lv IN SELECT DISTINCT rg FROM ldevrg LOOP
> SELECT ldev FROM ldevrg WHERE ldevrg='$lv';
> END LOOP;
> RETURN 1;
> END;
> $$ LANGUAGE plpgsql;
You've got a small error in the layout: the DECLARE part goes before
BEGIN not after. Swap the first two lines of the function.
regards, tom lane