Oracle用错误00917替换。00000-“缺少逗号”

时间:2019-04-30 06:43:22

标签: sql oracle merge

在Oracle中,当我在合并中使用SUBSTR()时,出现错误消息“缺少逗号”。我找不到,在哪里需要逗号,或者我使用了错误的子句?

WHEN NOT MATCHED THEN
        INSERT INTO A      
        (
        A.EMP_ID,
        A.HOLI_DATE,
        A.HOLI_HOURS,
        A.HOLI_REASON,
        A.START_TIME,
        A.END_TIME,
        A.AGENT_EMP_ID,
        A.VERSION,
        A.CREATETIME,
        --,TG.CREATOR
        --,TG.MODIFIER
        A.LASTUPDATE)
VALUES
 substr(B.EMP_ID,3,6)as EMP_ID,--this is the line with error"missing 
 comma"
        B.HOLI_DATE,
        B.HOLI_HOURS,
        B.HOLI_REASON,
        SUBSTR(B.HOLI_TIME,1,2)||':'||SUBSTR(B.HOLI_TIME,3,2) AS 
START_TIME,
        SUBSTR(B.HOLI_TIME,6,2)||':'||SUBSTR(B.HOLI_TIME,8,2) AS 
END_TIME,
        SUBSTR(B.AGENT_EMP_ID,3,6) AS AGENT_EMP_ID,
        1,
        sysdate,
        --,$$PLSQL_UNIT
        --,$$PLSQL_UNIT
        sysdate
FROM B

1 个答案:

答案 0 :(得分:0)

您必须在INTO A之后删除INSERT merge语句中的语法为:

merge into A
  using(select col1, col2, col3... from B)
  on (A.col1 = B.value1)
WHEN NOT MATCHED THEN
    INSERT (col1,col2...)
    VALUES (B.value1, B.value2...)
WHEN MATCHED THEN
    UPDATE SET col2= B.value2
...

别忘了在值列表周围加上括号