我已经使用create table和这些列创建了一个表:
create table myschema.mytable(
id serial PRIMARY KEY,
row_num integer,
col_num integer,
pix_centroid geometry,
pix_val double precision
)
当我试图填充它时:
insert into pixelbased (id, row_num, col_num, pix_centroid, pix_val)
values (
DEFAULT,
(select((ST_PixelAsPolygons(rast, 1)).x) from mytable where rid=3),
(select((ST_PixelAsPolygons(rast, 1)).x) from mytable where rid=3),
(select(ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) from rwanda8 where rid=3),
(select(ST_PixelAsPolygons(rast, 1)).val from mytable where rid=3)
)
我遇到以下错误:
错误:用作表达式的子查询返回多行。
我知道,由于我的每一列都有不止一行,所以出现这样的错误是有道理的。但我真的需要按照上述计算所有列。有谁知道我该怎么办?事实上,我想在表中插入以下查询的结果:
select
(ST_PixelAsPolygons(rast, 1)).val as geomval1,
(ST_PixelAsPolygons(rast, 1)).x as X,
(ST_PixelAsPolygons(rast, 1)).y as Y,
(ST_Centroid((ST_PixelAsPolygons(rast, 1)).geom)) as geom
from rwanda8
where rid=3
有谁知道我该怎么办?