Following is a Function created in PostgreSQL 9.2 ,
CREATE OR REPLACE FUNCTION getRows()
RETURNS TABLE (
"Name" character varying
,"Address" text
,"Phone" text
,"Email" character varying
,"Tin" character varying
,"DL.No1, DL.No2" text
,"Area" character varying
) AS
$func$
BEGIN
select acname as "Name", coalesce(nullif(concat_ws(', ', nullif(add1, ''),
nullif(add2, '')), ''), 'NIL') "Address", coalesce(nullif(concat_ws(', ',
nullif(phoneoff, ''), nullif(mobile, '')), ''), 'NIL') "Phone",case when email
<>'' then email else 'NIL' end as "Email",case when email <>'' then tin else
'NIL' end as "Tin",case when dlno1 ||', '||dlno2=', ' then 'NIL' else dlno1 ||',
'||dlno2 end as "DL.No1, DL.No2",areaname as "Area" from gtab12 left join
gtab47 using(areaid) where acgrcode = '204' order by areaname,"Name";
END
$func$ LANGUAGE plpgsql;
When select getRows() an error is occurring
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function getRows() line 4 at SQL statement
given below is actually what the select query inside the function getRow returns.
