Re: Problem with function returning a result set

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with function returning a result set
Date: 2010-04-08 08:59:41
Message-ID: 17356.1270717181@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar)
> RETURNS TABLE(id integer, full_name text)
> AS
> $$
> BEGIN

> RETURN QUERY
> SELECT id, first_name||' '||last_name
> FROM employee
> WHERE last_name LIKE name_pattern ||'%';
> END
> $$
> LANGUAGE plpgsql;

> I get one row returned which is correct, but the ID column is null
> (but should be 1).

Don't name the parameter the same as the table column ...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2010-04-08 09:01:20 Re: Problem with function returning a result set
Previous Message Thomas Kellerer 2010-04-08 08:54:36 Problem with function returning a result set