2016-12-06 85 views
0
if 0 <> (select count(*) from sung where hakbun = 1)then 
cnt := cnt+1; 
end if; 

我想上面的源代码和Oracle显示打击错误如何使用Subquery Select语句作为IF条件?

PLS-00405:子查询在此背景下

我在做什么错不允许?

+2

获得价值和比较 – GurV

+1

http://stackoverflow.com/questions/810919/scalar-subquery-in-if-statement-condition-in-pl-sql –

回答

1

如何在单个查询中完成整个任务?这是否工作?的选择在变

select cnt + (case when count(*) > 0 then 1 else 0 end) into cnt 
from sung 
where hakbun = 1;