postgresql - postgres function 101: returning text -
i have function this:
create or replace function current_name() returns text 'select foo;' language sql;
except doesn't work. neither return text "select 'foo';"
how can keep written in sql, still return text?
i think least change need make work.
create or replace function current_name() returns text 'select ''foo''::text;' language sql;
you'll see sql statement--the body of function--is string. strings have quoted, , single quotes within quoted string have escaped. have more quotation marks actual text.
the usual way write use dollar quoted string constant.
create or replace function current_name() returns text $$ select 'foo'::text; $$ language sql;