How do I get this to work? create or replace function getquadalphabet(text) returns
setof varchar as $$ declare r varchar; begin for r in SELECT distinct(substring(drgtitle, 1, 1)) as text
from stockdrgmeta where state ilike '%' || $1 || '%' return next r; END end; $$ language plpgsql; loop variable of loop over rows must be record or row
variable at or near "LOOP" at character 218 The documentation says http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html Note: The PL/pgSQL parser presently distinguishes the two kinds
of FOR
loops (integer or query result) by checking whether ..
appears outside any parentheses between IN and So where do I put the “..” so that r can be of varchar or
text? If I make R a record, it returns something like (A) instead of A –
you know what I mean? All I want to do is return a setof text or varchar! Thanks! -Scott |