gpt4 book ai didi

postgresql - FireDAC 在查询之前使用 DECLARE CURSOR

转载 作者:行者123 更新时间:2023-11-29 13:47:18 25 4
gpt4 key购买 nike

当我在 PG Admin III 中执行以下查询时,它运行良好:

WITH new_values (updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5) AS (
VALUES (current_timestamp,'2','3','4','5','6','7','8','9')
),
UPSERT AS (
UPDATE utel u
SET
updated_at=nv.updated_at,
v0=nv.v0,v1=nv.v1,v2=nv.v2,v3=nv.v3,v4=nv.v4,v5=nv.v5
FROM
new_values nv
WHERE
u.talker_id=nv.talker_id AND u.sentence_id=nv.sentence_id RETURNING u.*
)
INSERT into utel (updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5)
SELECT updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5
FROM new_values WHERE NOT EXISTS(
SELECT 1 FROM upsert up
WHERE
up.talker_id=new_values.talker_id
AND up.sentence_id=new_values.sentence_id
)

但是当我尝试通过 TFDQuery 执行它时,PostgreSQL 提示:

syntax error at or near "INSERT" at character 355

我打开 PostgreSQL 记录到 Windows 错误日志并看到以下内容:

DECLARE "10STM" CURSOR WITH HOLD FOR
WITH new_values (updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5) AS (
VALUES (current_timestamp,'2','3','4','5','6','7','8','9')
),
UPSERT AS (
UPDATE utel u
SET
updated_at=nv.updated_at,
v0=nv.v0,v1=nv.v1,v2=nv.v2,v3=nv.v3,v4=nv.v4,v5=nv.v5
FROM
new_values nv
WHERE
u.talker_id=nv.talker_id AND u.sentence_id=nv.sentence_id RETURNING u.*
)
INSERT into utel (updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5)
SELECT updated_at,talker_id,sentence_id,v0,v1,v2,v3,v4,v5
FROM new_values WHERE NOT EXISTS(
SELECT 1 FROM upsert up
WHERE
up.talker_id=new_values.talker_id
AND up.sentence_id=new_values.sentence_id
)

当我在 PG Admin III 中使用 DECLARE "10STM"CURSOR WITH HOLD FOR 执行相同的操作时,我得到了完全相同的错误。

为什么 FireDAC 在 PG 查询之前使用游标以及如何避免这种情况?

最佳答案

Victoria 不想得到她的分数,所以这里是答案:

获取选项中的游标类型设置为 ckAutomatic。我将其更改为 ckDefault,现在可以使用了。

关于postgresql - FireDAC 在查询之前使用 DECLARE CURSOR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46241955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com