【发布时间】:2021-05-28 18:22:49
【问题描述】:
我为长度创建了这种类型:
CREATE TYPE length AS (value numeric, uom text );
然后我创建了一个长度数组的类型
CREATE TYPE test_type AS (comp_height length[]);
在此之后,我创建了一个包含 test_type 数组类型列的表
CREATE TABLE test_table (test_column test_type[]);
现在我无法插入此表。这种方式我试过了
insert into test_table (test_column)
values (
ARRAY[
ARRAY[(1,'m')::length,
(20,'m')::length],
ARRAY[(3,'m')::length,
(40,'m')::length]
]::test_type
);
但我得到一个演员错误:(
ERROR: cannot cast type length[] to test_type
感谢您的帮助,谢谢
【问题讨论】:
标签: postgresql user-defined-types composite-types