构建PL/SQL IF THEN语句的更好方法是什么?

Pre*_*ets 3 database oracle syntax plsql

只是想知道是否有更好的方法在ORACLE中编写以下PL/SQL代码片段?

IF(p_c_courtesies_cd is not null 
OR  p_c_language_cd is not null
OR v_c_name is not null
OR v_c_firstname is not null
OR v_c_function is not null
OR p_c_phone is not null
OR p_c_mobile is not null
OR p_c_fax is not null
OR v_c_email is not null
) THEN
     -- Do something
END IF;
Run Code Online (Sandbox Code Playgroud)

Otá*_*cio 9

If coalesce( expr1, expr2, ... expr_n ) is not null then do something end if;
Run Code Online (Sandbox Code Playgroud)

看这里.

(感谢Tony的纠正)

  • 在原文中你必须读取每一行,包括"OR"和"IS NOT NULL" - 如果其中一行错误地说"IS NULL",它可能会错过(尽管格式化会有帮助) - 但COALESCE功能更清晰,完美地表达了意图. (2认同)