Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

custom violation messages on constrains and indexes

TPD-OpitzAug 21 2018 — edited Aug 21 2018

Situation

When data in a table changes in a way a constraint or index is violated we get an error message telling the name of the violated object. Eg.:

create table my_test (

   an_attribute number(100) constraint upper_bound_ck check (an_attribute <= 42)

);

insert into my_test values (43);

ORA-02290: CHECK-Constraint (upper_bound_ck) violated

Request

I'd like to be able to define a custom violation message which is added to the message we already get so that the error is more descriptive:

create table my_test (

   an_attribute number(100) constraint upper_bound_ck check (an_attribute <= 42) message '42 is already the answer'

);

insert into my_test values (43);

ORA-02290: CHECK-Constraint (upper_bound_ck) violated:  42 is already the answer

Enhancement1

The violation message feature should also provide some pattern replacement to include the actual values the user provided in this custom validation fail message.

eg:

constraint upper_bound_ck check (an_attribute <= 42) message '${1} is bigger than 42 which is already the answer'

where ${1} denotes the (one based) index of the attribute referring to the order the attributes are mentioned in the constraint or index.

Enhancement2

Provide a possibility to assign localized validation fail messages:

create message on  upper_bound_ck  '${1} ist mehr als die Antwrot auf alles' language 'DE_de' ,  '${1} это больше, чем ответ на все' language 'RU_ru'

upper_bound_ck 

One single entry in that comma separated list may omit the language part which then will be (or replace) the default for not covered languages.

Comments
Post Details
Added on Aug 21 2018
2 comments
1,526 views