Exception handling in calling procedure

Hi,
i have a package where currently am making calls to private procedures from public procedure.
and the senario is:-
create package body p_tst
is
ex_failed exception;
-- this is private proc
procedure p_private
is
begin
raise ex_failed;
exception
when ex_failed
then
raise;
end p_private;
procedure p_public
is
begin
-- nomaking call to private
-- procedure
p_private;
-- here i need to catch
-- the raised exception
-- passed from the called
-- procedure
when ex_failed
end p_public;
end;
basically i want to catch the exception being passed from called procedure to calling procedure, and raise the same exception in calling procdure.
is it possible to catch the same exception in the calling procedure?

Yes, you can catch the same exception in the calling procedure, exceptions are propagated to the caller if they are not handled in the called procedure.
Is this what you are trying to do?
CREATE OR REPLACE PACKAGE p_tst
AS
   PROCEDURE p_public;
   ex_failed   EXCEPTION;
END;
CREATE OR REPLACE PACKAGE BODY p_tst
IS
   PROCEDURE p_private
   IS
   BEGIN
      RAISE ex_failed;
   END p_private;
   PROCEDURE p_public
   IS
   BEGIN
      p_private;
   EXCEPTION
      WHEN ex_failed
      THEN
         DBMS_OUTPUT.put_line ('error');
   END p_public;
END;
SQL> set serveroutput on;
SQL> exec p_tst.p_public;
error
PL/SQL procedure successfully completed.

