Search Postgresql Archives

composite type insert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux