Oracle:UPDATE语句导致ORA-00933错误

时间:2012-08-28 07:55:16

标签: oracle

有人能看出这句话有什么不对吗?我已经尝试了一段时间来解决它,但无济于事,我在网上找到的答案坚持我需要删除ORDERBY语句,这是我不能使用的。

BEGIN
   UPDATE        Tags
     SET           MaskReasonId = v_MaskReasonId,
                    AppliedTime = v_AppliedTime,
                    ExpireTime = v_ExpireTime,
                    UserId = v_UserId,
                    ClientNode = v_ClientNode,
                    CommentId = v_CommentId
     FROM          Tags
     WHERE         Tag = v_sTag OR Tag = v_Tag;
END;

3 个答案:

答案 0 :(得分:3)

Oracle不支持UPDATE FROM语句,但支持UPDATE SELECT。试试这个。对于此查询,Nodes.NodeID必须是Nodes表中的主键。我猜v_MaskReasonId,...是来自NODES(?)的字段:

 update (select * from Tags
         INNER JOIN    Nodes ON Nodes.NodeId = Tags.NodeID
          WHERE         Node = v_Node AND (Tag = v_sTag OR Tag = v_Tag)
         ) t
       set t.MaskReasonId = t.v_MaskReasonId
           t.ExpireTime = t.v_ExpireTime,
           t.UserId = t.v_UserId,
           t.ClientNode = t.v_ClientNode,
           t.CommentId = t.v_CommentId

答案 1 :(得分:2)

您必须删除from tags

答案 2 :(得分:1)

Oracle不支持" FROM"在update语句中构造,试试这个:

BEGIN
   UPDATE        Tags
     SET           MaskReasonId = v_MaskReasonId,
                    AppliedTime = v_AppliedTime,
                    ExpireTime = v_ExpireTime,
                    UserId = v_UserId,
                    ClientNode = v_ClientNode,
                    CommentId = v_CommentId
     WHERE EXISTS (SELECT * FROM Tags WHERE Tag = v_sTag OR Tag = v_Tag);
END;