How to execute a string result of a stored procedure in postgres
I have created the following stored procedure, which basically receives a name of table, and a prefix. The function then finds all columns that share this prefix and returns as an output a 'select' query command ('myoneliner'). as follows: CREATE OR REPLACE FUNCTION mytext (mytable text, myprefix text) RETURNS text AS $myoneliner$ declare myoneliner text; BEGIN SELECT 'SELECT ' || substr(cols,2,length(cols)-2) ||' FROM '||mytable INTO myoneliner FROM ( SELECT array( SELECT DISTINCT quote_ident(column_name::text) FROM information_schema.columns WHERE table_name = mytable AND column_name LIKE