如何使用Oracle中的日期更新列?

时间:2016-03-14 10:44:25

标签: sql oracle

我需要使用当前日期更新特定列。这是我的问题:

update  a
set a.x_date =(select CAST(sysdate AS DATE)as f from dual)
from RIM I 
JOIN INV P ON P.ID = I.PK_ID
JOIN ODF a ON a.ID = I.ID  
JOIN SRM R ON R.USER_ID = I.ASSIGNED_TO 
WHERE I.TYPE_CODE = 'ISSUE'  
AND I.ID = 2222;

我收到此错误消息:“SQL命令未正确结束”

2 个答案:

答案 0 :(得分:3)

Oracle在JOIN中不允许UPDATE。您可以使用WHERE中的条件:

update odf
    set x_date = sysdate
    where exists (select 1
                  from RIM I join
                       INV P
                       on P.ID = I.PK_ID join
                       SRM R
                       on R.USER_ID = I.ASSIGNED_TO 
                  where I.TYPE_CODE = 'ISSUE' AND I.ID = 2222 and
                        I.ID = odf.ID
                 );

没有理由将sysdate视为约会。

答案 1 :(得分:0)

update  a
set a.x_date =SYSDATE
from RIM I 
JOIN INV P ON P.ID = I.PK_ID
JOIN ODF a ON a.ID = I.ID  
JOIN SRM R ON R.USER_ID = I.ASSIGNED_TO 
WHERE I.TYPE_CODE = 'ISSUE'  
AND I.ID = 2222;