Oracle PL/SQL - Using NULL command in IF statement

Introduction

Oracle doesn't allow a branch without any statements inside, you could use a NULL statement.

Demo

SQL>
SQL> create or replace function f_isSunday_tx (in_dt DATE)
  2  return VARCHAR2-- w  ww  .  j a  v  a 2s.  c om
  3  is
  4        v_out_tx VARCHAR2(10);
  5  begin
  6        if to_char(in_dt,'d')=1 then
  7             v_out_tx:='Y';
  8        else
  9              null;
 10        end if;
 11        return v_out_tx;
 12  end;
 13  /

Function created.
SQL> begin
  2     DBMS_OUTPUT.put_line(f_isSunday_tx(SYSDATE));
  3  end;
  4  /

PL/SQL procedure successfully completed.
SQL>

Related Topic