[英]FireDAC precedes query with DECLARE CURSOR
When I execute following query in PG Admin III, it runs fine: 当我在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
)
but when I try to execute it through TFDQuery, PostgreSQL complains: 但是当我尝试通过TFDQuery执行它时,PostgreSQL抱怨:
syntax error at or near "INSERT" at character 355
字符355处“ INSERT”处或附近的语法错误
I turned on PostgreSQL logging to Windows error log and saw following: 我打开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
)
When I execute the same, with DECLARE "10STM" CURSOR WITH HOLD FOR
in PG Admin III, I get exact the same error. 当我执行相同的操作时,使用PG Admin III中的
DECLARE "10STM" CURSOR WITH HOLD FOR
,我会得到完全相同的错误。
Why FireDAC precedes PG query with a cursor and how to avoid this? 为什么FireDAC在PG查询之前使用光标,以及如何避免这种情况?
Victoria doesn't want to get her points, so here is the answer: 维多利亚不想得到她的观点,所以这里是答案:
Cursor kind in fetch options was set to ckAutomatic
. 提取选项中的游标种类设置为
ckAutomatic
。 I changed it to ckDefault
and it works now. 我将其更改为
ckDefault
,现在可以使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.