I'm trying to understand how to insert a composite type value. I'm
having trouble with the last sql statement below. It errors out with:
ERROR: cannot cast type record to atype
How should I create a composite type value out of columns a and b in
table tt that I can insert into table atable?
CREATE TYPE atype AS (
acol
TEXT,
bcol
TEXT
);
CREATE TABLE atable (
aval
atype
);
CREATE TEMP TABLE
tt
AS
SELECT 'aaa'::text AS a, 'bbb'::text AS b;
INSERT INTO
atable
SELECT
ROW(a, b)
FROM
tt;
Thanks as always.
--
Ron Peterson
https://www.yellowbank.com/