Using NOT NULL
Besides assigning an initial value, the declarations can impose the NOT NULL constraint, as the example below shows:
acct_id INTEGER(4) NOT NULL := 9999;
You cannot assign nulls to the variable define as NOT NULL. If you attempt the PL/SQL raises predefined exception VALUE_ERROR. The NOT NULL constraint should be followed by the initialization clause. For e.g. the declaration below is illegal:
acct_id INTEGER(5) NOT NULL; -- illegal; not initialized
Remember that the subtypes NATURALN and POSITIVEN are predefined as NOT NULL. For illustration, the declarations below are equivalent:
emp_count NATURAL NOT NULL := 0;
emp_count NATURALN := 0;
In the NATURALN and POSITIVEN declarations, the type specifier should be followed by an initialization clause. Or else, you get a compilation error. For e.g. the declaration below is illegal:
line_items POSITIVEN; -- illegal; not initialized