Oracle数据库查询表中记录为空,Empty result set fetched

Oracle数据库查询表中记录为空,Empty result set fetched,此时没有数据,获取不到任何值,可是此时咱们须要根据结果来作计算,所以能够使用count()函数来作结果统计,将统计结果用来作判断。sql

场景:须要查询出结果用于求和计算,没有结果时取0。
方案:使用case...when作sql的条件判断,当有结果为1时表示有记录,此时使用查询到的记录,当结果是其余时表示没有记录,此时count()统计数据为0,用统计结果作结果返回用于求和运算;数据库

sql以下:函数

select count(1) from ldsysvar where sysvar='onerow' and ((
select Mult*50 from lspol where contno='?ContNo?' and riskcode='00963000'
)+(
(
case (select count(STANDBYFLAG1*100) from lspol where contno='?ContNo?' and riskcode in ('00958100') )
when 1 then (select STANDBYFLAG1*100 from lspol where contno='?ContNo?' and riskcode in ('00958100'))
else (select count(STANDBYFLAG1*100) from lspol where contno='?ContNo?' and riskcode in ('00958100') )
end
)
))>500 and '?RiskCode?' in ('00963000','00554000');fetch