Re: How to use RETURN TABLE in Postgres 8.4

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michal Szymanski <dyrex(at)poczta(dot)onet(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to use RETURN TABLE in Postgres 8.4
Date: 2009-07-03 15:46:38
Message-ID: 1704.1246635998@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michal Szymanski <dyrex(at)poczta(dot)onet(dot)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.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2009-07-03 15:49:42 Re: How to use RETURN TABLE in Postgres 8.4
Previous Message John Cheng 2009-07-03 14:37:19 Re: Problem search on text arrays, using the overlaps (&&) operator