Oracle SQL Lucee 中的 INSERT 错误 ORA-00933
Oracle SQL Error ORA-00933 on INSERT in Lucee
错误 ORA-00933:SQL 命令未正确结束
正在尝试使用以下 cfscript 语句插入一行:
q.setSQL("
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT #r.SCOINDEX[i]#, sc.DESCRIP, #(data.isDefault == 'Y' ? "'Y'" : "NULL")#, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = #y.id[1]#
");
结果
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628, sc.DESCRIP, 'Y', sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222
也因错误 ORA-00933 而失败的其他变体:
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
AND NOT ID in (
SELECT SALES_CHOICE_ID
FROM SALES_OPTION_CHOICE l
WHERE SALES_CONFIG_OPTION_ID = 25628
)
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, DESCRIP, 'Y' ISDEFAULT, CODE, ID, PRICE
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, sc.DESCRIP, 'Y' ISDEFAULT, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, sc.DESCRIP, 'Y' ISDEFAULT, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222;
我确定问题是我的一些小疏忽。我已经为此奋斗了几个小时。如果有任何见解,我将不胜感激。
已解决!显然 INSERT 语句需要包含在 BEGIN - END 中;
q.setSQL("
BEGIN
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT #r.SCOINDEX[i]#, sc.DESCRIP, #(data.isDefault == 'Y' ? "'Y'" : "NULL")#, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = #y.id[1]#;
END;
");
错误 ORA-00933:SQL 命令未正确结束
正在尝试使用以下 cfscript 语句插入一行:
q.setSQL("
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT #r.SCOINDEX[i]#, sc.DESCRIP, #(data.isDefault == 'Y' ? "'Y'" : "NULL")#, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = #y.id[1]#
");
结果
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628, sc.DESCRIP, 'Y', sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222
也因错误 ORA-00933 而失败的其他变体:
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
AND NOT ID in (
SELECT SALES_CHOICE_ID
FROM SALES_OPTION_CHOICE l
WHERE SALES_CONFIG_OPTION_ID = 25628
)
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE, SEQ)
SELECT 25628, DESCRIP, 'Y', CODE, ID, PRICE, NULL
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, DESCRIP, 'Y' ISDEFAULT, CODE, ID, PRICE
FROM SALES_CHOICE
WHERE ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, sc.DESCRIP, 'Y' ISDEFAULT, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT 25628 SCOINDEX, sc.DESCRIP, 'Y' ISDEFAULT, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = 222;
我确定问题是我的一些小疏忽。我已经为此奋斗了几个小时。如果有任何见解,我将不胜感激。
已解决!显然 INSERT 语句需要包含在 BEGIN - END 中;
q.setSQL("
BEGIN
INSERT INTO SALES_OPTION_CHOICE (SALES_CONFIG_OPTION_ID, DESCRIP, ISDEFAULT, CODE, SALES_CHOICE_ID, PRICE)
SELECT #r.SCOINDEX[i]#, sc.DESCRIP, #(data.isDefault == 'Y' ? "'Y'" : "NULL")#, sc.CODE, sc.ID, sc.PRICE
FROM SALES_CHOICE sc
WHERE sc.ID = #y.id[1]#;
END;
");