Thomas Carlton
Thomas Carlton

Reputation: 5968

Oracle: Raise custom error messages without conflict with default error IDs?

I'm writing an application using .Net.

The application is connected to Oracle database and handles oracle error messages.

It works like this

Try
    'Do oracle operations
Catch Ex as OracleException
    'Handle exception
End Try

In the database side, I'm creating some customized error messages :

raise_application_error (-20000, 'Custom Error description');

My problem is that : I don't want any conflict between the Error number of default Oracle errors and mine. So I tried to use an Error Number outside default oracle interval (From 0000 to 62001) but I'm getting the error "Ora-21000 error number argument to raise_application_error. 63000 is out of range"

Does anyone have a workaround ?

Upvotes: 1

Views: 8101

Answers (2)

OldProgrammer
OldProgrammer

Reputation: 12169

The user-defined error code range that you can use is in the range -20000..-20999. So, any values you assign in that range will work. You can read more about exception in the Oracle Docs

Upvotes: 6

Justin Cave
Justin Cave

Reputation: 231661

The only error codes that it is valid for your application to use are -20000 to -20999 (giving you a range of 1000 error codes). You can use any of those without conflicting with Oracle database error codes. Some of Oracle's internal packages, though, do use error codes in that range.

Upvotes: 4

Related Questions