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
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly