Forum Stats

  • 3,769,230 Users
  • 2,252,933 Discussions
  • 7,874,951 Comments

Discussions

Intercept Database Error Message

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

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.

Thanks.
Tagged:

Answers

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

    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,

    John.
    --------------------------------------------
    http://jes.blogs.shellprompt.net
    http://www.apex-evangelists.com
  • 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:

    http://apex.oracle.com/pls/otn/f?p=31517:185

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------
  • 520817
    520817 Member Posts: 35
    Thanks,

    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.