Sergey
Sergey

Reputation: 406

how to provide error message when rising oracle predefined exception

I rise DUP_VAL_ON_INDEX in SQL and I'd like to associate some custom error message with it. Right now after executing the code

IF ___SOME_CONDITION___ THEN
  RAISE DUP_VAL_ON_INDEX;
END IF

I see following message:

00001. 00000 -  "unique constraint (%s.%s) violated"

How I can provide custom message to substitute these "%s"?

Upvotes: 1

Views: 205

Answers (1)

Boneist
Boneist

Reputation: 23578

You wouldn't typically raise these pre-defined errors yourself. Instead, you would either let the database raise them (eg. you really have tried to insert a row that violates the unique constraint/index) or raise your own custom error (eg. raise_application_error()) and provide the necessary information there.

Upvotes: 3

Related Questions