I'm using an Oracle 19 DB that is structured into multiple layers by using DB users. Here is a simplified overview of the structure:
- User DATA: Has the table
XTEST
and the viewTEST
. The view is created with aCREATE VIEW TEST AS SELECT * FROM XTEST
statement, so it contains all columns of the table. - User APP: Uses the view
DATA.TEST
for all SQL and DML.
The APP user does not have any grants on the tableDATA.XTEST
, but does have SELECT,INSERT,UPDATE,DELETE grants on the viewDATA.TEST
.
Now to my problem:
If a NOT NULL constraint on the table DATA.XTEST
is violated, the error message doesn't show the column name. The error message is literally:
ORA-01400: cannot insert NULL into (???)
The DB used Oracle 11 some time ago and back then we had the same problem, but could fix it by granting the REFERENCES
privilege on the table DATA.XTEST
to the APP user (see related question: Grant privilege to see column names in null constraint violations when inserting in views). But this doesn't work any more in Oracle 19.
Does anyone know how to get the column name in the error message?
Best Answer
Other than the obvious solution (
grant select on data.xtest to app;
), you can revert to the old behavior by setting SQL92_SECURITY toFALSE
. In 11.2, its default value wasFALSE
, but in 19c, its default value isTRUE
.Then restart the database, as this parameter can not be changed online.
Demo:
By changing the parameter: