Forum Stats

  • 3,782,434 Users
  • 2,254,645 Discussions


Intercept Database Error Message

520817 Member Posts: 35
edited Sep 9, 2008 5:08PM in APEX Discussions

Is there an easy way to intercept a database generated error so that
you can redirect Apex to a "pretty" error page rather than showing
the default database error message on the page?

For example, if you have a date field (defined as DATE in the database)
and the user doesn't enter a date in the correct format, then when
you attempt an update on their record, you get an error like:

ORA-01840: input value not long enough for date format

on a default page. I'd like to intercept that error message/number
somewhere and redirect to a "nice" error page.

I'm working over a database link. So the form data is being passed to
a package on the back-end that's doing the update.

I had attempted to have the package return a certain value to Apex
and redirect from that but it didn't work for some reason.



  • John Edward Scott
    John Edward Scott Member Posts: 5,475 Gold Badge

    Lots of different ways to do this, for example you could use exception handlers in your PL/SQL code, and on an error set the value of an item in session state (say P0_ERROR) to the value of the exception (SQLERRM etc). Then have a process that conditionally shows that error on the screen if P0_ERROR is non-null (i.e. an error occurred).

    Hope this helps,

  • Denes Kubicek
    Denes Kubicek Member Posts: 6,163 Bronze Crown
    There are many ways you can do that. Validations are one way. See this example as an alternative:

    Denes Kubicek
  • 520817
    520817 Member Posts: 35

    I had everything setup correctly. I just had to have my conditional branch be a plsql expression.

    Not the first time I have chosen the wrong item from that set of drop-down options.
This discussion has been closed.