您是否知道如何显示以下查询的结果或将其存储在表格中:
do
$$
declare
i record;
begin
for i in 1..3 loop
PERFORM ROW_NUMBER() OVER() AS id,
sub_query.*
FROM line AS b, LATERAL (
SELECT array_agg(DISTINCT a.id) AS old_id,
ST_Union(a.geom) AS fusion
FROM line AS a
WHERE a.id > b.id
AND ST_touches(a.geom, b.geom) = true
AND a.material = b.material
GROUP BY a.material
) AS sub_query
;
end loop;
end;
$$
;
答案 0 :(得分:0)
我没有看到你如何在上面的代码中使用记录,所以只运行三次:
SELECT ROW_NUMBER() OVER() AS id,
sub_query.*
FROM line AS b, LATERAL (
SELECT array_agg(DISTINCT a.id) AS old_id,
ST_Union(a.geom) AS fusion
FROM line AS a
WHERE a.id > b.id
AND ST_touches(a.geom, b.geom) = true
AND a.material = b.material
GROUP BY a.material
) AS sub_query
;
?..
如果您在理论上提出要求,请使用raise
输出值,或使用insert into
将它们放到表中......