鉴于此示例(DUP_VAL_ON_INDEX 异常),是否可以捕获违反约束的值以便记录它们?
如果批量插入产生多个违规,该方法是否相同?
BEGIN
-- want to capture '01' and '02'
INSERT INTO Employee(ID)
SELECT ID
FROM (
SELECT '01' ID FROM DUAL
UNION
SELECT '02' ID FROM DUAL
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
-- log values here
DBMS_OUTPUT.PUT_LINE('Duplicate value on an index');
END;