From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: Problem with function returning a result set
Date: Thu, 08 Apr 2010 11:29:26 +0200
Message-ID: <hpk7lm$gmq$1@dough.gmane.org> (raw)
In-Reply-To: <17356.1270717181@sss.pgh.pa.us>
References: <hpk5kd$98o$1@dough.gmane.org>
<17356.1270717181@sss.pgh.pa.us>
Tom Lane, 08.04.2010 10:59:
> 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
>
I knew it was something simple I overlooked ;)
Thanks for the quick response.
Regards
Thomas
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: spam_eater@gmx.net
Subject: Re: Problem with function returning a result set
In-Reply-To: <hpk7lm$gmq$1@dough.gmane.org>
* 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