Similar Messages

  • Never implemented exception handling  in Stored Procedures

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

  • Need of exception handler in calling function, isn't that weird???

    Hi,
    I have written a function as follows
    public String fetchName(String query) throws Exception
              stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery(query);
              rs.next();
              return (rs.getString(1));
    I've handled the for exceptions here using "throws Exception". Inspite of that when i call it from other function and in that funtion no exception need to be handled, compiler gives errror.
    Following is the calling funtion
    public String checksubAction(String action)
              String retValue=" ";
    String query="";
              query = "select Title from dbo.Folder where Folder_Id="+folderId;
              retValue = dataBaseObj.fetchName(query);                                        
    but when i write it in try-catch block, no errror is given.
    Why is it that inspite of handling exception(s) in the called function, we need to handle them in calling functions.

    No you have not handled the exception. Your code say "fetchName" does NOT handle exceptions of type "Exception", the calling method should be aware of this, and handle that type of exception.
    The Java Tutorial: Essential Java Classes: Handling Errors Using Exceptions
    (Please when declaring a method can throw exceptions, be specific, i.e. throw SQLException in this case)

  • Exception Handling when calling a PHP Webservice

    I followed a great tutorial on setting calling PHP services from ABAP ([Accessing arbitrary databases from within ABAP using a PHP data hub and web services|Accessing arbitrary databases from within ABAP using a PHP data hub and web services]).   Unfortunately I'm getting occassional CX_AI_SYSTEM_FAULT exceptions and I don't know how to handle them gracefully.
    I'm calling the web service ABAP code from an RFC function which for some reason doesn't allow TRY/CATCH statements (I get a message saying "During RFC/update, no exception classes can be used".) 
    I'd be happy enough just to ignore the error since it's currently dumping users out of order entry.
    To make matters more complicated, I can't TRY/CATCH my own RFC since I'm calling it from GuiXT
    I'd really appreciate help on this; I'm pretty stumped.
    Thanks,
    Lee

    Well, to answer my own question, I found an ugly workaround.
    Change attribute from "Remote-enabled" to "Normal Function", add the TRY/CATCH logic.  Then call this function from the "real" RFC.
    Off to program like it's 1979!
    Lee

  • Configuring Exception Handling CAF Guided Procedure

    Hi everybody,
    which types of callable objects can define exceptions?  I found an tutorial where Background Callable Object and External Service (BAPI/RFC) can define exceptions, but is it also possible for composite services or WebServices?
    And how could I configure a WebService as a background Callable Object?
    Thanks!
    Stefan

    Hi Stefan,
    WebService Callable Object defines exception for sure! It has to be define in the WSDL though.
    To define a WS Callable Object, you can have a look at <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/44/4758351fcb1193e10000000a155369/frameset.htm">SAP Help</a>
    Hope this helps,
    David

  • Trying to raise a named exception, in an exception handler

    We have some converted code that I'm trying to fix. Usually, the code isn't modularized, and is an EXCEPTION named at the top of a package gets raised, the code falls into the EXCEPTION handler and everything works fine.
    create or replace package tmp_pg
    as
      procedure main;
    end tmp_pg;
    create or replace package body tmp_pg
    as
      x_datacheck EXCEPTION;
      wk_num      NUMBER(1);
    begin
      wk_num := 1;
    exception
      when x_datacheck then
        raise_application_error(-20500, 'datacheck');
      when others then
        raise;
    end tmp_pg;
    /The problem we're seeing for some of the code, is that inside the private methods in the PACKAGE BODY, the EXCEPTION defined at the PACKAGE BODY-level is raised, which results in a "ORA-06510: PL/SQL: unhandled user-defined exception" error:
    create or replace package body tmp_pg
    as
      x_datacheck EXCEPTION;
      wk_num      NUMBER(1);
      procedure main is
      begin
        if wk_num = 1 then
          raise x_datacheck;
        end if;
      end main;
    begin
      wk_num := 1;
    exception
      when x_datacheck then
        raise_application_error(-20500, 'datacheck');
      when others then
        raise;
    end tmp_pg;So the code above compiles, but fails at runtime. I tried both of the following, which doesn't work:
    - adding an exception handler in the procedure MAIN( ), which raises X_DATACHECK
      procedure main is
      begin
        if wk_num = 1 then
          raise x_datacheck;
        end if;
      exception
        when x_datacheck then
          raise x_datacheck
      end main;- adding a locally defined exception handler in MAIN( ), raising that, which in turn raises X_DATACHECK from the exception handler in MAIN( )
      procedure main is
        lx_datacheck EXCEPTION;
      begin
        if wk_num = 1 then
          raise lx_datacheck;
        end if;
      exception
        when lx_datacheck then
          raise x_datacheck;
      end main;Does anyone have another solution I could try?
    Thanks,
    --=Chuck

    This block of code:
    begin
      wk_num := 1;
    exception
      when x_datacheck then
        raise_application_error(-20500, 'datacheck');
      when others then
        raise;
    end tmp_pg;executes only once, the first time the package is accessed in a session. Since it does not raise x_datacheck, the exception block will not catch it. When x_datacheck is raised in main, the initialisation section has already finished running, so main needs to be the one catching and re-raising. Something like:
    SQL> create package tmp_pg as
      2    procedure main;
      3  end tmp_pg;
      4  /
    Package created.
    SQL> create or replace package body tmp_pg as
      2    x_datacheck EXCEPTION;
      3    wk_num      NUMBER(1);
      4
      5    procedure main is
      6    begin
      7      if wk_num = 1 then
      8        raise x_datacheck;
      9      end if;
    10    exception
    11      when x_datacheck then
    12        raise_application_error(-20500, 'datacheck');
    13    end main;
    14
    15  begin
    16    wk_num := 1;
    17  end tmp_pg;
    18  /
    Package body created.
    SQL> exec tmp_pg.main;
    BEGIN tmp_pg.main; END;
    ERROR at line 1:
    ORA-20500: datacheck
    ORA-06512: at "OPS$ORACLE.TMP_PG", line 12
    ORA-06512: at line 1This would work even if some procedure called by main raised x_datacheck. If you want the initialisation section to catch x_datacheck, then either it needs to raise it itself, or call a procedure that raises x_datacheck.
    John
    John

  • Simple exception handling

    Hello,
    I am trying to figure out how to add exception handling to a procedure so that I can save the error message into a table. Here is the simple procedure that calls another procedure, and the error is always due to some problem in the subprocedure, which will continue to occur periodically:
    (var1 integer, var2 integer)
    is
    begin
    subprocedure (var1, var2);
    commit;
    end;
    Here is my guess for adding exception handling:
    (var1 integer, var2 integer)
    is
    begin
    subprocedure (var1, var2);
    exception
    insert into errortable (col1) values (error_message);
    commit;
    end;
    I currently have the java setup with error handling using the try-catch system which displays the oracle error message in the tomcat window.
    How do I setup the oracle procedure to send my user-defined error message to the tomcat window?
    Any suggestions are greatly appreciated. TIA.

    raise_application_error will automatically end the transaction by calling ROLLBACK.
    So you may have to COMMIT before calling raise_application_error to perserve your insert.
    But i see you are writing into errorlog. The best way to do it is have a seperate procedure, define it as a autonomous transation and call it in your exception block. Something like this
    create or replace procedure log_error(pErrorMessage varchar2, pDate date)
    as
      pragma autonomous_transaction;
    begin
      insert into errorlog values (pErrorMessage, pDate);
      commit;
    end;
    /in your exception block do this.
    EXCEPTION
    WHEN OTHERS THEN
    log_error(dbms_utility.format_error_stack,SYSDATE)---Insert Into your Table--
    raise_application_error(-20101, dbms_utility.format_error_stack); ---Raise application error back to Java App---

  • How to implement Exception Handling error in IDoc to File and RFC to File

    Hi,
    We are implementing the two below scenarios :
    1. IDOC to File
    2. RFC to File
    We have to implement the Exception Handling for the above two cases. Kindly could you provide the inputs to implement the Exception Handling for the above two cases.
    Please provide the precious inputs to implement this.
    Thanks,
    Ramesh

    Hi Ramesh,
    The exception handling for idocs
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/6b7f1543d711d1893e0000e8323c4f/frameset.htm
    Exception handling in File to IDoc Scenario
    For RFCs
    Re: Passing SAP Exceptions to a sync SOAP Call
    Error Handling when using RFC
    Exception Handling while Calling RFC - BPM
    handle exceptions in remote function modules
    Regards,
    Prateek

  • Exception Handling in packages called from forms

    I am running 10g forms that have many calls to packages/procedures in the database. I am seeing hanging processes on the web server (even after forms processes are stopped) and 1 of the causes Oracle listed was not having proper exception handling in the procesdures. Do I need to add an Exception (' when others then null') to my package specs to handle this?

    "Do I need to add an Exception (' when others then null') to my package specs to handle this? "
    That will hide the problem not handle it. You really need is to find out where the code is failing...
    There is a method for logging message for debugging here...
    http://oracle-developer.net/display.php?id=424
    An another which is less good for a live system (the one above lets you set different levels of importance for logs messages and can be turned on or off for each user) but looks easier to implement in case you might be in a hurry...
    Re: Zdebug -- Download a Forms debugging message tool

  • Exception handling in Custom Login procedure

    Hi,
    I have a custom login procedure. Now instead of handling the possible exceptions in a custom way too, I want to use the syntax of the exception handling API (probably the one in the PDK) the default login procedure uses. Can someone point me to the values the default login procedure uses?
    Thanks, Tony

    Tony,
    The default login page (the source of which is now unwrapped in 3.0.0), uses the following snippet of code to report the errors:
    if p_error then
    wwerr_api_error_ui.show_inline_html;
    end if;The errors are stacked when the ls_login procedure is executed, and the next time the login page is called up, it just displays the stacked errors.

  • Resume procedure execution after Exception Handler

    Hi -- Can anyone tell me how to resume execution of my procedure if and when I fall into the Exception Handler?
    I'm in a for/loop and i want to move to the next record after falling into the exception handler.
    Thanks,
    ~Christine

    It's just a scoping issue...
    BEGIN
        FOR r IN ( SELECT ... FROM whatever ) LOOP
           BEGIN
               --  do stuff
           EXCEPTION
                 WHEN others THEN
                      log_error(SQLERRM);
           END;
         END LOOP;
    END;
    /If you're using BULK processing you may want to check out %BULK_EXCEPTIONS.
    Cheers, APC

  • Calling EJBs from Global Exception Handler

    Hi, I'm using Weblogic Workshop 8.1.4.
    I have a JPF which calls a EJB to set a lock flag (to prevent the JPF being executed twice at the same time.)
    I want to reset the lock flag in the global exception handler, however, if I call an EJB (Entity or Session) in a perform node in the exception handler, I get a NullPointerException.
    Is this because it's being called in the exception handler? Is there any way to work around this (without building a POJO which does all the persistance logic and SQL calling manually?)
    Thanks.

    You can redirect stdout to wherever you want by using
    System.setOut(PrintStream out). Also, you can give
    printStackTrace a PrintStream.
    hth,
    mI think to solve this problem you should call System.setErr(PrintStream err);

  • Environment.Exit hangs when called from an application domain exception handler

    I've implemented a handler for exceptions not thrown in the main GUI thread of my C# WinForms application, as follows:
        AppDomain.CurrentDomain.UnhandledException  += OnUnhandledExceptionThrown;
    This handler is called from a background thread. The last statement in this handler is a call to
    Environment.Exit with the application exit code. However, the application hangs in this call. From within Visual Studio, it hangs and I'm unable to break the application; I have to use Task Manager to terminate Visual Studio. Environment.Exit
    works fine when called from the unhandled exception handler for the GUI thread. Is there a better way to terminate the application in the context of an unhandled exception thrown by a background thread?

    Are you just trying to avoid a crash? Environment.Exit can cause deadlocking if exiting in the wrong kind of scenario; if you're just trying to avoid a crash, use
    GetCurrentProcess with
    TerminateProcess to terminate your own process.  It skips the notification phases that Environment.Exit uses which prevents the common deadlock scenarios.
    WinSDK Support Team Blog: http://blogs.msdn.com/b/winsdk/

  • Global exception handler not being called

    Hi,
    I have a wli process that has a global excepton handler. One of the controls throws a NullPointerException but it is not being handled by the group exception handler nor the global exception handler.
    Does anyone have any idea what may be causing this behaviour?
    Thanks,
    Dale

    I have discovered that using -memalign=Ns with N greater than 1 does not work for me. For example, if I remove a VME card from the system and try to use an unsigned short pointer to access a 16-bit register in the card's vacated VME address space, my signal handler gets called when I compile the code with N=1, but for any other N, my handler is ignored and my program cores.
    Unfortunately, using N=1 causes other code that works with higher N to fail. I have one VME card where I need to access a register as a 16-bit read. The code the compiler generates to access the unsigned short pointer value results in two single-byte load instructions - this causes the device to cry foul and as a result, the driver raises SIGBUS, which my program handles. For higher N, the compiler generates one two-byte load instruction, and the device is happy to send back the data.
    So it would appear there is some kind of problem with -xmemalign=Ns for N > 1. It seems like the SIGBUS handler typically imployed by the compiler to handle the misalignment problems when -xmemalign=Ni is used is being invoked.
    Any other ideas?

  • 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

Maybe you are looking for