X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 78165475ADE for ; Mon, 24 Feb 2003 10:19:14 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 84732-05 for ; Mon, 24 Feb 2003 10:19:03 -0500 (EST) Received: from web20805.mail.yahoo.com (web20805.mail.yahoo.com [216.136.226.194]) by postgresql.org (Postfix) with SMTP id 4038E4759BD for ; Mon, 24 Feb 2003 10:17:37 -0500 (EST) Message-ID: <20030224151740.15417.qmail@web20805.mail.yahoo.com> Received: from [208.13.35.65] by web20805.mail.yahoo.com via HTTP; Mon, 24 Feb 2003 07:17:40 PST Date: Mon, 24 Feb 2003 07:17:40 -0800 (PST) From: Jeff Eckermann Subject: Re: syntax question To: Josh Berkus , James Cooper Cc: pgsql-sql@postgresql.org In-Reply-To: <200302231507.23831.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/530 X-Sequence-Number: 11928 --- Josh Berkus wrote: > you cannot select the results of > a query directly into a > RECORD variable without a loop. > Pardon?? kper=# create function test(integer) returns varchar as 'declare stuff record; begin select * into stuff from employee where empid =$1; return stuff.empnum; end;' language 'plpgsql'; CREATE kper=# select test(66664); test ------ 3094 (1 row) kper=# select empid, empnum from employee where empid = 66664; empid | empnum -------+-------- 66664 | 3094 (1 row) This functinality has been in pl/pgsql from early days AFAIK. Be aware that this only works reliably if you have some way to be sure of what will be selected ("empid" is a unique column in this example), because the second and later rows to be returned from the query will be silently discarded. __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/