Re: How to use RETURN TABLE in Postgres 8.4 - Mailing list pgsql-general

From Pavel Stehule
Subject Re: How to use RETURN TABLE in Postgres 8.4
Date
Msg-id 162867790907030849q6272901eufba275b2223856b2@mail.gmail.com
Whole thread Raw
In response to Re: How to use RETURN TABLE in Postgres 8.4  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: How to use RETURN TABLE in Postgres 8.4
List pgsql-general
2009/7/3 Tom Lane <tgl@sss.pgh.pa.us>:
> Michal Szymanski <dyrex@poczta.onet.pl> writes:
>> CREATE OR REPLACE FUNCTION buggy_procedure() RETURNS TABLE (id INT8,
>> test VARCHAR)
>>     AS $$
>> BEGIN
>>     -- @todo hide password
>>     RETURN QUERY
>>         SELECT id  ,test
>>         FROM bug_table
>>     ;
>> END;
>> $$
>>     LANGUAGE plpgsql STRICT SECURITY DEFINER;
>
> Don't use column names in your functions that are the same as variable
> or parameter names of the function.  This is working basically as if
> you'd written "SELECT null,null", because the output parameters are
> still null when the RETURN QUERY is executed.
>

use qualified names instead

  RETURN QUERY
    SELECT b.id, b.test
       FROM bug_table b;

regards
Pavel Stehule


>                        regards, tom lane
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to use RETURN TABLE in Postgres 8.4
Next
From: nha
Date:
Subject: Re: Group by on %like%