I have created following function in PostgreSQL database
CREATE or REPLACE FUNCTION getSR15ReportData(value text)
RETURNS TABLE(
userid integer,
username varchar(50)
) AS -- text AS --
$body$
DECLARE
fullsql TEXT;
records RECORD;
exeQuery TEXT;
BEGIN
fullsql:= 'SELECT userid, username from user_index where status='''value'''';
exeQuery := 'SELECT * FROM (' || fullsql || ') AS records';
RETURN QUERY EXECUTE exeQuery;
END
$body$
LANGUAGE plpgsql;
It's giving me output as follow:
getdate
--------------
501,alexanda
502,cathie
But I need output like:
userid username
------|---------
501,alexanda
502,cathie