日期:2014-05-17  浏览次数:20956 次

下面语句怎么写的啊??????
if select count(1) from test3 where id = 2 >0
  select 1 from dual 
else
  select 2 from dual


上面这句话报错,,请问用oracle怎么写的啊?

------解决方案--------------------
试试这样写
DECLARE
rnt int := 0;
BEGIN
SELECT COUNT(1) INTO rnt FROM t_test ;
  
IF (rnt >0) THEN
--select 1 from dual;
dbms_output.put_line('aaaaaaa');
ELSE
--select 2 from dual;
dbms_output.put_line('bbbbbb');
END IF;
END;