Re: SELECT syntax synopsis: column_definition?
| От | Michael Glaesemann |
|---|---|
| Тема | Re: SELECT syntax synopsis: column_definition? |
| Дата | |
| Msg-id | CE1E5560-D185-48F2-BE12-97D837882D56@seespotcode.net обсуждение исходный текст |
| Ответ на | Re: SELECT syntax synopsis: column_definition? (Michael Glaesemann <grzm@seespotcode.net>) |
| Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: