do
$$
    begin
    if exists(select * from res_partner where 1!=1) then
        raise notice ‘ererrrr‘;
    end if;
    end;
$$;
count 来获取返回的结果,然后判断count的值是否为零.postgres 判断查询结果集为空,判断查出出来的记录为零
原文:https://www.cnblogs.com/qianxunman/p/13962228.html