debugModerate
Does Oracle PL/SQL have a standard ASSERT routine?
Viewed 0 times
sqlroutinestandardassertdoesoraclehave
Problem
I'd like to use an ASSERT routine functionally similar to the one found in other languages, i.e. a construct (be it a procedure, syntax...)
such that when the `
I know this is trivial to do by hand but I'm asking if there's a standard one provided with the DBMS.
Having to write my own one or import one from 3rdy-party packages would be impractical, since I'd need it to be completely portable and transparent to every project I'm working on.
ASSERT( , )such that when the `
passed in the first argument is false an exception is raised with the specified ` descriptive message.I know this is trivial to do by hand but I'm asking if there's a standard one provided with the DBMS.
Having to write my own one or import one from 3rdy-party packages would be impractical, since I'd need it to be completely portable and transparent to every project I'm working on.
Solution
There isn't a built-in assertion procedure in SQL or PL/SQL, so you will have to write your own.
There are two ways of going about this. You can either manually raise an exception, as discussed in this Oracle article, or you can write a wrapper for the
I'll add that exceptions were designed for this kind of scenario, so you'd be better off taking your programmer hat off for a second & using your DBA hat :)
There are two ways of going about this. You can either manually raise an exception, as discussed in this Oracle article, or you can write a wrapper for the
raise_application_error procedure, which is documented in the Oracle exception handling section of the documentation. I'll add that exceptions were designed for this kind of scenario, so you'd be better off taking your programmer hat off for a second & using your DBA hat :)
Context
StackExchange Database Administrators Q#23705, answer score: 11
Revisions (0)
No revisions yet.