[Oracle]if中不能有子查詢

来源:互联网 发布:淘宝宝贝宣言词怎么写 编辑:程序博客网 时间:2024/06/07 03:50

if后不能有子查詢,只能為邏輯運算式。

若想在if后加入:值是否在某範圍內

   eg:

               if    v_a  in(select ...from...)

               then

               ...

               end if;


解決方案:

可以將限制條件放在where中,查詢該數量

  eg:

            select  count(1)  into  變數 from  ...

            where 列=v_a;

            if    變數>0

            then

            ...

           end if;

原创粉丝点击