Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 7F6199F9F11 for ; Tue, 21 Aug 2007 20:17:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 77706-02 for ; Tue, 21 Aug 2007 20:17:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao03.charter.net (mtao03.charter.net [209.225.8.188]) by postgresql.org (Postfix) with ESMTP id 860DB9F9DB7 for ; Tue, 21 Aug 2007 20:17:24 -0300 (ADT) Received: from aa02.charter.net ([10.20.200.154]) by mtao03.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070821231722.LNEL10962.mtao03.charter.net@aa02.charter.net>; Tue, 21 Aug 2007 19:17:22 -0400 Received: from [10.0.1.2] (really [66.188.165.91]) by aa02.charter.net with ESMTP id <20070821231722.VXHS26124.aa02.charter.net@[10.0.1.2]>; Tue, 21 Aug 2007 19:17:22 -0400 In-Reply-To: <50700110-2B0D-4935-B033-084ED908BEC5@seespotcode.net> References: <830878.14424.qm@web31803.mail.mud.yahoo.com> <50700110-2B0D-4935-B033-084ED908BEC5@seespotcode.net> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Cc: Richard Broersma Jr , SQL Postgresql List Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: SELECT syntax synopsis: column_definition? Date: Tue, 21 Aug 2007 18:17:17 -0500 To: Michael Glaesemann X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/182 X-Sequence-Number: 29120 On Aug 21, 2007, at 18:04 , Michael Glaesemann wrote: > So the *form* is right, but I don't know of an example that works. CREATE TABLE foos ( foo text PRIMARY KEY , title text NOT NULL ); INSERT INTO foos (foo, title) values ('foo', 'the great') , ('bar', 'the extravagant') , ('baz', 'the indisputable'); CREATE OR REPLACE FUNCTION get_foo() RETURNS record LANGUAGE plpgsql AS $body$ DECLARE v_record record; BEGIN SELECT INTO v_record * FROM foos ORDER BY RANDOM() LIMIT 1; RETURN v_record; END; $body$; a | b -----+------------------ baz | the indisputable (1 row) test=# SELECT * test-# FROM get_foo() AS (a text, b text); a | b -----+----------------- bar | the extravagant (1 row) IIRC, this form is used by the crosstab functions in tablefunc. Michael Glaesemann grzm seespotcode net