User friendly error handling in a trigger

Hello,
How can I have user freindly error handling when am using a trigger??
In the trigger I through an exception such I use if statment in the tigger
If ( condition) then
RAISE_APPLICATION_ERROR(-20001, ' Error message');
end if;How can I display this message in uer friendly way??

See Patrick's posts here:
http://www.inside-oracle-apex.com/apex-4-1-error-handling-improvements-part-1/
http://www.inside-oracle-apex.com/apex-4-1-error-handling-improvements-part-2/

Similar Messages

  • User defined error handling in PLSQL procedure of portal form

    I need some help of building a user defined exception handling in PLSQL.
    I build a portal form based on a PLSQL procedure.
    In this procedure there are several SQL statements with exception handling.
    In case of exception I want to display my on error message and than raise the procedure, so that the user can read the message and than go back to form.
    I try this by calling a raise statement generating some HTML output over htp.p() but than the output look's like
    SQL:
    begin
    "ACHEMA2003"."P_LOGIN" ( P_STAMM_SEQ => 33491, P_ADRESSNR => 2009721, P_PASSWORD => '3333', P_PROJEKT_ID => 'ACHEMA2003', P_MESSENR => '00023', P_SPKZ => 'D');
    end;
    ORA-20000:
    Login ACHEMA 2003
    Ung|ltiges Passwort !!!
    Back to form
    I want to supress the standard Oracle messages.
    Now I read about the packages wwerr_api_error and wwerr_api_error_ui to make this, but it seems to be a little difficult.
    Is there anybody who have a solution for this problem, perhaps some example PLSQL code for this.
    Thanks Erwin.

    Jacob,
    Try following:
    declare
    v_sender VARCHAR2(1000);
    v_sender_id NUMBER;
    begin
    v_sender := p_session.get_value_as_VARCHAR2(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'A_SENDER');
    v_sender_id := p_session.get_value_as_NUMBER(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'A_SENDER_ID');
    insert into hd (number, text) values (hd_seq.nextval,
    'step 3 v_sender = ' || v_sender ||
    ' v_sender_id = ' || v_sender_id);
    if v_sender_id >= 100 then
    p_session.set_value(
    p_block_name => "_block",
    p_attribute_name => '_STATUS',
    p_value => 'Sender ID must be less than 100!');
    -- return to your form with status message set
    -- and all fields filled with recent values
    return;
    end if;
    end;
    -- This point is reached only if validation is OK
    doInsert;
    Regards,
    Henn

  • Order blocked by user / Workflow error handling

    Hi Folks,
    I am getting this requirement quite often. Time to address it in a more efficient way than that I know.
    The following is the requirement:
    Workitem goes to approver. If the approver approves/rejects the workitem, there is a subsequent change in the sales order which is handled by BAPI in the next step. If the sales order is locked by some user, BAPI does not make change and throws an error.
    Solution that I can think of:
    The way it is handled right now is - if there is an error message from BAPI - the workflow is routed to a power user or an email message is sent to admin asking him to inform the right user.
    This approach of mine does not sound correct. Can we actually throw error at the time when the approver tries to open the workitem itself (i.e. see if the transaction is being locked and if it is locked - throw an error and do not allow the approver to take action ).
    Thanks,
    aby.

    Hi Folks,
    I am getting this requirement quite often. Time to address it in a more efficient way than that I know.
    The following is the requirement:
    Workitem goes to approver. If the approver approves/rejects the workitem, there is a subsequent change in the sales order which is handled by BAPI in the next step. If the sales order is locked by some user, BAPI does not make change and throws an error.
    Solution that I can think of:
    The way it is handled right now is - if there is an error message from BAPI - the workflow is routed to a power user or an email message is sent to admin asking him to inform the right user.
    This approach of mine does not sound correct. Can we actually throw error at the time when the approver tries to open the workitem itself (i.e. see if the transaction is being locked and if it is locked - throw an error and do not allow the approver to take action ).
    Thanks,
    aby.
    Hi Aby,
    If I understand this correctly, the sales order can be blocked by some other application during the approver's task? 
    Is the approval task a decision task, or a custom task?  If custom, perhaps you could include some locking/unlocking code?
    I suppose you could  implement  a before-method to check for a lock - but you aren't able to pass data back to the approval task from a before method.  You could check for a lock in a separate task prior to the approval task, but there is no guarantee that the user would complete the task before someone else locks the object up again.
    Another approach might be to check the results of the BAPI, and if it's throwing an 'Object locked' type of error, call it again.  Of course, you would need to put some wait time in the BAPI, and also, you would need to ensure it does not go on waiting and trying forever.  But nobody likes to admit they put wait steps into anything.
    Just a few ideas to consider.  I wonder if this problem is that persistent?
    Sue

  • Getting SCRIPT5007 when trying to implement a user-friendly survey error message

    Hi,
    I am trying to use the code from http://sharepoint.stackexchange.com/questions/64357/friendly-message-when-user-tries-to-take-the-survey-again to show a user-friendly error message when a user tries to answer a survey twice.
    The detection of the user's answer count works, but when the code tries to open the survey by calling the old code (NewItem2Orig(evt, url);) I get an error SCRIPT5007
    which says, that tagName cannot be found because of an undefined or null-reference in inplview.js, row 2, column 32309.
    Does anybody know, why this is happening? I actually can't see why it shouldn't work...
    Thanks in advance
    P.S.: The error happens in IE 11, in Firefox the code seems to work

    I'm not sure how you get the parameter to execute the NewItem2Orig(evt, url). you can use JavaScript code to first get the button click event script, save it as a variable.
    Then in your rewrite NewItem2 method, else part, set the button click event to the origional event.
    Qiao Wei
    TechNet Community Support

  • Apex 4.0.1 Error handling

    Hi All,
    Do we need plug in to handle user friendly error message instread of throwing ORA- error to user?

    You could try this idea..
    http://www.talkapex.com/2010/09/custom-error-messages-in-apex.html
    or view a thread that talks about this in the Forum:
    How to Customize Error Messages?
    Thank you,
    Tony Miller
    Webster, TX
    On the road of life...There are 'windshields', and there are 'bugs'
    (splat!)
    "Squeegees Wanted"

  • Error handler

    I get the following error message when unique constraint is violated.
    "ORA-00001: unique constraint (WWW_EYECAREDEV.MAIN_EYECARE_CON) violated
    Unable to process row of table MAIN_EYECARE."
    my question now is how to i dispaly the proper message to the user....
    Thank you

    Tshepza
    If you look at your origional thread:
    Re: Validation in application express
    Andy has written some steps to create a validation that checks your table for the value you are inserting.
    If it were me, I would be looking to write the insert / update dml manually and capturing the error message in the exception handler
    i.e.
    DECLARE
    BEGIN
    insert into my_table (id, value1)
    values (pk_value, value1);
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    IF SQLCODE = -00001
    THEN
    -- logic to handle your exception. Display an nice error, redirect to a different page etc
    ELSE
    -- More logic to handle all unexpected errors
    END IF;
    END;
    I tend to set up a page in Apex that I use in my error reporting for all expected and unexpected exceptions. I redirect to this whenever an error is encountered.
    If it is an expected error, (as your is) I write a user friendly error message to the screen. If its unexpected I will log the error in my error table and display a generic "Unexpected Problem" error.
    If this is something you would like help with, let me know and i will be happy to put an example on apex.oracle.com
    Regards
    Duncan

  • Handling contraint violations in a user friendly way

    How do you trap constraint violation errors is a user friendly manner ...
    I've seen a number of related posts on the forum but have not yet seen a solution that people are happy with.
    Ideally, Id like to:
    - avoid displaying the 'raw' oracle error to the user
    - display a user-friendly message in an alert box
    - sent the user back to the entry forms with his
    entered data present.
    This requirement seems fundamental to the development of a reasonable application, somebody must have solved it.

    I'm no expert, but here's info from my own experience.
    1. Trap those pk/uk constraint violations in an appropriate exception block. Get this working and test it under all conceivable exceptions.
    2. Write an exception handler, producing the javascript/html/redirects you need.
    Oracle exception handling is pretty mature, but you need to put some effort in to catching everything listed in the package throws declarations.
    If you're working with forms or other components the approach is different, but you weren't terribly specific in your question.

  • HT4009 Not very user friendly! Where is the place to report a problem!? I have been billed for an in-app purchase but not had the goods - I received an error message telling my I hadn't been charged at the time and now it is on my bill! What can I do?

    Not very user friendly! Where is the place to report a problem!? I have been billed for an in-app purchase but not had the goods - I received an error message telling my I hadn't been charged at the time and now it is on my bill! What can I do?

    You can try contact iTunes support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Translate oracle error message into User-Friendly messages

    I want to translate the following message and display the user-friendly message.
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-02290: check constraint ...
    I have a table with MRU,MRD,...
    How do I do that?

    Mine is a sql query(updatable report). I don't have any items, except the columns on the report. One of the column is a select list of user_names( on which I want not null validation). I have "ApplyMRU" and "ApplyMRD",.. to add/delete rows.
    How do I access the columns of report. My column name is "USER_NAME". But when I put this column name in "Validate Item:" field, I am getting:
    1 error has occurred
    Item specified does not exist.

  • Error Handling in the SQL Trigger 2008 R2

    Hi ,
    I need some guidance in setting up error handling process in the table  trigger. I have created a trigger on source database table and it load data to target table whenever there are any changes in last update date of source database ( given code below).
    Problem : sometime I am getting error message ( like unique Index , data length mismatch etc) and my trigger don’t work and rollback the entire transaction.  
    Requirement : If there is an error with the insertion, I would like to move that error-inducing record into an error table  .  Any guidance much appreciate.  thanks!
    /****** Object:  Trigger Defination     ******/
    USE [MPSAIntegration]
    GO
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    /*Description:    Trigger to insert Asset details into Siebel Table*/
    ALTER
    TRIGGER [dbo].[trg_INS_INTO_CX_PRODPROF_STG]
    ON  [MPSAIntegration].[dbo].[CustomerProductLines]
    AFTER INSERT,UPDATE
    AS
    /****** Get the current Timestamp,Max of SR_NUM from Target table and LastRun time from dbo.TIME ******/
    DECLARE @currtime
    DATETIME,
    @SR_NUM
    INT,
    @Last_Run
    DATETIME
    SELECT @currtime
    = (SELECT
    CURRENT_TIMESTAMP)
    SELECT @SR_NUM
    = (select
    max(Sr_Num)
    from dbo.SerialNum
    WHERE Entity='PROD')
    SELECT @Last_Run
    = (SELECT LastRun
    from [MPSAIntegration].[dbo].[TIME]
    where ENTITY =
    'PROD')
    BEGIN
    SET
    NOCOUNT ON;
    SET
    XACT_ABORT ON;
    /***** Update dbo.SerialNum Table *****/
    UPDATE dbo.SerialNum
    SET Sr_Num = @SR_NUM+1
    where Entity='PROD';
    /***** Insert into [dbo].[CX_PRODPROF_STG] table *****/
    INSERT
    INTO [ntscrmdbdev].[SiebelDB].[dbo].[CX_PRODPROF_STG]
    ([ROW_ID]
    ,[CREATED]
    ,[CREATED_BY]
    ,[LAST_UPD]
    ,[LAST_UPD_BY]
    ,[MODIFICATION_NUM]
    ,[CONFLICT_ID]
    ,[LOAD_STATUS]
    ,[SR_NUM]
    ,[INFO_CAPTURE_DATE]
    ,[ADDRESS_NAME]
    ,[CUSTOMER_CODE]
    ,[DESCRIPTION]
    ,[PRODUCT]
    ,[SERVER_NAME]
    ,[STATUS]
    ,[CANCEL_DATE],
          [SEQUENCE_ID])
    SELECT
    CAST(CUSTOMERCODE
    AS NVARCHAR(8))+CAST(@SR_NUM
    AS NVARCHAR(7))
    ,Current_Timestamp
    ,'dbo'
    ,Current_Timestamp
    ,Current_User
    ,0
    ,'N'
    ,'Not Processed'
    ,CAST(@SR_NUM
    AS NVARCHAR(15))
    ,InfoCaptureDate
    ,(SELECT CUST.CUSTOMERNAME
    FROM CUSTOMERS CUST where CUST.CustomerCode
    = I.CustomerCode)
    ,CustomerCode
    ,ProductLine
    ,ProductLine
    ,ServerName
    ,'ACTIVE'
    ,TerminationDate
    ,1
    FROM INSERTED I
    /****** Update the LastRun in dbo.TIME ******/
    UPDATE [MPSAIntegration].[dbo].[TIME]
    SET LastRun
    = @currtime
    WHERE ENTITY
    = 'PROD';
    END

    The first choice is stored procedure. Trigger should be last resort.
    Related links:
    http://stackoverflow.com/questions/884334/tsql-try-catch-transaction-in-trigger
    http://www.sqlservercentral.com/Forums/Topic1499938-3077-1.aspx
    http://www.sommarskog.se/error-handling-I.html
    http://www.codemag.com/Article/0305111
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Error handling in user exit

    Hello every one,
    How to do error handling in user exit plz gimme some example for this..
    Regards
    Martin

    Hi Jen,
    the problem is that I want to use a transaction that needs data (TO number) that I created already but I don't called a COMMIT, see following structure (simplified):
    * Creating TO
    PERFORM create_new_transport_order CHANGING lv_generated_to_num.
    CALL TRANSACTION LT31 WITH lv_generated_to_num.
    <....>
    COMMIT WORK.
    Is it possible to call a transaction with data that is not really in the database yet? That's my question/problem.
    Thanks

  • User friendly method to post a error document

    Hi Experts,
        I have a requirement. While posting vendor billing in a custom transaction, the posting is not happening because of invalid cost objects. To solve it some alternative cost object must be selected by the custom program and has to post the document. Is there any much user friendly method to do this, apart from doing enhancement either inside the posting custom program to select valid cost objects or designing screen with controls to select valid cost objects and post?
    Thanks in advance!!!

    Hello Raju,
    Its a invoice which the user posts via a MIRO.
    I can do it with a FM also, U r right.
    There have been lots of issues with rounding values when trying to post a parked document in MIRO , till now such invoices were getting posted. Now, we r getting errors, just trying to find if someone else had encountered with a similiar problem and what was the approach they used?
    we get a value of 0.02 difference when trying to post via MIRO for some invoices, till now such invoices were getting posted. Its purely a functional issue though.
    We checked the invoice also, its prefectly fine. There does not seems to any issue, just wondering if there  has been any exchange rate problems etc...
    Thanks,
    Anitha

  • How to handle Database's trigger

    Greetings,
    i have an application on JDeveloper 11.1.2.4.0. At some point the user add new customer and its been saved to the database.
    Because the application may be used in more than 1 shop, i have created a 2nd database, only for biography uses and history,
    so it can be view by all shops. What i did is, when a new record is inserted into application's biography table, i also have a trigger
    that after the row is inserted, i also insert the new row into my 2nd database. In both databases a primary key exists to avoid duplicated id's.
    I was hoping instead of handling duplicated records on trigger, the database will handle it (if duplicated records exists, just dont save it at all),
    but my problem now is, its throw me a proper exception
    ORA-00001: unique constraint (PERSONAL_RECORD.BIOGR_PK) violated ORA-06512: at "ELAB.SAVE_BIOGR", line 11 ORA-04088: error during execution of trigger 'ELAB.SAVE_BIOGR' ORA-06512: at line 1
    AND it does not save the biogr on the 1st database either. I do not understand what the trigger have to do with the first database since its after insert row method and not before.
    It should insert the record into the database, then fire the trigger, throw an exception and dont save the record in 2nd database. But instead the record its been saved nowhere..
    The case is: user fields some text boxes for a new customer, i check if the id is already exists in the 2nd database, and i notify the user that this new customer already exists in
    the personal record database (2nd database, 1 common database for all shops), and i ask the user if he/she wants to synchronize or use the current fields. If synchronize, i take the record
    from the 2nd database and insert them into the 1st. If not, i insert them into the 1st database, and thats when the trigger should handle the duplicate row exception, not my application.
    Is there a way i can temporally turn off database trigger from my adf application or i can handle the exception BUT the record be save on the 1st database? because if the exception its been
    thrown, the new record its gone.
    thanks in advance for any help.

    True, since i can't handle the trigger procedure, i add an exception inside of it. So it will do something when the exception occurs BUT it will save the customer
    in 1st database. Here is my trigger code:
    create or replace TRIGGER SAVE_BIOGR
    AFTER INSERT
       ON ELAB.BIOGR
       FOR EACH ROW
    DECLARE
       v_username varchar2(10);
    BEGIN
       SELECT user INTO v_username
       FROM dual;
       INSERT INTO PERSONAL_RECORD.BIOGR
       ( ID,
         NAME,
         SNAME,
         USERNAME )
       VALUES
       ( :NEW.ID_PATIENTS,
         :NEW.NAME,
         :NEW.SNAME,
         v_username);
        EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
        UPDATE PERSONAL_RECORD.BIOGR SET ERROR = 'ALREADY EXIST';
    END;
    I add update on exception because leaving it blank or with comment in THEN section it gave me an error i dont know why. So i just
    include a dump update procedure.

  • Error Handling On a Page with a Report

    Hi guys.
    I have a page with a report region on it. The report is based on an External Table.
    If i load a file that does not conform to the format the External Table definition is expecting, I Get an 'ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-30653: reject limit reached' error.
    I am happy that an error is generated but my question is this?
    How can I handle this exception and others when there is just a report region on a page.
    I basically wish to capture 'ORA-30653: reject limit reached' and display an friendly error message to the user in the report region.
    Any help would be most welcome.
    Duncan

    One way to handle this that I have seen is
    a. configure your external table with REJECT LIMIT UNLIMITED
    b. specify a BADFILE badfile.txt.
    c. Create another external table on that badfile.txt with the same access parameters as your original table but specify all the columns as VARCHAR2(4000), so nothing is rejected.
    d. Create another report region on the external table on badfile.txt, call it "Load errors"
    So, you would have 2 report regions on the page, one would read your datafile and the other would read the badfile.
    Hope this helps.

  • Error Handling in JDBC Adaptor - Without BPM

    Hi friends,
    My problem is like this. Scenario is File -> Xi -> JDBC.
    here i didn't used BPM at all.
    My interface is working fine.
    right now i am not doing any error handling for 'Primary key violation, refrential intigrity etc.. '.
    if this type errors encountered i going to adapter monitoring and looking out the issue.
    Now the client requirment is
    whenever this type of errors occured Client should be notified Via email along with error description.
    Is there anyway to do this ?

    Hi Suresh,
    You can setup the Alerting framework of XI to trigger alerts. Alert rules can be set to raise alerts in case of JDBC Adapter Errors.
    Check these links....
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/81023cfa699508e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/80/942f3ffed33d67e10000000a114084/frameset.htm
    Thanks & Regards,
    Renjith
    An addition to what i just said...You have to be on SP14 for this...
    Message was edited by: Renjith Andrews

Maybe you are looking for