Check nullment for object instance : Object Instance « Object Oriented « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE TYPE address AS OBJECT
  2              (line1 VARCHAR2(20),
  3               line2 VARCHAR2(20),
  4               city VARCHAR2(20),
  5               state_code VARCHAR2(2),
  6               zip VARCHAR2(13));
  7  /

Type created.

SQL>
SQL> DECLARE
  2    addressValue address;
  3  BEGIN
  4    IF (addressValue IS NULL) THEN
  5
  6      DBMS_OUTPUT.PUT_LINE('addressValue is atomically null ');
  7
  8    END IF;
  9
 10    IF (addressValue.line1 IS NULL) THEN
 11
 12      DBMS_OUTPUT.PUT_LINE('line1 is null ');
 13
 14    END IF;
 15
 16    addressValue :=address('27 Rd','A','E','NJ','00000');
 17
 18    addressValue :=NULL;
 19
 20    IF (addressValue IS NULL) THEN
 21      DBMS_OUTPUT.PUT_LINE('addressValue is atomically null ');
 22    END IF;
 23
 24    addressValue.line1 :='1 Road';
 25
 26  EXCEPTION WHEN ACCESS_INTO_NULL THEN
 27
 28    DBMS_OUTPUT.PUT_LINE('Access Into Null');
 29  END;
 30  /
addressValue is atomically null
line1 is null
addressValue is atomically null
Access Into Null

PL/SQL procedure successfully completed.

SQL>








32.6.Object Instance
32.6.1.NULL objects and NULL attributes
32.6.2.Check nullment for object instance
32.6.3.Invoking a method
32.6.4.Call User-defined constructors