我正在尝试测试从表中删除数据的存储过程,并设置类似于此的设置:
Oracle安装程序:
CREATE TABLE table_name ( id NUMBER );
PL / SQL脚本:
DECLARE
v_scn V$DATABASE.CURRENT_SCN%TYPE;
v_row TABLE_NAME%ROWTYPE;
BEGIN
INSERT INTO table_name VALUES ( 1 );
INSERT INTO table_name VALUES ( 2 );
INSERT INTO table_name VALUES ( 3 );
SELECT current_scn INTO v_scn FROM V$DATABASE;
-- call a procedure with side-effects such as:
DELETE FROM table_name WHERE id = 1;
SELECT *
INTO v_row
FROM (
SELECT * FROM table_name AS OF SCN( v_scn )
MINUS
SELECT * FROM table_name
);
DBMS_OUTPUT.PUT_LINE( 'One row deleted: ' || v_row.id );
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE( 'Not found' );
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE( 'Too many rows' );
END;
ROLLBACK;
我希望v_row
将填充一行,并且不会调用任何异常处理程序。但是,正在调用NO_DATA_FOUND
异常。