From: | Condor <condor(at)stz-bg(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: return query execute SQL-problem |
Date: | 2012-10-16 08:56:32 |
Message-ID: | d5a1ce961c209ee11c862345eaa7c3c2@stz-bg.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2012-10-16 10:44, Maximilian Tyrtania wrote:
> 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
You can use AS
select f_aliastest() AS alias;
Regards,
C
From | Date | Subject | |
---|---|---|---|
Next Message | Maximilian Tyrtania | 2012-10-16 09:25:49 | Re: return query execute SQL-problem |
Previous Message | Craig Ringer | 2012-10-16 08:07:37 | Re: Application takes longer time to fetch large no of records from Postgresql 9.0.3 |