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

Similar Messages

  • Is there a LabView example in the use of user defined error codes?

    Specifically, I have a VI that tests four arrays of data against various high/low limits. I have pass/fail outputs for 18 tests. I'd like to combine these into an 'error out' cluster with appropriate error codes and messages, for which I've created an x-errors.txt file.
    My first question must be trival - how do I just set the 'status' bit of the error stream to let the general error handler then look up the error desription from the file?
    Secondly - I can't find an example of this in the technical resourses, amI missing something?
    Thanks,
    Mike
    Mike Evans
    TRW Conekt
    N.I. Alliance Member, UK
    http://www.Conekt.net

    There is no example program. There is extensive help on how to do this. Here's the basics.
    1) There are two ways to define user error codes in LV6.1. If you are using LV6.0 or earlier, only one method is possible.
    2) The 6.0 method involves wiring arrays of error codes and arrays of error code strings to the General Error Handler.vi. These codes will be used to explain any error code which is undefined in LV's internal error code database. Error codes reserved for users which are guaranteed not to be used by NI are from 5000 to 9999.
    3) The 6.1 method allows you to create a specially formatted error code file on disk that will be merged with the LV error code database each time LabVIEW launches. For help on this, go to LV's online help, and in t
    he Index tab, type
    "user-defined error codes, in text files"
    (without the quote marks)
    4) If you want to set an error into the error cluster, use the General Error Handler.vi again. Wire your error code value to the Error Code terminal (the leftmost-topmost corner terminal). Wire the name of your VI to the Error Source terminal, and wire "No Dialog" to the Type of Dialog terminal (left-side, near the bottom). The error code cluster that comes out of this VI will either be the error in (if one was set) or a new error code cluster with your error and the status bit set to TRUE.
    5) The attached demo is written in LV6.0.
    Attachments:
    Error_Demo.vi ‏37 KB

  • "user defined exception" in a stored procedure and APEX

    I would like to use user defined exception in a stored procedure or trigger in a APEX application.
    Does anybody know how to do it ? or know where can I find a good reference ?
    Thanks,

    raise_application_error(-20001, 'error message');
    Scott

  • User-Defined Exception in Package OE_SCHEDULE_UTIL Procedure Load_Results_f

    Hi Expert,
    While running the Order Import i am getting the error please help us :
    Order Import Concurrent Program
    Concurrent Program Parameters
    Validate Only: N
    Order Source:
    Order Ref:
    Sold To Org Id:
    Sold To Org:
    Change Sequence:
    Performance Parameter: Y
    Trim Blanks: N
    Operation:
    Number of Instances: 0
    Debug Level: 0
    Request Id: 4471
    Org Id: 2453
    Failed to perform Action Request BOOK_ORDER
    Failed to perform Action Request BOOK_ORDER
    No. of orders found: 1
    No. of orders imported: 0
    No. of orders failed: 1
    Source/Order/Seq/Line Message
    10/1046001534//2 ATP Process resulted in no data
    10/1046001534//2 User-Defined Exception in Package OE_SCHEDULE_UTIL Procedure Load_Results_from_tbl
    10/1046001534//2 User-Defined Exception in Package OE_SCHEDULE_UTIL Procedure Load_Results_from_rec
    End of Order Import Concurrent Program
    Regards,
    Suraj

    And also check
    Order Import error : User-Defined Exception in Package OE_SCHEDULE_UTIL Procedure Action_Undemand,User-Defined Exception in Package OE_SCHEDULE_UTIL Procedure Action_Reschedule [ID 737031.1]

  • Page process: user defined error-message

    hi to everyone!
    i want to display a user-defined error-message, if for example a select in an anonymous PL/SQL block returns more than one row. i tried it with an user defined exception, but i get allways the success message... how can i do that?
    thanks for your help.
    bye,
    christian

    Hi,
    In the exception handler of your PL/SQL process use this :-
    apex_application.g_print_success_message := '<span style="color:red">Error message</span>';Regards
    Paul

  • Help in user defined exception handler

    Hi
    Can some one help in solving this error .
    when i run my procedure i get this error which is given below .
    ORA-06510 PL/SQL unhandeled user defined exception at line 7
    Procedure FMG_EXTRACT_MOTORBIKE_NEWBUS (P_NSSC_YN VARCHAR2) IS
    l_start date;
    l_end date;
    cursor motorbike_rec is
    select
    c.id,
    k.id pak_id,
    p.ref,
    i.description,
    i.current_status,
    i.premium,
    i.sum_insured,
    mv.registration_no,
    mv.cc_rating,
    nl.ncl_level,
    nl.percentage_discount,
    dp.full_name main_driver,
    dpd.birth_date,
    e.user_name entered_by,
    ep.full_name emp_name,
    fmg_get_imposed_terms(i.id,'. ',';') imposed_terms
    from
    fmg_clients c,
    fmg_client_paks k,
    fmg_policies p,
    fmg_Policy_items i,
    fmg_mv_usages u,
    fmg_people dp,
    fmg_people_details dpd,
    fmg_employees e,
    fmg_people ep,
    fmg_motor_vehicles mv,
    fmg_ncb_levels nl
    where i.date_created>=l_start
    and i.date_created<l_end
    and i.pol_id=p.id
    and p.ctp_id=k.id
    and k.cli_id=c.id
    and i.id=u.poi_id(+)
    and u.per_id=dp.id(+)
    and dp.id=dpd.per_id(+)
    and i.id=mv.poi_id(+)
    and i.ncl_id=nl.id(+)
    and ( (i.pit_pro_code in ('TFF','FMC','FMT','FMF','FBK','PMC','TPO','MCL'))
    or (i.pit_pro_code = 'CMV' and i.pit_code = 'MCL')
    or (i.pit_pro_code = 'PMS' and i.pit_code = 'MCL')
    or (i.pit_pro_code = 'PMT' and i.pit_code in ('MCT','MCF'))
    and i.user_created=e.user_name
    and ( (e.business_unit='BCC' and P_NSSC_YN='Y') OR (nvl(e.business_unit,'X')<>'BCC' and P_NSSC_YN='N') )
    and e.per_id=ep.id;
    l_file UTL_FILE.FILE_TYPE;
    l_file_name varchar2(100);
    l_data VARCHAR2(4000);
    BEGIN
    if P_NSSC_YN='Y' then
    l_start := trunc(sysdate)-1;
    l_end := trunc(sysdate);
    l_file_name := 'MotorCycle_Daily_'||to_char(l_start)||'.csv';
    l_file := utl_file.fopen( fmg_re_filepath('SSC'), l_file_name, 'W' );
    else
    l_start := to_date('01-' || to_char(sysdate-28,'MM-YYYY'));
    l_end := last_day(to_date('01-' || to_char(sysdate-28,'MM-YYYY')));
    l_file_name := 'MotorCycle_Monthly_'||to_char(l_start)||'_'||to_char(l_end)||'.csv';
    l_file := utl_file.fopen( fmg_re_filepath('GAU'), l_file_name, 'W' );
    end if;
    l_data := '"Client ID","Pak ID","Policy Ref","Item Desc","RegoNo","CC","Item Status","Premium","Sum Insured",' ||
    '"NCB Level","NCB%","Main Driver","Birth Date","Imposed terms","EnteredBy","Employee Name"';
    utl_file.put_line(l_file, l_data );
    for i in motorbike_rec loop
    l_data :=
    to_char(i.id) || ',' ||
    to_char(i.pak_id) || ',' ||
    i.ref || ',' ||
    '"' || i.description || '",' ||
    '"' || i.registration_no || '",' ||
    to_char(i.cc_Rating) || ',' ||
    i.current_status || ',' ||
    to_char(i.premium) || ',' ||
    to_char(i.sum_insured) || ',' ||
    to_char(i.ncl_level) || ',' ||
    to_char(i.percentage_discount) || ',' ||
    '"' || i.main_driver || '",' ||
    to_char(i.birth_date) || ',' ||
    '"' || i.imposed_terms || '",' ||
    i.entered_by || ',' ||
    '"' || i.emp_name || '"' ;
    utl_file.put_line(l_file,l_data);
    end loop;
    utl_file.fclose( l_file );
    exception
    when others then
    if utl_file.is_open(l_file) then
    utl_file.fclose( l_file );
    end if;
    raise;
    END;

    What does fmg_re_filepath('SSC') return? Are their sufficient rights with Oracle user on the location that is returned by this function?
    Which OS are you using?

  • How do you use user defined error messages in Value Help?

    Hi,
    I'm currently working on a Modifiable Value Help Selector in Web Dynpro Java, and I want to use a user defined error message when I validate the values entered by a user. Currently, it's returning its default error message ("Character <string> does not match...").
    Since the project requires a different error message, is there a way to override the default error message and use my defined error message instead?
    Thanks!

    Hi Angelo,
    I am not sure why message area is showing both Custom and inbuilt messages but you can try the following:
    i guess you must be using reportContextAttribute exception for showing Error messages on the input fields as well.in that case you can disable the message area so messages will appear only on the Context level ie; on input fields.
    For other messages apart from validation messages you can enable the message area before reporting the exception.
    make sure the boolean context variable which will be used for enabling and disabling the message area should have Readonly property set as true.
    I am not sure whether this is the only solution for this but you can try and see if it works.
    Siddharth

  • 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/

  • User defined error management in variance calculation

    Dear Expert,
    I would like to change the message type for some messages in variance calculation. Path:  IMG/product cost controlling/cost object controlling/product by order/manufacturing order/periodic processing.  According to IMG documentation, the message type can be changed here. But I failed to edit the message and it seems not modifiable.  Can anyone reply on this? Thanks!
    BEST REGARDS
    Maggie
    Edited by: Qin Ou on Oct 27, 2009 6:36 AM

    Hi,
    I am able to change the message is the IMG Path:
    IMG/product cost controlling/cost object controlling/product by order/manufacturing order/ User defined Error Management /
    1, Specify User-Def. Msg Types for Preliminary Costing of Manufacture
    2, Assign Message to Responsible Area
    Regards,
    Sridhar Sha

  • Is there a range of error codes reserved for user defined error codes?

    I would like to create my own error codes for a CVI dll but I want to make sure I don't use error codes already defined for something else. Is there a range reserved for such use?
    Samee thing for warnings (errorcode > 0)
    Thanks

    I have never found a positive mention of a "safe" range of error codes available for user-defined error conditions, but I can suggest you some source of informations.
    First of all, every library has its specific list of error codes, usually listed in the relative include file. All these error codes are listed in the online help too (search for "error codes" in the index tab of the help).
    Second, GetGeneralErrorString () is a function that can be used to trap errors of the following libraries with a unique error function:
    User Interface Library
    Easy I/O instrument driver
    Toolbox instrument driver
    ActiveX Library
    DIAdem Connectivity Library
    .NET Library
    DataSocket instrument driver
    Network Variable Library
    Real-Time Utility Library
    TDM Streaming Library
    UDP Support Library
    This means that the error codes from this libraries do not overlap, so you could derive from its code some ranges not used by these libraries.
    Nevertheless, there is not a single function for error trapping: every library has its proper list of error codes and a function to decode them in human readable form, andthere is no guarantee that these ranges does not overlap. It's up to you to trap errors from every function in the proper way.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Is including an error handler in every procedure OK?

    Hello,
    I have read a lot of articles about error handling on the internet but could not find advice on whether it is good/acceptable practice to put a handler in every procedure. My goal
    when debugging is to break on every error, so that the relevant variables are still in scope, and I can view them and react to the error. Is there a VS setting for this, or do I need to achieve this via error handling?
    In VB6 I think that there used to be a “Break on all errors” option.
    Currently, many procedures in my code do not have error handlers. When an error is encountered in a procedure that does not have an error handler, I believe that control is passed back down the stack to the first procedure that has a Catch.
    This makes it hard to debug, because the error variables that I need to review are out of scope.
    Therefore, if one is not worried about performance considerations, is it reasonable/best practice to include an error handler in every procedure where there might conceivably be an error?
    Also, how will the above approaches affect runtime behaviour?
    Many thanks.
    Keith
    R K Howard

    Hi Keith,
    First, just to be clear, I am going to assume that by error handling we are talking about Try-Catch blocks in code.  As Acamar said, if you write a block of code that has the potential to fail, and you have a plan for doing something when that failure
    occurs, then definitely wrap the code block in a Try-Catch. 
    As for what happens in the debugger when an error occurs, it depends on the context of the error and the assembly in which it occurred.  If you are still on the UI thread and the error occurred in your code or a base class library, then execution
    will stop on the line of code that caused the error - with or without a Try-Catch.  If however the error occurred in another thread, asynchronously, or within an assembly for which you do not have source code (or in unmanaged code), then the debugger
    will break at the lowest spot in the stack where managed code with known source was executed, or nowhere (no source available) if there is no source code or you broke in unmanaged code.  In these cases, adding a Try-Catch might let you break closer to
    the exception because there is managed code executed to create the Try statement - but it still doesn't let you break
    at the actual exception because there's still either no source code or the error is unmanaged.
    So I guess the answer is two-part: don't be afraid to use Try-Catch anywhere that it makes sense, and wait for the improved debugging experience in the next version of Visual Studio (they're improving the ability to debug with secondary threads and async
    code execution).
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Throw user defined Errors from within built in apex procedures

    Hi all
    The task at hand is I have a tabular form with add row button. On click of this button, the built in add row to a form type of process is called. The table in which this row is being added has some Foriegn key constraints and some other check constraints.
    What I want is if during insertion in the table, if there is a foreign key voilation and the process fails, I should be able to throw a user defined exception.
    And moreso, I want to throw this in the notification area and not the error page.
    Any thoughts??
    Regards
    Shantanu Dhanuka

    Hi Shantanu,
    If you want to capture exceptions raised by the wizard created MR* processes, you have to complete replace this processes with your own processes where you do the insert/update/delete. Don't forget to add the code for the optimistic locking.
    About showing the error in the notification area, see my blog posting at
    http://inside-apex.blogspot.com/2006/12/hacking-apex-error-page.html
    which is able to do that.
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com
    Check out the ApexLib Framework: http://apexlib.sourceforge.net

  • User defined error in register service of service portlet

    Hi,
    When I try to install the service portlet(PLSQL PDK)
    I get a user defined exception error whenthe service register
    sql file is ran.
    Does any one know the solution for this??
    cheers,
    Ranjit
    PS:sorry for posting this second time.

    Hello Shanky!
                When ever purchase order is created, a message type will get invoked which in turn will call the function module IDOC_INPUT_PORDCR1.The import parameters of this function module must be populated with appropriate values when purchase order is created.Failing which, error messages will be generated.That's what happened in your case.
               Also, please check in WE05 whether your IDoc is created with error.If you have erroneous IDoc in WE05 for your purchase order, it should be due to the above stated reason.To override the erroneous IDocs , take a copy of the above function module and do the customization that suits to your requirement. 
               If  you cannot handle this issue, approach your ABAP-XI consultant or the ABAPer who has knowledge in ALE/IDocs.
    Regards,
    S.Suresh

  • Send a array of user-defined java objects to stored procedure

    hi,
    I´d like to know if its possible send java user-defined objects to a collection. I've tried the exemple bellow but it doesn´t work:
    1) In database
    -- nested table type
    create or replace type client_table_type is table of client%rowtype;
    -- table client:
    teste
    ( id number(18,0),
    name varchar2(80),
    birthday date)
    -- stored procedure
    create or replace package client_pkg
    is
    procedure insert_clients(
    p_array_clients client_table_type
    end;
    2) In Java
    java.lang.Class.forName ("oracle.jdbc.driver.OracleDriver");
    java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:oracle:thin .....);
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("client_table_type", conn);
    ARRAY a2 = new ARRAY(descriptor, conn, anArrayIn);
    PreparedStatement ps = (PreparedStatement)conn.prepareStatement("{ call client_pkg.insert_clients(?) }");
    ps.setArray(1, a2);
    ps.execute();
    Where anArrayIn is an array of Client and Client is a java user-defined class with these attributes:
    public class Client{
    public long id;
    public String name;
    public Date birthday;
    3) when I´ve tried to run the java code its returned the error in the ArrayDescriptor line:
    Exception in thread "main" java.sql.SQLException: .....:
    Unable to resolve type: "SISSERV.CLIENT_TABLE_TYPE"
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.sql.ArrayDescriptor.initPickler(ArrayDescriptor.java:1976)
    at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:199)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:118)
    at teste_array_oracle.Carga.callPLSQL(Carga.java:60)
    at teste_array_oracle.Carga.<init>(Carga.java:41)
    at teste_array_oracle.Carga.main(Carga.java:32)
    erro de execuþÒo
    Tks for any help!

    A brief answer to this from my side (not knowing Java that wel), but hopefully suffices to put you on the right track.
    <p>
    A SQL user defined type is basically a class (it can contain properties and methods). It has only superficial resemblence to a traditional record struct. So you cannot use one. Even if you could (assuming you code a PL/SQL "traditional" record struct), there are issues around how char and numeric data are represented binary inside Oracle and issues around byte/word alignment.
    <p>
    So bottom line - what you're doing will not work (as the errors show).
    <p>
    Okay, so what then? Well, the OCI (Oracle Call Interface) supports all Oracle data types, including these user types (also called Advance Data Types in Oracle-speak). You therefore need to use the supplied API calls to deal with instantiated objects (structures) of these type.
    You're best bet is to have a look Oracle® Database Java Developer's Guide

  • Error Handling in Stored Procedure code

    Hi All,
    I need to know which step is failing and whats the error message when i run a stored procedure.
    Lets say i have a stored procedure with below content.So i want to know which of the below four statements failed,and
    the error message belonging to it.
    How can i modify the below code to achieve my output.
    begin try
    DELETE FROM Table1 WHERE Column1 = 'A'
    UPDATE Table1 SET Column1 = 'C' WHERE Column2 = 'B'
    SELECT * FROM Table1 WHERE Column3 = 'C'
    SELECT * FROM Table1 WHERE Column4 = 'D'
    end try
    begin catch
    end catch
    Thanks in Advance!!

    Take a look at this excellent TechNet Wiki article
    Structured
    Error Handling Mechanism in SQL Server 2012
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

Maybe you are looking for