using not nullbesides assigning an initial value


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

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: using not nullbesides assigning an initial value
Reference No:- TGS0172478

Expected delivery within 24 Hours