IF EXISTS condition not working with PLSQL

前端 未结 2 1487
醉酒成梦
醉酒成梦 2020-11-27 18:47

I am trying to print the TEXT when condition is TRUE. The select code is perfectly working fine. It\'s showing 403 value when i only run select code. But I have to print som

2条回答
  •  臣服心动
    2020-11-27 18:50

    Unfortunately PL/SQL doesn't have IF EXISTS operator like SQL Server. But you can do something like this:

    begin
      for x in ( select count(*) cnt
                   from dual 
                  where exists (
                    select 1 from courseoffering co
                      join co_enrolment ce on ce.co_id = co.co_id
                     where ce.s_regno = 403 
                       and ce.coe_completionstatus = 'C' 
                       and co.c_id = 803 ) )
      loop
            if ( x.cnt = 1 ) 
            then
               dbms_output.put_line('exists');
            else 
               dbms_output.put_line('does not exist');
            end if;
      end loop;
    end;
    /
    

提交回复
热议问题