So, today I've been playing with visible and invisible columns in Oracle database tables and noticed one interesting fact related to USER_ERRORS view data population.
The data is populated AFTER the first explicit or implicit compilation of the invalid object.
The example
I created a table named TICA_TEST
CREATE TABLE tica_test (
id number primary key not null,
c1 varchar2(100),
c2 varchar2(100),
c3 varchar2(100),
c4 varchar2(100),
c5 varchar2(100)
);
Also created a procedure P_TICA_TEST, which is reading data from the tica_test table:
CREATE OR REPLACE PROCEDURE p_tica_test ISl_id number;l_c1 varchar2(100);l_c2 varchar2(100);l_c3 varchar2(100);l_c4 varchar2(100);l_c5 varchar2(100);BEGINSELECT *INTO l_id, l_c1, l_c2, l_c3, l_c4, l_c5FROM tica_testWHERE rownum = 1;END;
If I drop the column named C5 or make it invisible I expect that the procedure gets invalidated and that errors are stated in the view USER_ERRORS...
But expectations are reality are not always aligned 😁
The column is dropped:
ALTER TABLE tica_test MODIFY (c5 invisible);
The status of the procedure is INVALID, as expected :
SELECT status
FROM user_objects
WHERE object_name = 'P_TICA_TEST';
But the USER_ERRORS view does not return any data?!
SELECT *
FROM user_errors
WHERE name = 'P_TICA_TEST';
And only when I compile the procedure (explicit compile) or execute the procedure (implicit compile) errors are shown and the view is populated:
ALTER PROCEDURE p_tica_test COMPILE;
or
BEGIN
p_tica_test;
END;
Data from the view:
The conclusion
Do not be surprised if the object is invalid and there are no errors stated.
Maybe indeed there are no errors... and the object is just marked as invalid... but the errors are going to be revealed only after the object compilation.