Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 29A4B632315 for ; Thu, 8 Apr 2010 05:59:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 49062-01 for ; Thu, 8 Apr 2010 08:59:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 5D730632224 for ; Thu, 8 Apr 2010 05:59:44 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o388xfPg017357; Thu, 8 Apr 2010 04:59:41 -0400 (EDT) To: Thomas Kellerer cc: pgsql-sql@postgresql.org Subject: Re: Problem with function returning a result set In-reply-to: References: Comments: In-reply-to Thomas Kellerer message dated "Thu, 08 Apr 2010 10:54:36 +0200" Date: Thu, 08 Apr 2010 04:59:41 -0400 Message-ID: <17356.1270717181@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.465 tagged_above=-10 required=5 tests=AWL=0.134, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201004/28 X-Sequence-Number: 33955 Thomas Kellerer 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