Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2008
    Posts
    5

    Unanswered: How to display an error message generated by a trigger

    Hi

    I need to prevent that a column to be updated and display an error message. The table is accesed either Developer Forms or Java Programs. There are more than 100 programs thah access the table so we don't want to modify them, instead we want to use a database trigger.

    We kwow how to write the trigger, for example

    create or replace trigger trigger_bef_upd
    before update of myField on myTable
    for each row
    declare
    myException Exception;
    begin
    if :new.myField > 1000 then raise myException ;
    end if;
    exception
    when miExcepcion then
    raise_application_error(-20999,'You cannot update this field');
    end;



    But we don´t know hoy to the error message could be displayed without modifying the programs

    Any suggestions?

    Thanks in advance

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Teach your users to get familiar with Forms capabilities.

    By default, there's the "Help" menu which contains "Display Error"; selecting it, the "raise_application_error" message will be visible to end user.

    The above "solution" doesn't require additional programming in Forms. Any other way would, as far as I can tell, require you to do some coding in order to display an error message in a nice way.

  3. #3
    Join Date
    Dec 2008
    Posts
    5
    Quote Originally Posted by Littlefoot
    Teach your users to get familiar with Forms capabilities.

    By default, there's the "Help" menu which contains "Display Error"; selecting it, the "raise_application_error" message will be visible to end user.

    The above "solution" doesn't require additional programming in Forms. Any other way would, as far as I can tell, require you to do some coding in order to display an error message in a nice way.

    This is true in Forms, but what about our Java Clients?

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Huh, you got me! Unfortunately, I wouldn't know the answer to that question.

  5. #5
    Join Date
    Dec 2008
    Posts
    5
    Quote Originally Posted by Littlefoot
    Huh, you got me! Unfortunately, I wouldn't know the answer to that question.
    No problem my friend. Thanks a lot!!!!

    We´ll continue investigating

  6. #6
    Join Date
    Mar 2008
    Posts
    89
    Hi there,

    I am not sure, if this helps at all,
    but java Developers will get SQL exceptions through the use
    of the package "java.sql.SQLException".

    If they are at least moderately good at programming for Databases, I am sure
    they are catching this type of errors and as far as I understand it (I'm not a developer myself) a failed statement because of a trigger would also be returned by the above class package, which throws all kinds of issues occuring during a JDBC connection...

    However, I have no idea in what format they would get it, probably depends both on your trigger exception output and their exception handling.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •