0

这与其说是一个问题,不如说是一个谨慎,因为如果遇到这种情况,它将为人们省去很多麻烦。

当我将命令的 BindByName 属性设置为 true 时,我在合并语句中遇到了神秘的 ORA-01036 错误。如果我将 BindByName 设置为 false,情况会变得更糟,实际上会给出不正确的结果,而不会给出错误消息。

经过一番研究,事实证明,您不能在查询中重复键参数,而是需要将 using 语句中的键变量用于 inserts 中的键变量。这是一个简单的说明。

merge into rsvp r using (select :id as id from dual) d on (r.id=d.id)
 when matched then update set rsvp_date=sysdate
 when not matched then insert (id,rsvp_date) values (:id, sysdate)

这会给你错误。解决方法是将最后一行的插入语句更改为:

   when not matched then insert (id,rsvp_date) values (d.id, sysdate)
4

1 回答 1

0

经过一番研究,事实证明,您不能在查询中重复键参数,而是需要将 using 语句中的键变量用于 inserts 中的键变量。这是一个简单的说明。

merge into rsvp r using (select :id as id from dual) d on (r.id=d.id)
 when matched then update set rsvp_date=sysdate
 when not matched then insert (id,rsvp_date) values (:id, sysdate)

这会给你错误。解决方法是将最后一行的插入语句更改为:

   when not matched then insert (id,rsvp_date) values (d.id, sysdate)
于 2016-05-05T12:56:49.703 回答