1

I have a table in Oracle with several constraints. When I insert a new record, Oracle raises only the "first" error. How to get all violations of my record?

**********EDITED FOR LITERAL EXAMPLE****************

CREATE TABLE TEST(
  COL_1 NUMBER NOT NULL,
  COL_2 NUMBER NOT NULL
);

INSERT INTO TEST VALUES(NULL, NULL);

Response: ORA-01400: cannot insert NULL into ("USER_4_8483C"."TEST"."COL_1");

What I need:

Col_1 cannot be NULL
Col_2 cannot be NULL
...
Avhelsing
  • 81
  • 2
  • 7
  • Oracle throws an exception on the first constraint violation it finds. Also - given the data you've shown you won't get an exception on your second field as Oracle will simply translate the string to a number for you. Best of luck. – Bob Jarvis - Слава Україні Aug 15 '16 at 15:48
  • 1
    Did you mean single quotes in your INSERT statement? With double quotes Oracle will throw a different exception - it will not even go as far as checking the constraints. More exactly: with double quotes the query will not even compile. (Constraints are only checked at run time; your query as written won't even get to run time, it will fail to compile.) –  Aug 15 '16 at 16:22

0 Answers0