ORA-01422:精确提取返回超过请求的行数ORA-06512:在“SYSTEM.AA”

时间:2017-02-10 19:23:37

标签: oracle plsql

我是PL / SQL的新手 我试图将删除的记录保存到临时表中。为此我做了一个触发器如下:

create or replace trigger aa
before delete on master_table
declare
v_id number(2);
begin
select id into v_id from master_table;
insert into temp_table values(v_id);
end;
/

但是当我尝试从master_table中删除记录时,会抛出这些异常:

ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "SYSTEM.AA", line 4
ORA-04088: error during execution of trigger 'SYSTEM.AA'

提前谢谢。

1 个答案:

答案 0 :(得分:2)

您可以为每一行创建执行触发器,只需使用:old.id将值插入临时表。

create or replace trigger aa
before delete on master_table
for each row
begin
    insert into temp_table values(:old.id);
end;
/