Oracle不支持IF not Exists,怎么写

如题所述

Oracle在select,update, delete这样的语句中是支持exists判断(或not exists),但是其他地方如if判断中并不支持exists。

我是这样做的: 要select into语句给变量赋值,在if条件中根据该变量值进行判断. 示例:

declare
v_flag varchar(10);
begin
  select case when exists (select tk_id from SIPRMA.SIPRMA_INV_TRANTK where tk_num = 'UWT140800266') then 'Y' else 'N' end as val 
  into v_flag
  from dual;
  
  if v_flag = 'Y' then
    DBMS_OUTPUT.PUT_LINE('Exists');
  else
    DBMS_OUTPUT.PUT_LINE('Not Exists');
  end if;
end;

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-28

明确告诉你,支持!

select * from your_table where not exists (select 1 from your_table)

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网