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; 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -