Andreas Kretschmer wrote:
create or replace function zip_foo(OUT out_id int, OUT out_name text, OUT 
out_name2 text) returns setof record as $$
declare
        my_rec  RECORD;
        my_name TEXT;
begin
        for my_rec in select id, name, parent_tbl, parent_id from zip  LOOP
                execute 'select name from ' || my_rec.parent_tbl || ' where id 
= ' || my_rec.parent_id || ';' into my_name;
                out_id := my_rec.id;
                out_name := my_rec.name;
                out_name2 := my_name;
                return next;
        end loop;
end;
$$ language plpgsql;
Thanks, Andrew. I was hoping for a pure SQL solution but your idea will certainly work.

John

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to