如何不得到这个警告? DB2 警告 SQLSTATE=02000 没有找到 FETCH、UPDATE 或 DELETE 的行;或者查询结果为空 table

How to not get this warning? DB2 Warning SQLSTATE=02000 No row was found for FETCH, UPDATE, or DELETE; or the result of a query is an empty table

我们设置错误处理的方式会在出现此警告时向所有人发送电子邮件(我无法更改此设置)。我真的不在乎找不到该作业的行。

我该怎么做

A) 在删除行之前检查行是否存在或

B) Circumvent/ignore 这个警告不知何故?

删除示例:

 delete from schema.table 
   where key is null;

SQLSTATE=02000 No row 显示 FETCH、UPDATE 或 DELETE 错误;或者查询结果为空 table.

我也无法插入要删除的虚拟记录。

也许这样就可以了

with delete_rows as (
  select * from old table (delete from schema.table where key is null)
)
select count(*) from delete_rows

您可以尝试Compound SQL (compiled) statement“吃掉”这个警告。

BEGIN
  DECLARE CONTINUE HANDLER FOR NOT FOUND
  BEGIN END;
  DELETE ...;
END