Oracle Update Query缺少SET关键字 - ORA97100& ORA-00904

时间:2014-11-20 00:38:16

标签: sql oracle

我在尝试运行这个简单的UPDATE语句时遇到了令人困惑的" ORA97100缺少SET关键字" 错误,尽管" set"关键字在那里:

UPDATE CURRENT_LOAD as ac
SET ac.LOAD_START_TIMESTAMP = CURRENT_TIMESTAMP
WHERE ac.LOAD_START_TIMESTAMP IS NULL;

我也试过了,它给了" 无效的标识符ORA-00904 AC.LOAD_START_TIMESTAMP"

UPDATE CURRENT_LOAD ac
SET ac.load_start_timestamp = CURRENT_TIMESTAMP
WHERE ac.load_start_timestamp IS NULL;

我进一步尝试了,它再次给出"无效的标识符ORA-00904 CURRENT_LOAD.LOAD_START_TIMESTAMP"

UPDATE CURRENT_LOAD 
SET CURRENT_LOAD.load_start_timestamp = CURRENT_TIMESTAMP
WHERE CURRENT_LOAD.load_start_timestamp IS NULL;

这很奇怪,因为属性" LOAD_START_TIMESTAMP"实际上是在我的表中定义的,参见" CURRENT_LOAD"表DDL如下:

 CREATE TABLE "CURRENT_LOAD"
   (
  "LOAD_START_TIMESTAMP" TIMESTAMP with TIME ZONE, 
    "CONTRACT_NO" VARCHAR2(100 BYTE), 
    "PROJECT_DEFINITION" VARCHAR2(100 BYTE), 
    "MASTER_CONTRACT_NO" VARCHAR2(100 BYTE), 
    "Sac_CONTRACT_NO" VARCHAR2(100 BYTE)
);

任何深思熟虑的建议都将受到赞赏。

由于

1 个答案:

答案 0 :(得分:2)

尝试运行UPDATE语句而不使用表别名ac,如

UPDATE CURRENT_LOAD
SET LOAD_START_TIMESTAMP = CURRENT_TIMESTAMP
WHERE LOAD_START_TIMESTAMP IS NULL;

此外,问题出在表别名之前的AS。您的UPDATE声明应该是

UPDATE CURRENT_LOAD ac
SET ac.LOAD_START_TIMESTAMP = CURRENT_TIMESTAMP
WHERE ac.LOAD_START_TIMESTAMP IS NULL;

有关详细信息,请参阅Oracle documentation