I would like to get effect of selecting table record when construct a
composite type.
CREATE TYPE "chains"."foo" AS (id INTEGER,bar INTEGER
);
CREATE OR REPLACE FUNCTION construct_foo(INTEGER,INTEGER) RETURNS
chains.foo AS $$
DECLAREf chains.foo;
BEGINf.id := $1;f.bar := $2;RETURN f;
END;
$$ LANGUAGE 'plpgsql';
SELECT * FROM construct_foo(10,20);
id bar
10 20
However I do not like idea to write a function similar to
"construct_foo" for each composite type I have.
I tried to solve this problem through selection of composite type
literal input, and I got following:
SELECT '(10,20)'::chains.foo;
foo
(10,20)
The only query I got desirable result is:
SELECT (t.foo).* FROM(SELECT '(10,20)'::chains.foo) t;
id bar
10 20
Is there a way to obtain the same result without use of the nested query?
--
Best regards. Yuri.
mailto: yuragal@gmail.com