The following example shows how you can use the OEXTEND method to fill the end of a constructed ARRAY with NULL elements so that these elements are no longer in an uninitialized state. This can be helpful when the ARRAY may be used as an argument to another system function or operator.
CREATE TYPE myarray AS VARRAY(5) OF INTEGER; CREATE TABLE mytab (id INTEGER, ary myarray); /* Populate the first 3 elements. The last 2 elements are uninitialized. */ INSERT INTO mytab VALUES (1, NEW myarray(1,2,3)); /* Fill the last 2 elements with NULLs. */ UPDATE mytab SET ary = ary.OEXTEND(2) WHERE id = 1; SELECT ary FROM mytab;
The following is the result of the query.
(1,2,3,NULL,NULL)