【发布时间】:2018-11-11 18:58:41
【问题描述】:
我有一个 PL/SQL 过程,用于删除对应于具有 NULL 值的字段的记录。我可以通过以下查询来实现这一点。
set serveroutput on;
begin
dbms_output.put_line('Execution started');
for rec in (
select name from employee where emp_id is null
and location = 'SITE_A'
)
loop
delete from employeedetails@sitea where name = rec.name;
dbms_output.put_line('name '|| rec.name ||' deleted');
end loop;
dbms_output.put_line('Execution completed');
end;
/
set serveroutput off;
我正在从一个数据库运行 for 循环查询,并使用数据库链接删除另一个数据库 ( sitea ) 中的记录。
我需要添加一个条件,例如,如果name=rec.name 没有返回任何要删除的记录,那么dbms_output.put_line('No records to be deleted');
有没有一种舒适的方法来实现它?
【问题讨论】: