gpt4 book ai didi

sql - 下一个值函数错误

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

在 postgresql 执行过程中出现以下错误:错误 [HY000] 错误:您只能在目标列表中使用“下一个值”函数

这个sql语句有什么问题:

SELECT TRFCON.ID       
,
case when DDDCON.ID_CON = 0
then
NEXT VALUE FOR SEQ_DDD_CON
else
DWHCON.ID_CON
end ID_CON

FROM TTT_CONSUMPTION TTTCON

join DDDDWH_CON DWHCON on TTTCON.ID_ORG = DDDCON.ID_ORG
and TTTCON.ID_PRO = DDDCON.ID_PRO
and TTTCON.ID_REF = DDDCON.ID_REF

该序列的DDL如下:

CREATE SEQUENCE SEQ_DDD_CON AS BIGINT
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
NO CYCLE;

最佳答案

来自 CREATE SEQUENCE 的文档

Compatibility

CREATE SEQUENCE conforms to the SQL standard, with the following exceptions:

  • [...]
  • Obtaining the next value is done using the nextval() function instead of the standard's NEXT VALUE FOR expression.

关于sql - 下一个值函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17829458/

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