excluded.column 中的 PostgreSQL 更新数据错误
PostgreSQL update data error in excluded.column
我尝试使用 PostgreSQL 9.6 从另一个 table 更新数据,遵循文档和 Whosebug 的建议以及此查询
1.这个查询是为了找到接近lokasi_esb.geom
的geom的id_vertex。这个你可以忽略,它正常工作
CREATE TEMP TABLE temp1 AS
WITH kuery2 as(
SELECT id_esb, id_vertex, distant, rank() OVER (PARTITION BY id_esb ORDER BY distant asc) as ranked FROM table vertex)
select id_esb, id_vertex, distant, ranked
from kuery2
where ranked=1;
2. 此查询使用 id_vertex_最近的列 更新 lokasi_esb table 而没有 excluded
table。 ////我已经知道这是错误的,我更新了数字 3
INSERT INTO lokasi_esb(id_esb, id_vertex_nearest)
select id_esb,id_vertex
from temp1
ON CONFLICT (id_esb) DO UPDATE
SET lokasi_esb.id_vertex_nearest = temp1.id_vertex;
我遇到了这个错误
错误:缺少 table « temp1 »
的 FROM 子句条目
SQL状态:42P01
字符:634
3。 此查询更新 lokasi_esb table 与 id_vertex_最近的列 与 excluded
table
INSERT INTO lokasi_esb(id_esb, id_vertex_nearest)
select id_esb,id_vertex
from temp1
ON CONFLICT (id_esb) DO UPDATE
SET lokasi_esb.id_vertex_nearest = excluded.id_vertex;
我发现了这个错误(翻译自印度尼西亚)
错误:列 excluded.id_vertex 尚不存在
SQL 状态:42703
字符:634
那么谁能帮我弄清楚这里发生了什么?
“排除”记录中的列名指的是目标 table 的列。并且 SET 表达式中的目标列不能以 table 名称作为前缀(因为无论如何您都无法更新不同的 table)
所以你需要使用:
SET id_vertex_nearest = excluded.id_vertex_nearest
我尝试使用 PostgreSQL 9.6 从另一个 table 更新数据,遵循文档和 Whosebug 的建议以及此查询
1.这个查询是为了找到接近lokasi_esb.geom
的geom的id_vertex。这个你可以忽略,它正常工作
CREATE TEMP TABLE temp1 AS
WITH kuery2 as(
SELECT id_esb, id_vertex, distant, rank() OVER (PARTITION BY id_esb ORDER BY distant asc) as ranked FROM table vertex)
select id_esb, id_vertex, distant, ranked
from kuery2
where ranked=1;
2. 此查询使用 id_vertex_最近的列 更新 lokasi_esb table 而没有 excluded
table。 ////我已经知道这是错误的,我更新了数字 3
INSERT INTO lokasi_esb(id_esb, id_vertex_nearest)
select id_esb,id_vertex
from temp1
ON CONFLICT (id_esb) DO UPDATE
SET lokasi_esb.id_vertex_nearest = temp1.id_vertex;
我遇到了这个错误
错误:缺少 table « temp1 »
的 FROM 子句条目
SQL状态:42P01
字符:634
3。 此查询更新 lokasi_esb table 与 id_vertex_最近的列 与 excluded
table
INSERT INTO lokasi_esb(id_esb, id_vertex_nearest)
select id_esb,id_vertex
from temp1
ON CONFLICT (id_esb) DO UPDATE
SET lokasi_esb.id_vertex_nearest = excluded.id_vertex;
我发现了这个错误(翻译自印度尼西亚)
错误:列 excluded.id_vertex 尚不存在
SQL 状态:42703
字符:634
那么谁能帮我弄清楚这里发生了什么?
“排除”记录中的列名指的是目标 table 的列。并且 SET 表达式中的目标列不能以 table 名称作为前缀(因为无论如何您都无法更新不同的 table)
所以你需要使用:
SET id_vertex_nearest = excluded.id_vertex_nearest