利用returning bulk collect into获取delete,insert,update等操作的返回集,再通过返回集做其它的操作,可以有效节省系统资源。
示例如下:
declare
TYPE NumList is TABLE OF char(24);
tmptable NumList;
begin
delete tbl where id< 200 returning (drug_id:这个是要显示表中字段) BULK
COLLECT INTO tmptable;
DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' rows:');
FOR i IN 1 .. tmptable.count LOOP
DBMS_OUTPUT.PUT_LINE('id:' || tmptable(i));
END LOOP;
end;
示例如下:
declare
TYPE NumList is TABLE OF char(24);
tmptable NumList;
begin
delete tbl where id< 200 returning (drug_id:这个是要显示表中字段) BULK
COLLECT INTO tmptable;
DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' rows:');
FOR i IN 1 .. tmptable.count LOOP
DBMS_OUTPUT.PUT_LINE('id:' || tmptable(i));
END LOOP;
end;