According to section 24.2.5.3 of
http://www.postgresql.org/users-lounge/docs/7.1/programmer/plpgsql-descripti
on.html
----------------
FOR referrer_keys IN select * from cs_referrer_keys order by try_order
LOOP
a_output := a_output || '' if v_'' || referrer_keys.kind || '' like
''''''''''
|| referrer_keys.key_string || '''''''''' then return
''''''
|| referrer_keys.referrer_type || ''''''; end if;'';
END LOOP;
-- This works because we are not substituting any variables
-- Otherwise it would fail. Look at PERFORM for another way to run
functions
----------------
It says it does not work when substituting variables. This is what I need
to do:
full_sql := 'SELECT ' || sql_fields || ' AS full_name FROM ' || sql_table
|| ' WHERE ' || sql_id_field || ' = ' || user_id;
FOR sql_results IN full_sql LOOP
users_name := sql_results.full_name;
END LOOP;
The variables sql_fields, sql_table, sql_id_field and user_id are previously
set according to some values passed into the function.
Is there a workaround that will accomplish what I am looking for, or am I
stuck to not using a function and doing a two separate queries?
Thanks in advance,
-Dan