From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with function returning a result set
Date: Thu, 08 Apr 2010 04:59:41 -0400
Message-ID: <17356.1270717181@sss.pgh.pa.us> (raw)
In-Reply-To: <hpk5kd$98o$1@dough.gmane.org>
References: <hpk5kd$98o$1@dough.gmane.org>
Thomas Kellerer <spam_eater@gmx.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, spam_eater@gmx.net
Subject: Re: Problem with function returning a result set
In-Reply-To: <17356.1270717181@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox