问题
I get the following error during postgresql execution: ERROR [HY000] ERROR: you can only use a 'next value(s)' function within a target list
What is wrong with this sql statement:
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
The DDL of the sequence is the following:
CREATE SEQUENCE SEQ_DDD_CON AS BIGINT
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
NO CYCLE;
回答1:
From the docs for 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.
来源:https://stackoverflow.com/questions/17829458/next-value-function-error