NULL as a statement inside IF : NULL Statement « PL SQL « Oracle PL / SQL






NULL as a statement inside IF

 

SQL>
SQL> CREATE TABLE MyTable (
  2    num_col    NUMBER,
  3    char_col   VARCHAR2(60)
  4    );

Table created.

SQL>
SQL>
SQL> DECLARE
  2    v_TempVar  NUMBER := 7;
  3  BEGIN
  4    IF v_TempVar < 5 THEN
  5      INSERT INTO MyTable (char_col)
  6        VALUES ('Too small');
  7    ELSIF v_TempVar < 20 THEN
  8      NULL; -- Do nothing
  9    ELSE
 10      INSERT INTO MyTable (char_col)
 11        VALUES ('Too big');
 12    END IF;
 13  END;
 14  /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from MyTable;

no rows selected

SQL>
SQL>
SQL> drop table MyTable;

Table dropped.

SQL>
SQL>
SQL>

 








Related examples in the same category

1.Empty procedure with 'NULL' statement
2.Null statement means nothing