return query execute SQL-problem - Mailing list pgsql-general

From Maximilian Tyrtania
Subject return query execute SQL-problem
Date
Msg-id 178CAFBA-5FC9-42AD-B626-51304BB4720E@contactking.de
Whole thread Raw
Responses Re: return query execute SQL-problem  (Condor <condor@stz-bg.com>)
Re: return query execute SQL-problem  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: return query execute SQL-problem  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
Hi there,

here is something I don't quite grasp (PG 9.1.3): This function:

CREATE OR REPLACE FUNCTION f_aliastest()
  RETURNS setof text AS
$BODY$
declare sql text;
begin
  sql:='SELECT ''sometext''::text as alias';
  return query execute SQL;
end;
$BODY$
LANGUAGE plpgsql VOLATILE;

returns its result as:

contactking=# select * from f_aliastest();

 f_aliastest
-------------
 sometext
(1 row)

I was hoping I'd get the data back as 'alias', not as 'f_aliastest'. If I do:

contactking=# select alias from f_aliastest();
ERROR:  column "alias" does not exist
LINE 1: select alias from f_aliastest();

Is there a way that I can make my function return the field aliases?

Best wishes from Berlin,

Maximilian Tyrtania
http://www.contactking.de



pgsql-general by date:

Previous
From: Chris Travers
Date:
Subject: Re: Application takes longer time to fetch large no of records from Postgresql 9.0.3
Next
From: Craig Ringer
Date:
Subject: Re: Application takes longer time to fetch large no of records from Postgresql 9.0.3