Oracle exception [ORA-22908: NULL Table value reference] Problem Analysis and Solution
Oracle exception [ORA-22908: NULL Table value reference] Problem Analysis and Solution
The scenario is as follows:
Type list_obj; test (name (regexp_like (name,), id, version_list list_obj) nested table version_list store as version_list;
Scenario Description: The list_obj type is a list of numbers with equivalent elements. Table test has three fields. The field name is a string consisting of only lowercase letters, numbers, and underscores. The field id is a number and cannot be empty; the version_list field is a nested table of the list_obj type.
Operation 1:
Test (name, id), 1 );
The query result is as follows:
Currently, version_list is empty (Note: It is null). Now we need to maintain this field: Insert a version 20130403112459 to the record. The statement is as follows:
() Values (20130403112459 );
If you execute the preceding insert statement, an error is returned!
Why? The version_list field is currently NULL. The preceding insert statement attempts to perform this action: table (NULL), that is, to visualize NULL into a table. This is against common sense. Oracle cannot do it!
How can this problem be solved? The version_list field is NULL because it is not initialized at all. So, can the problem be solved shortly after initialization of insert?
Method 1: Use the following statement to insert data to the test table:
Test (name, id, version_list), 1, list_obj ());
Method 2: Initialize version_list before inserting version numbers.
Test;
See:
This is the query output under pl/SQL developer. Note that the background color of the Data cell in the version_list column is not pale yellow (the field value is null at this time )! Although there is still no record for viewing the internal content of the version_list field, it is different in the sense that it is null before initialization and list_obj object after initialization.
Finished!