Embedded Java in BPEL and exception handling

Hello everybody,
i want to use some embedded java code in my BPEL process (bpelx:exec). This code would sometimes throw exceptions. How can i deal with these exceptions to control my BPEL process? I would like, in a sense, to do some catching of java exceptions but at the BPEL level... for example, my java code would throw an exception, that my BPEL process would "catch" and react the way i want. Is it possible to do that?
Thanks for your help!
Nicolas

you need to throw a com.oracle.bpel.client.BPELFault ..
from the code
* This class represents a standard fault that may be thrown by the server
* during run-time. A BPEL fault has defined, minimally, a QName that
* corresponds to the fault name (there are several standard faults that
* are supported, please refer to Appendix A - Standard Faults in the BPEL
* 1.1 specification for a complete list).
* <p>
* This class can only be used from within a <code>bpelx:exec</code> activity;
* the <code>throw</code> activity can be used from BPEL code.
* <p>
* Additional information (such as a fault variable) can be passed through
* as a part. Currently, internal system errors populate error codes and
* summary messages via parts.
hth clemens

Similar Messages

  • Using embedded Java in BPEL 2.0

    I have found a lot of write ups but am having difficulty.
    My problem is a failure to deploy by composite. I get the message below:
    Redeploying on /Farm_soadev_domain/soadev_domain/AdminServer ...
    Redeploying on "/Farm_soadev_domain/soadev_domain/AdminServer" failed!
    There was an error deploying/undeploying composite on AdminServer: Error occurred during deployment of component: formatDate to service engine: implementation.bpel for composite: formatData: ORABPEL-05250
    Error deploying BPEL suitcase.
    error while attempting to deploy the BPEL component file "E:\Oracle\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\dc\soa_c8abc64b-8475-4479-b54b-b36e4f44c37a"; the exception reported is: java.lang.RuntimeException: failed to compile execlets of formatDate
    This error contained an exception thrown by the underlying deployment module.
    Verify the exception trace in the log (with logging level set to debug mode).
    To simplify the issue I have reduced my code snippet to:
    /*Write your java code below e.g.
      System.out.println("Hello, World");
    String testOne = "Hi Mom";
    The embedded section looks like:
        <extensionActivity>
          <bpelx:exec name="decodeBinary" language="java">
            <![CDATA[
    /*Write your java code below e.g. 
      System.out.println("Hello, World");
    String testOne = "Hi Mom";]]>
          </bpelx:exec>
        </extensionActivity>

    I read the blog post here
    Embedding Java in BPEL process
    Based on that I created this test class to help write code:
    The bolded code is the snippet I actually want to implement when I can solve the problem above.
    package com.f17.customfunction;
    import com.collaxa.cube.engine.ext.bpel.v1.nodes.BPELXExecLet;
    public class codeTyper extends BPELXExecLet {
        public codeTyper() {
            super();
        public void exec(){
         // below code gets pasted in here
    String input = (String)getVariableData("testfile");
    oracle.soa.common.util.Base64Decoder Decoder = new oracle.soa.common.util.Base64Decoder(); 
    try { 
    byte[] decodedByteArray = oracle.soa.common.util.Base64Decoder.decode(input.getBytes());
    setVariableData("compANDstore_merge_InputVariable.AusCreditCollection/ns2:AusCredit/ns2:fileData,decodedByteArray",decodedByteArray);
    } catch(Exception e) {
    e.printStackTrace();

  • Pls help..Constructor,setter, getter and Exception Handling Problem

    halo, im new in java who learning basic thing and java.awt basic...i face some problem about constructor, setter, and getter.
    1. I created a constructor, setter and getter in a file, and create another test file which would like to get the value from the constructor file.
    The problem is: when i compile the test file, it come out error msg:cannot find symbol.As i know that is because i miss declare something but i dont know what i miss.I post my code here and help me to solve this problem...thanks
    my constructor file...i dont know whether is correct, pls tell me if i miss something...
    public class Employee{
         private int empNum;
         private String empName;
         private double empSalary;
         Employee(){
              empNum=0;
              empName="";
              empSalary=0;
         public int getEmpNum(){
              return empNum;
         public String getName(){
              return empName;
         public double getSalary(){
              return empSalary;
         public void setEmpNum(int e){
              empNum = e;
         public void setName(String n){
              empName = n;
         public void setSalary(double sal){
              empSalary = sal;
    my test file....
    public class TestEmployeeClass{
         public static void main(String args[]){
              Employee e = new Employee();
                   e.setEmpNum(100);
                   e.setName("abc");
                   e.setSalary(1000.00);
                   System.out.println(e.getEmpNum());
                   System.out.println(e.getName());
                   System.out.println(e.getSalary());
    }**the program is work if i combine this 2 files coding inside one file(something like the last part of my coding of problem 2)...but i would like to separate them....*
    2. Another problem is i am writing one simple program which is using java.awt interface....i would like to add a validation for user input (something like show error msg when user input character and negative number) inside public void actionPerformed(ActionEvent e) ...but i dont have any idea to solve this problem.here is my code and pls help me for some suggestion or coding about exception. thank a lots...
    import java.awt.*;
    import java.awt.event.*;
    public class SnailTravel extends Frame implements ActionListener, WindowListener{
       private Frame frame;
       private Label lblDistance, lblSpeed, lblSpeed2, lblTime, lblTime2, lblComment, lblComment2 ;
       private TextField tfDistance;
       private Button btnCalculate, btnClear;
       public void viewInterface(){
          frame = new Frame("Snail Travel");
          lblDistance = new Label("Distance");
          lblSpeed = new Label("Speed");
          lblSpeed2 = new Label("0.0099km/h");
          lblTime = new Label("Time");
          lblTime2 = new Label("");
          lblComment = new Label("Comment");
          lblComment2 = new Label("");
          tfDistance = new TextField(20);
          btnCalculate = new Button("Calculate");
          btnClear = new Button("Clear");
          frame.setLayout(new GridLayout(5,2));
          frame.add(lblDistance);
          frame.add(tfDistance);
          frame.add(lblSpeed);
          frame.add(lblSpeed2);
          frame.add(lblTime);
          frame.add(lblTime2);
          frame.add(lblComment);
          frame.add(lblComment2);
          frame.add(btnCalculate);
          frame.add(btnClear);
          btnCalculate.addActionListener(this);
          btnClear.addActionListener(this);
          frame.addWindowListener(this);
          frame.setSize(100,100);
          frame.setVisible(true);
          frame.pack();     
        public static void main(String [] args) {
            SnailTravel st = new SnailTravel();
            st.viewInterface();
        public void actionPerformed(ActionEvent e) {
           if (e.getSource() == btnCalculate){
              SnailData sd = new SnailData();
           double distance = Double.parseDouble(tfDistance.getText());
           sd.setDistance(distance);
                  sd.setSpeed(0.0099);
              sd.setTime(distance/sd.getSpeed());
              String answer = Double.toString(sd.getTime());
              lblTime2.setText(answer);
              lblComment2.setText("But No Exception!!!");
           else
           if(e.getSource() == btnClear){
              tfDistance.setText("");
              lblTime2.setText("");
       public void windowClosing(WindowEvent e){
                   System.exit(1);
        public void windowClosed (WindowEvent e) { };
        public void windowDeiconified (WindowEvent e) { };
        public void windowIconified (WindowEvent e) { };
        public void windowActivated (WindowEvent e) { };
        public void windowDeactivated (WindowEvent e) { };
        public void windowOpened(WindowEvent e) { };
    class SnailData{
       private double distance;
       private double speed;
       private double time;
       public SnailData(){
          distance = 0;
          speed = 0;
          time = 0;
       public double getDistance(){
          return distance;
       public double getSpeed(){
          return speed;
       public double getTime(){
          return time;
       public void setDistance(double d){
          distance = d;
       public void setSpeed(double s){
          speed = s;
       public void setTime(double t){
          time = t;
    }Pls and thanks again for helps....

    What i actually want to do is SnailTravel, but i facing some problems, which is the
    - Constructor,setter, getter, and
    - Exception Handling.
    So i create another simple contructor files which name Employee and TestEmployeeClass, to try find out the problem but i failed, it come out error msg "cannot find symbol".
    What i want to say that is if i cut below code (SnailTravel) to its own file(SnailData), SnailTravel come out error msg "cannot find symbol".So i force to put them in a same file(SnailTravel) to run properly.
    I need help to separate them. (I think i miss some syntax but i dont know what)
    And can somebody help me about Exception handling too pls.
    class SnailData{
       private double distance;
       private double speed;
       private double time;
       public SnailData(){
          distance = 0;
          speed = 0;
          time = 0;
       public double getDistance(){
          return distance;
       public double getSpeed(){
          return speed;
       public double getTime(){
          return time;
       public void setDistance(double d){
          distance = d;
       public void setSpeed(double s){
          speed = s;
       public void setTime(double t){
          time = t;

  • Error while embedding java into BPEL

    Hi Guys,
    I am getting the following error while embedding Java into BPEL.
    Error: C:\unzipjdev\jdev\system\oracle.j2ee.10.1.3.41.57\embedded-oc4j\.client (The system cannot find the file specified)
    i checked for .client content , it is not available in the directory.
    Does anybody know about this?

    could you please provide the java exec code snippet that you use in bpel? there is a sample under samples/references/JavaExec

  • How to debug embedded Java in BPEL

    Is there a way to figure out why Java code embedded in a BPEL does not work?
    JDev 11.1.1.4

    What's not working??

  • C call-out and exception handling on HP_UX

    Does anyone have experiencing calling out to C++ code which uses exception
    handling on HP_UX? I'm having trouble getting this to work - details
    below.
    I'm trying to call out of Forte to some C++ code. The exposed functions
    have been specified extern "C". This C++ code makes calls to the Lotus
    Notes' C++ API. This API uses exception handling, as does our C++ code.
    This all works great on Window NT. It's pretty cool, in fact.
    It's not so cool on HP_UX. We're running 10.20, Forte 3.0.E. Apparently,
    under HP_UX you have to compile and link using the +eh option in order to
    use exception handling. So I did this. My test driver (which calls out to
    my user object module) works fine.
    So I fired up fcompile, passing in the +eh arguments, and the location of
    one of Lotus Notes' shared libraries:
    fcompile -cflags eh -lflags "eh /opt/lotus/notes/latest/hppa/libnotes.sl"
    It works, giving me no errors.
    Then I try to call the functions from inside Forte. It gives me the "Not
    enough space loading library blah-blah-blah" error message. In my
    experience, this message is misleading, and there's actually something else
    going on. So I looked at the log file for the node manager. I saw these
    messages:
    /usr/lib/dld.sl: Unresolved symbol: __eh_Cqqsh_DynScope (data) from
    /tools/forte/EdgeNotes/userapp/conplus_/cl0/lnapifor.sl
    /usr/lib/dld.sl: Unresolved symbol: __eh_dt_count (data) from
    /tools/forte/EdgeNotes/userapp/conplus_/cl0/lnapifor.sl
    /usr/lib/dld.sl: Unresolved symbol: __eh_reset_dt_count (data) from
    /tools/forte/EdgeNotes/userapp/conplus_/cl0/lnapifor.sl
    /usr/lib/dld.sl: Unresolved symbol: __eh_Cqqlo_Object (data) from
    /tools/forte/EdgeNotes/userapp/conplus_/cl0/lnapifor.sl
    /usr/lib/dld.sl: Unresolved symbol: dealloc_object__18__eh_thrown_objectFi
    (code) from /tools/forte/EdgeNotes/userapp/conplus_/cl0/lnapifor.sl
    I don't know what this all means. In an attempt to replicate the situation
    as closely as possible, I tried linking in the shared library (created by
    Forte) to my driver program, and ran my driver program. It worked,
    although it gave me the following warnings:
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqfo.sl was not compiled with +eh.
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqrpgs.sl was not compiled with +eh.
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqsm.sl was not compiled with +eh.
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqdo.sl was not compiled with +eh.
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqcm.sl was not compiled with +eh.
    __link_incompatibility: Warning: Shared library
    /tools/forte/EdgeNotes/install/lib/libqqknpthrd.sl was not compiled with
    +eh.
    Hmmm .... After further investigation, I found that the
    "__eh_Cqqsh_DynScope", "__eh_dt_count", and
    "dealloc_object__18__eh_thrown_objectFi" symbols are referenced from my
    user object module, and not from any of Forte's libraries (via the nm
    command).
    My guess is that there's an incompatibility between the forte run-time, and
    my code, and I'm further guessing that this incompatibility is related to
    the fact that my code is using exception handing.
    I'm in contact with Forte Tech Support, but I wanted to see if anyone on
    this list has ever run across this.
    Thanks,
    Dan
    [email protected]

    I did not know that the 9.2 Oracle ODBC driver was not certified for Oracle 7
    In fact, when I read the help in the Oracle Net Manager that I installed from the same package (OraWin9204.exe), I can see that there is a normal conncection possible between the packed software and Oracle 7. Downward compatibility is something we should expect from astate-of-the-art RDBMS like Oracle.
    I do not have the Oracle 7 ODBC driver installed, I was since two years using the Oracle 8 ODBC driver wich worked fine with both Oracle 7 and 8 but due to upgrading of one of our production databases to Oracle 9 I had to install the Oracle 9 software.
    As I stated in my original mail, when testing the Oracle 9 driver in the Data source (ODBC) off my WinXP, it gives a perfect result while connectiing to the System DSN I configured for the Oracle 7 database.
    But when opening Access2003 and linking tables, the ODBC call always fails
    BR,
    Theo

  • What is the idea behind Render Response and Exception Handling in TF?

    Dear All,
    While searching for answer for my question, I find it hard to decipher this line.
    task flow exception handling doesn't handle any exception that is in Render Response phase
    I found this several times in many post like this.
    Re: ADF Exception handling (including RENDER RESPNSE PHASE)
    and this
    Re: Exception Handling in TaskFlow
    What's the idea behind exception handling in task flow that is related to JSF/ADF life cycle?
    I can't find a resource on why I should know what phase an exception has been thrown?
    Sorry if my question might be vague/ignorant to others, but I just would like to know the idea from experts around here. :)
    Thanks.
    JDEV 11G PS4

    Hi,
    Render Response is the last lifecycle phase processed during JSF request. The ADF controller has no chance of handling exceptions that occur during this time (example, exception thrown in managed bean) and therefore in its default exception handling implementation ignores this lifecycle phase. As an application developer you don't need to know when an exception is raised. However, if you find that an exception occurs during Render Response and it is not handled by the ADFc declarative exception handler, then you know. You can try and override the framework exception handler as explained here:
    https://blogs.oracle.com/jdevotnharvest/entry/extending_the_adf_controller_exception_handler
    However, better practice is to use try/catch blocks surrounding e.g. calls in a managed bean that could cause exceptions
    Frank

  • MC.9 and MCY1 and Exception Handling in (Logistics Inf. Sys)LIS

    Hi,
    I want the 'Valuated Stock Value" greater then or equal to zero (>=) appear in the MC.9 report. I can create 'Exception' in MCY1 but am unable to do so. Once I am in MCY1; I choose 'Requirements' then Key Figure 'Valuated Stock Value' then  'Type of condition' is 'Threshold Val. Anal.' is set to '> 0'. However, the report still displays zero values in MC.9. I don't want to display 'Valuated Stock Value' zero to be displayed on the report. Please help.
    Thanks
    Naved

    Hey Chris,
    I got the point for exception handling in weblogic 9.2. We ae using 9.2. It comes up with the concept of shared page flows which means all my unhandled exceptions are thrown to the shared page flow controller. There based on the type of exception, i can forward the request to appropraite page.
    Thanks anywyas,
    Saurabh

  • Exception Handling In BPEL  By using Catch Blocks or Fault Policies Or Both

    I have a confusion regarding
    Exception handling :
    When Should i go for 1)Catch Block (Remote , or binding ) in bpel for exception handling .
    2)Fault Policy , Fault binding.xml
    Currently iam using catch blocks , but even fault policy is good , but can i use both...
    Currently in My bpel ,when any error occurs i have to send a error notification by Email .
    Currently i have exposed the email service which shuts emails and write a file with errored Message.
    Hence if any error i will catch i in a parent BPEL, i will just invoke the above email, service .
    So anybody can help me by giving the suggestion how to go for the best approach
    Edited by: anantwag on Mar 23, 2011 6:31 AM

    Currently in My bpel ,when any error occurs i have to send a error notification by Email .
    Currently i have exposed the email service which shuts emails and write a file with errored Message.Seeing your use case I will suggest you to use fault handling framework (fault policy). Fault handling framework should be used where you need generic error handling framework which handles all the faults occured in any composite component. Generally BPEL catch block should be used to propagate error info/fault back to the client/to fault handling framework or to consume an error
    Regards,
    Anuj

  • Exception Handling in Message Mapping and Alert

    Hello,
    1. Pls let me know the concept of Exception Handling and Alerts.
    2. Pls provide some blogs for Exception Handling in Message Mapping.
    3.What are Alerts and how it help us in XI. Pls provide some blogs for Alert
    4.How are Alerts and Exception Handling can be related say for some scenario
    Regards

    Hi,
    Plz check out these blogs of Sravya on Error Handling:
    /people/sravya.talanki2/blog/2006/11/22/error-handling-framework-xiout-of-the-box-episode-1
    /people/sravya.talanki2/blog/2006/11/23/error-handling-framework-xiout-of-the-box-episode-2
    Also check this SAP Presentation:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9418d690-0201-0010-85bb-e9b2c1af895b
    /people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping
    Error Handling :
    http://help.sap.com/saphelp_nw04/helpdata/en/56/b46c3c8bb3d73ee10000000a114084/frameset.htm
    Alerts:
    /people/michal.krawczyk2/blog/2005/09/09/xi-alerts--troubleshooting-guide
    /people/michal.krawczyk2/blog/2005/09/09/xi-alerts--step-by-step
    http://help.sap.com/saphelp_nw04/helpdata/en/56/d5b54020c6792ae10000000a155106/content.htm
    BPM:
    /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit
    Working with acknowledgements
    regards

  • Exception handling in ucm

    hi,
    I have created a custom component that has a service which invokes my custom java methods. I would like to redirect to two error pages depending on the exception thrown by the java method? How exception handling is done in UCM. I see a text box called error messages while creating the service and service actions. But that message is not printed when my java method throws application specific exceptions.
    Is there a way to handle the exception at Service configuraration / UI side and redirect to two different meaningful error pages dependinf upon the thye of exception
    Thanks,
    Siva

    Hi Jayakrishna,
    In General , there are non execptions in BAPIs, because of the reason, that the exception raised in a SAP envoronment may not mean anything for a non SAP initiator. All the exception situations would only fill the return table(TYpe BAPIRET2 or something like that). If you read that table after the call to the bapi, you can understand what has gone wrong.
    Regards,
    Ravi

  • What King of exception handling is done in OA framework code?

    Hi All,
    I am not a core java person but have to do some OA framework code changes.Wanted to know what kind of exception handling is done in OAF codes?
    I was looking as the seeded oracle controllers and dont see any try catch blocks.
    can anyone guide me?

    OAF java based framework, hence exception handling is similar to how its done in core java. I would advuce to better go through exception handling concepts of core java.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                   

  • BPM Exception Handling

    I am trying to test my Deadline and Exception handling.But it is not at all working. I will explain what I have done, please guide me where I am going wrong.
    1) Block Step. Properties --- Exception == ERROR1
    2)Switch Step . Success Branch . Send Step. with a Transport Response. And I am sending to the Mail adapter. And in directory I have provided the WRONG URL FOR THIS Mail.
          Otherwsie Branch. Send step, sending to a File.
    3)Dead Lock Branch : Having a Control Step.
                  Properties
                   Action : Throw Exception
                   Exception: ERROR1
    4) Exception Branch.
               Properties
                    Exception Handler : ERROR1
          Send Step : Send a Message to  a File (
    Result
    I am Seeing a Clock in my SXMB_MONI OUTBOUND_Status column, because I am expecting a TRANSPOT Response, and this going to never happen, so I thought the Deadline monitor will wakeup after 1 minute interval and my Exception branch has to Trigger, but it has never triggered my Deadline branch aswell as my Exception Branch.
    WE are in XI SP 12.  We dont have CCMS installed yet, even ALERT management is not installed.
    Please guide me.
    Thanks.

    Hi Anand,
    I looked into the Transaction SWI2_DEAD and I dont see any listings there.
    I am executing 1 Minute deadline Monitoring and from here firing an exception Branch, for my Asynchronous Scenario.
    So definitely after a minute , the DeadLine Branch should have been fired. But it didnot take place.
    In the mean time I have located an OSS notes OSS note 829921 And I am awaiting my Basis team to apply this note.
    symptom
    If the execution of an asynchronous method ends with a "system error" or "application error", the work item is not set to the 'ERROR' status.
    Other terms
    Reason and Prerequisites
    This problem is caused by a program error.
    Solution
    Implement the correction instructions.
    Note the following manual changes that must be implemented BEFORE you use SNOTE to implement the corrections:
    1. Make sure that the SET_EXECUTION_INTERRUPTED method of the CL_SWF_RUN_RESULT class has the following parameters:
    a) IM_CODE, Importing, Optional, Type SWO_RETURN, default Value 0000
    b) IM_ERRORTYPE, Importing, Optional, Type SWO_ERRTYP, Default Value 0
    Note the following manual changes, which you must carry out AFTER you have implemented the corrections:
    1. The M_EXECUTION_INTERRUPTED attribute type of the CL_SWF_RUN_RESULT class must be changed to EXECUTION_INTERRUPTED.

  • UTL file exception handling oracle 11g

    We use oracle 11g
    We use UTL file and exception handling in many place. Thanks in advance.
    We have many utl program and we are writing same exception handling code ,copy and paste .
    It is possible to create new UTL exception procedure and call it.
    I am not sure how to write generic UTL exception procedure and reuse the same.
    I am learning oracle etl files method.
    Please advise.
    sample program 1 :
    DECLARE
    fileHandler UTL_FILE.FILE_TYPE;
    BEGIN
    fileHandler := UTL_FILE.FOPEN('test_dir', 'test_file.txt', 'W');
    UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
    UTL_FILE.FCLOSE(fileHandler);
    EXCEPTION
    when utl_file.invalid_path then
    raise_application_error(-20001,
    'INVALID_PATH: File location or filename was invalid.');
    when utl_file.invalid_mode then
    raise_application_error(-20002,
    'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
    when utl_file.invalid_filehandle then
    raise_application_error(-20002,
    'INVALID_FILEHANDLE: The file handle was invalid.');
    when utl_file.invalid_operation then
    raise_application_error(-20003,
    'INVALID_OPERATION: The file could not be opened or operated on as requested.');
    when utl_file.read_error then
    raise_application_error(-20004,
    'READ_ERROR: An operating system error occurred during the read operation.');
    when utl_file.write_error then
    raise_application_error(-20005,
    'WRITE_ERROR: An operating system error occurred during the write operation.');
    when utl_file.internal_error then
    raise_application_error(-20006,
    'INTERNAL_ERROR: An unspecified error in PL/SQL.');
    when utl_file.invalid_filename then
    raise_application_error(-20010, 'The filename parameter is invalid.');
    WHEN OTHERS THEN
    IF UTL_FILE.IS_OPEN(fileHandler ) THEN
    UTL_FILE.FCLOSE (fileHandler );
    END IF;
    RAISE;
    END;
    How to write generic procedure of utl exception handling ?
    please advise.
    create or replace procedure sp_utl_exception
    begin
    when utl_file.invalid_path then
    raise_application_error(-20001,
    'INVALID_PATH: File location or filename was invalid.');
    when utl_file.invalid_mode then
    raise_application_error(-20002,
    'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
    when utl_file.invalid_filehandle then
    raise_application_error(-20002,
    'INVALID_FILEHANDLE: The file handle was invalid.');
    when utl_file.invalid_operation then
    raise_application_error(-20003,
    'INVALID_OPERATION: The file could not be opened or operated on as requested.');
    when utl_file.read_error then
    raise_application_error(-20004,
    'READ_ERROR: An operating system error occurred during the read operation.');
    when utl_file.write_error then
    raise_application_error(-20005,
    'WRITE_ERROR: An operating system error occurred during the write operation.');
    when utl_file.internal_error then
    raise_application_error(-20006,
    'INTERNAL_ERROR: An unspecified error in PL/SQL.');
    when utl_file.invalid_filename then
    raise_application_error(-20010, 'The filename parameter is invalid.');
    WHEN OTHERS THEN
    IF UTL_FILE.IS_OPEN(fileHandler ) THEN
    UTL_FILE.FCLOSE (fileHandler );
    END IF;
    RAISE;
    end;

    Mahesh Kaila wrote:
    Hello,
    Common procedure to log exception in log file
    create or replace procedure sp_utl_exception (log_dir varchar2, log_file varchar2, exception_msg varchar2)
    is
    hnd_file   UTL_FILE.file_type;
    begin
    hnd_file := UTL_FILE.fopen (log_dir, log_file, 'A');
    UTL_FILE.put_line (hnd_file, exception_msg);
    UTL_FILE.fclose (hnd_file);
    exception
    when others
    then
    raise;
    end;
    Very poor implementation.
    a) Absolutely no need for that exception handler in there. It should be removed.
    b) As it's a procedure for logging exceptions relating to UTL_FILE, it would seem error prone to be logging the errors with UTL_FILE. For example, what is it supposed to do if the exception is raised because of lack of disk space in those file locations? How is it going to write out the exception with the disk full? Also, if the exception handler is used by multiple processes, then only 1 process at a time can access the log file to write it's exceptions, so it doesn't scale well. Better logging is done by having an autonomous transaction procedure that writes log/trace messages to dedicated table(s). That also means that the logs etc. can be viewed, as appropriate, from any client using SQL (either manually or through a application written to view logs etc.), rather than requiring physical/remote access to the server o/s to go and view the contents of the file, which in itself could lock the file and prevent any process from writing further logs whilst it's being used.

  • Oracle exception handling

    is this right way do to coding and exception handling
    2 cases
    if we get overwrite = 1 then update else insert.
    I am not sure i have handled proper user defined exception.
    Please advise.
    create or replace procedure get_rc1(in_file_name in VARCHAR2, overwrite number) is
    o_error_number number;
    err_exception EXCEPTION;
    begin
    IF overwrite = 1 THEN
    UPDATE store
    SET uploaded_by = 'ram'
    WHERE file_name = in_file_name;
    dbms_output.put_line ('update');
    IF (SQL%ROWCOUNT > 0)
    THEN
    history_log(p_key_id => '123',
    desc => 'v_his_desc',
    key_word => 'p1' ,
    ser_id => 'ram',
    status => NULL,
    p_error_number => o_error_number);
    IF o_error_number <> 0
    THEN
    RAISE err_exception;
    END IF;
    END IF;
    ELSE
    dbms_output.put_line ('insert');
    INSERT
    INTO store
    ID
    ,FILE_LENGTH
    ,FILE_NAME
    ,DOCUMENT_IMAGE
    ,UPLOADED_DATE
    ,UPLOADED_BY
    ,MIME_TYPE
    VALUES
    1234,
    12345,
    '123',
    NULL ,
    sysdate,
    '[email protected]',
    'balaji'
    IF (SQL%ROWCOUNT > 0)
    THEN
    history_log(p_key_id => '123',
    desc => 'v_his_desc',
    key_word => 'p2' ,
    ser_id => 'ram',
    status => NULL,
    p_error_number => o_error_number);
    IF o_error_number <> 0
    THEN
    RAISE err_exception;
    END IF;
    END IF;
    END IF;
    -- maintaining the history and setting the message
    commit;
    exception
    when others then
    dbms_output.put_line ( sqlerrm);
    END;

    Hi,
    user4485803 wrote:
    is this right way do to coding and exception handling
    2 cases
    if we get overwrite = 1 then update else insert.
    I am not sure i have handled proper user defined exception.
    Please advise.When posting formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    create or replace procedure get_rc1(in_file_name in VARCHAR2, overwrite number) is
    o_error_number number;
    err_exception EXCEPTION;
    begin
    IF overwrite = 1 THEN
    UPDATE store
    SET uploaded_by = 'ram'
    WHERE file_name = in_file_name;
    dbms_output.put_line ('update');
    IF (SQL%ROWCOUNT > 0)
    THEN
    history_log(p_key_id => '123',
    desc => 'v_his_desc',
    key_word => 'p1' ,
    ser_id => 'ram',
    status => NULL,
    p_error_number => o_error_number);
    IF o_error_number <> 0Did you mean IF o_error_number 1= 0
    ?  This site doesn't like to display the &lt;&gt; inequality operator.  Use the equivalent != operator when posting here.
    THEN
    RAISE err_exception;
    END IF;
    END IF;
    ELSE
    dbms_output.put_line ('insert');
    INSERT
    INTO store
    ID
    ,FILE_LENGTH
    ,FILE_NAME
    ,DOCUMENT_IMAGE
    ,UPLOADED_DATE
    ,UPLOADED_BY
    ,MIME_TYPE
    VALUES
    1234,
    12345,
    '123',
    NULL ,
    sysdate,
    '[email protected]',
    'balaji'
    IF (SQL%ROWCOUNT > 0)
    THEN
    history_log(p_key_id => '123',
    desc => 'v_his_desc',
    key_word => 'p2' ,
    ser_id => 'ram',
    status => NULL,
    p_error_number => o_error_number);
    IF o_error_number <> 0
    THEN
    RAISE err_exception;
    END IF;
    END IF;
    END IF;
    -- maintaining the history and setting the message
    commit;
    exception
    when others then
    dbms_output.put_line ( sqlerrm);
    END;That looks like the correct way to raise an error.
    If you don't have an EXCEPTION section, then PL/SQL will display an error message, including the line number where the error was detected.  If the error occurred deep in a series of called procedures, the error message will include information about what procedures were called, and where.  All of that is potentially very important information, and all of that is lost if you have your own EXCEPTION handler, like the one above.  Acutally, it would be better to call the code above a exception *hider* , not a handler, because all it's really doing is hiding details about any error.
    Use an EXCEPTION sedction only when you can improve on the default exception handling.  Even then, you rarely want to use WHEN *OTHERS* ; you want to check for specific errors.  For example...
    EXCEPTION
    WHEN err_exception
    THEN
    END;
    If any exception other than err_exception occurs, this will not hide it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • When installing Adobe Reader XI WSUS connection failed

    When we install any version of Adobe reader XI on a computer  (We got over 1000 installations) we loose WSUS server connection for this computer. This doesnt happen with reader X This happen with our English and French distribution of Windows 7 EVERY

  • Setting a line background color in a GridBagLayout

    I have a Gridbaglayout where I'm adding objects a runtime. I need to be able to set the background color for the line to red on a specific event. I can set the labels etc for the line but the spaces between them stay grey. // code in loop to add comp

  • Error at the time of dep. run

    Dear All, I have assigned the cost centers in the asset master & also create the Dep. GL accounts as a cost element but the problem arise when i run the depreciation. At the time of running the depreciation run, we are getting the following error, "G

  • Dynamic menu not appear in level in jdeveloper 11.1.1.6

    jdeveloper  11.1.1.6.0 version 64 i create menu from task flow and this menu have 3 level 0 ,1 ,2 after creat template and navigation pan and nod stamp and navigation item when i set level to navigation pan to  0 it  appear and when set it  1 it not

  • How updating Safari from 2.0 to 2.04 when OS X 10.4.8 is already installed?

    After a freezing Safari I tried installing Safari 2.0 from Tiger 10.4 DVD (System/Installations/Packages/Safari.pkg). It was very fast and ... unsuccessful. The installation I guess compared the 2.0 files with the already installed but not proper wor