0

Just wanted to come back to this question as proposed solution (using a temp table) Are there other ways to select a dynamic list of columns? didn't exactly work for me.

My scenario (using example from the link above):

CREATE OR REPLACE FUNCTION webview.test2(colList VARCHAR)
 RETURNS SETOF record AS
$func$
BEGIN

RETURN QUERY EXECUTE 'SELECT ' || colList || ' FROM webview.webview_account ';

END $func$ LANGUAGE plpgsql;

-- this call works fine but I'd like to avoid explicitly providing the data types in the result set.

SELECT * 
FROM webview.test2('account_number, customer_name') 
AS f(account_number varchar, customer_name varchar);
Alex F
  • 1
  • 1

0 Answers0