【发布时间】:2020-01-02 22:10:17
【问题描述】:
是否可以捕获触发复制异常的主键或记录rowID?
table1 有 PK: col1 和 Unique1: col2
例如
begin
insert into table1(col1, col2, col3)
values (1, 2, 3);
exception
when dup_val_on_index then
--- here, can you somehow indicate either PK or ROWID of the record that generated the exception of uniqueness?
e.g.
update table1 set
col3 = 100
where rowid = "GETROWID" or col1 = "GETPK";
end;
【问题讨论】:
-
我不这么认为。
-
您的表上有多少个索引?哪一列?
-
没关系,就是检测哪条记录已经存在了……我想没有这样的机制,但这就是我想问的……但事实是,如果有很多唯一索引,可能有很多处于危险之中,那么它不会是一个 ROWID 而是很多......
-
这很重要。我问的原因是您可以查询您的表以查找导致异常的匹配记录,然后从那里处理它。我认为这将是你唯一的选择。
-
那个我可以问数据库很清楚,但我认为有办法“自动”获取
标签: oracle primary-key unique-key