Populating OUT parameters when TOO_MANY_ROWS exception is thrown

When I was trying to write code to test out today's PL/SQL challenge quiz, the behavior appears to depend on the table being queried. I can't figure out what attribute of the table drives the behavior (or if there is a different explanation for the behavior).
The quiz is testing what happens when a procedure does a SELECT INTO an OUT parameter and a TOO_MANY_ROWS exception is thrown. The intent is to show that even though the behavior is technically undefined, what actually happens is that the OUT parameter is populated with the first row that is selected (obviously, you would never write code that depends on this behavior-- this is solely an academic exercise). The demonstration code works as expected
CREATE TABLE plch_emp ( emp_name VARCHAR2(100) );
INSERT INTO plch_emp VALUES ('Jones');
INSERT INTO plch_emp VALUES ('Smith');
COMMIT;
CREATE OR REPLACE PROCEDURE plch_get
  (out_name OUT plch_emp.emp_name%TYPE) IS
BEGIN
  SELECT emp_name
  INTO out_name
  FROM plch_emp
  ORDER BY emp_name;
EXCEPTION
  WHEN OTHERS THEN
    dbms_output.put_line('A:' || out_name);
END;
What will be displayed after executing the following block:
DECLARE
  l_name plch_emp.emp_name%TYPE;
BEGIN
  plch_get(l_name);
  dbms_output.put_line('B:' || l_name);
END;
/and outputs
A:Jones
B:JonesWhen I replicate the logic while hitting the EMP table, the PLCH_EMP table, and the newly created EMP2 table, however, I get different behavior for the EMP and EMP2 tables. The procedure that queries PLCH_EMP works as expected but the OUT parameter is NULL when either EMP or EMP2 are created. Any idea what causes the behavior to differ?
select *
  from v$version;
create table emp2
as
select *
  from emp;
create or replace procedure p1( p_out out varchar2 )
is
begin
  select emp_name
    into p_out
    from plch_emp
   order by emp_name;
exception
  when others then
    dbms_output.put_line( 'P1 A:' || p_out );
end;
create or replace procedure p2( p_out out varchar2 )
is
begin
  select ename
    into p_out
    from emp
   order by ename;
exception
  when others then
    dbms_output.put_line( 'P2 A:' || p_out );
end;
create or replace procedure p3( p_out out varchar2 )
is
begin
  select ename
    into p_out
    from emp2
   order by ename;
exception
  when others then
    dbms_output.put_line( 'P3 A:' || p_out );
end;
declare
  l_ename varchar2(100);
begin
  p1( l_ename );
  dbms_output.put_line( 'P1 B:' || l_ename );
  p2( l_ename );
  dbms_output.put_line( 'P2 B:' || l_ename );
  p3( l_ename );
  dbms_output.put_line( 'P3 B:' || l_ename );
end;
SQL> select *
  2    from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>
SQL> create table emp2
  2  as
  3  select *
  4    from emp;
Table created.
SQL>
SQL> create or replace procedure p1( p_out out varchar2 )
  2  is
  3  begin
  4    select emp_name
  5      into p_out
  6      from plch_emp
  7     order by emp_name;
  8  exception
  9    when others then
10      dbms_output.put_line( 'P1 A:' || p_out );
11  end;
12  /
Procedure created.
SQL>
SQL> create or replace procedure p2( p_out out varchar2 )
  2  is
  3  begin
  4    select ename
  5      into p_out
  6      from emp
  7     order by ename;
  8  exception
  9    when others then
10      dbms_output.put_line( 'P2 A:' || p_out );
11  end;
12  /
Procedure created.
SQL>
SQL> create or replace procedure p3( p_out out varchar2 )
  2  is
  3  begin
  4    select ename
  5      into p_out
  6      from emp2
  7     order by ename;
  8  exception
  9    when others then
10      dbms_output.put_line( 'P3 A:' || p_out );
11  end;
12  /
Procedure created.
SQL>
SQL> declare
  2    l_ename varchar2(100);
  3  begin
  4    p1( l_ename );
  5    dbms_output.put_line( 'P1 B:' || l_ename );
  6
  7    p2( l_ename );
  8    dbms_output.put_line( 'P2 B:' || l_ename );
  9
10    p3( l_ename );
11    dbms_output.put_line( 'P3 B:' || l_ename );
12
13  end;
14  /
P1 A:Jones
P1 B:Jones
P2 A:
P2 B:
P3 A:
P3 B:
PL/SQL procedure successfully completed.Justin

Billy  Verreynne  wrote:
So we can then reasonably assume that the test or environment itself somehow interferes with the results? After all, the very same cursor is executed and the same PL/SQL engine uses that cursor interface.Clearly, there is something in my environment that is wonky. It just bugs me that I can't figure out what that variable is.
Your test was done as a single anonymous PL/SQL block. Which means each proc that was called referenced the same variable/memory - are there perhaps PL/SQL optimisation enabled for the database or session? Or any other settings that could influence the test? Have you tried calling the procedures directly from SQL*Plus using a bind var and not via an anon block and a local var in that block?I have. And the results were the same
SQL> var ename varchar2(100);
SQL> exec p1( :ename );
P1 A:Jones
PL/SQL procedure successfully completed.
SQL> exec p2( :ename );
P2 A:
PL/SQL procedure successfully completed.
SQL> exec p3( :ename );
P3 A:
PL/SQL procedure successfully completed.
As a sanity test - what happens when proc P3 for example is changed to a catersian join/union of emp2 and plch_emp? Do the test results change? Or you can change it as follows:
SQL> ed
Wrote file afiedt.buf
  1  create or replace procedure p5( p_out out varchar2 )
  2  is
  3  begin
  4    --// force a value into p_out using a successful fetch
  5    select emp_name
  6      into p_out
  7      from plch_emp
  8     where rownum = 1;
  9    --// force an error and determine if p_out was overwritten
10    select ename
11      into p_out
12      from emp2
13     order by ename;
14  exception
15    when others then
16      dbms_output.put_line( 'P5:' || p_out );
17* end;
18  /
Procedure created.
SQL> exec p5( :ename );
P5:Jones
PL/SQL procedure successfully completed.
Of course, you can also put this one down to using an operating system like Windows as a poor database server and not as a magnificent client gaming platform... Well, sure. But you can probably only play World of Warcraft so long before you need to write some PL/SQL.
Justin

Similar Messages

  • How can the eclipse debugger break in the code when an exception is thrown

    Is there a way in eclipse to break into the bebugger when an exception is thrown in debug mode like Visual Studio 2003 or 2005?
    Thanks

    For 3.x, select "Add Java Exception Breakpoint" from the "Run" menu.
    Check "Caught" to break even if your code handles the exception, "Uncaught" to break when your code doesn't handle the exception.

  • How to fail messsages when timeout exception is thrown in BPM?

    Hi
    In my BPM, if the time out exception is thrown in BPM, in SXMB_MONI, all the inbound messages' staus is 'processed sucessfully' ? How can I make the message fail?  With a red flag  or anything indicating exception?
    In my design I used deadline branch to throw time out exception.And in the exception branch I used control step to cancel the process.

    Hi,
    In my design I used deadline branch to throw time out exception.And in the exception branch I used control step to cancel the process
    If this is what you have designed then increasing the timeout using the above mentioned blogs doesn't seem to be logical:) (BPM will throw the error when the deadline is meet....can't understand how by increasing timeout will help you)....instead of increasing the timeout you can increase the time limit mentioned in the deadline branch itself to ensure that your message will be processed in that particular time limit.
    Since you have reached the timeout it means that desired message processing has failed so better you raise an alert instead of going for a increase in timeout....increasing timeout decreases performance...
    Regards,
    Abhishek.

  • Detecting when exception was thrown using custom class loader

    Hello all,
    I would like to implement the solution described here - http://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java - that uses custom class loader in order to detect when an Exeption thrown somewhere in the JVM hosting my app, please note that exceptions might be thrown from 3rd party jars the app is using. So, thanks to help I got from another post, I've managed to code the custom class loader. My question is how can the class loader wrap the original exception, as the methods in ClassLoader deals with classes, not instances. So where should I set the original exception?
    Thanks!
    Edited by: user9355666 on Sep 28, 2010 10:48 PM

    user9355666 wrote:
    I think I'm missing something fundumental, forgive me for being slow...
    This is what I did so far. For the exception wrapper I made a simple class extens Exception that recieve Exception in its ctor and store it. I also subclassed ClassLoader and override its loadClass(). I've registered it as the system classloader. My thinking was to check in that point that if the requested class is instance of Exception and if yes, returning my wrapper class wrapping this exception. But, since loadClass() return class, how can I set in the wrapper the original exception?
    In addition, let's say 2 different places in the code throws NPE, to my understanding the classloader will load NPE only once, so how throwing the NPE in the second time can be detected?you are missing a key point. you should creating a custom implementation of the NPE class which hooks into your detection code in its constructor. from that point forward, anytime any NPE (which is your custom class) is constructed, you can detect it.

  • BPM finishes when reaching exception in loop block

    Hi everybody,
    we got a loop block in BMP. In the loop block we catch mapping errors by using an exception branch.
    What we can see is that when an exception is thrown the process steps into the exception branch an than is leaving the loop block!! So the remaining single messages are not processed!
    Is there a workaround?
    Regards Mario

    Hi Mario,
    Have you used the local correlation for block step.
    Can you please give steps you used in BPM, also try to see the below threads
    What is the use of block step in BPM? Please help!
    BPM ParforEach Loop
    BPM loop
    also,
    BPM Block step
    Using BPM (Blocks) when Incoming message has multilple rows
    Doubt in BPM
    BPM: Block Processing: ParForEach
    Regards
    Chilla

  • Why is exception not thrown in AseCommand when "Truncation error occurred"?

    In the below SQL, data is written to SOURCE and from there to TARGET.
    The DECIMAL columns in TARGET are deliberately smaller than those in SOURCE (eg a DECIMAL (12, 2) column populated from a DECIMAL (19,11) source).
    When I run this in an Query tool (eg, SqlDbx) I get the messages:
    "Truncation error occurred
    Command has been aborted"
    But when I run this using the .net Client (supplied with the Developer Edition of ASE 16.0) no exception is thrown (the INSERT fails though).  The method is AseCommand.ExecuteNonQuery().
    Is this deliberate? 
    Is this believed to be correct?
    How can I tell that a truncation error has been raised?
    Thanks
    IF OBJECT_ID ('dbo.TARGET') IS NOT NULL
      DROP TABLE dbo.TARGET
    GO
    CREATE TABLE dbo.TARGET
      S_Name_NVARCHAR NVARCHAR (50) null,
        S_RedComponent_DEC_15_6 decimal(15, 6) NULL,
        S_BlueComponent_DEC_12_2 decimal(12, 2) NULL, 
        S_GreenComponent_DEC_18_10 decimal(18, 10) NULL
    GO
    IF OBJECT_ID ('dbo.SOURCE') IS NOT NULL
      DROP TABLE dbo.SOURCE
    GO
    CREATE TABLE dbo.SOURCE
      Name_NVARCHAR      NVARCHAR (2000) NULL,
      RedComponent_DEC   DECIMAL (19,11) NULL,
      GreenComponent_DEC DECIMAL (19,11) NULL,
      BlueComponent_DEC  DECIMAL (19,11) NULL
    GO
    INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
    VALUES ('Beige', 272.195, 272.195, 244.42)
    GO
    INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
    VALUES ('Bisque', 283.305, 253.308, 217.756)
    GO
    INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
    VALUES ('Black', 0, 0, 0)
    GO
    INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
    VALUES ('BlanchedAlmond', 283.305, 261.085, 227.755)
    GO
    --Is there data to migrate?
    SELECT LEFT( S.Name_NVARCHAR,8000),S.GreenComponent_DEC,S.GreenComponent_DEC,S.GreenComponent_DEC
    FROM (
    SELECT * FROM SOURCE
    ) S
    --Yes.migrate away!
    --Next line gives a truncation error occurred in Sybase (gives a truncation error occurred in a query tool
    --but fails silently in AseCommand.ExecuteNonQuery).
    INSERT dbo.TARGET (S_Name_NVARCHAR,S_RedComponent_DEC_15_6,S_BlueComponent_DEC_12_2,S_GreenComponent_DEC_18_10)
    SELECT LEFT( S.Name_NVARCHAR,8000),S.GreenComponent_DEC,S.GreenComponent_DEC,S.GreenComponent_DEC
    FROM (
    SELECT * FROM SOURCE
    ) S
    select * from dbo.TARGET

    Hi Dave,
    I am consulting internally on this. To my understanding, this behavior is based on the ASE severity level, as returned in the TDS_EED token. AseExceptions are thrown when severity level is 11 or higher.
    Our docs are not explanatory in this regard.  Once I get clarification we will provide something in the form of wiki or KBA or doc bug to further explain the detail.  Apologize for the delay and problems this caused. I guess since the command is aborted by ASE, therefore no insertion occurs, even though ASE indicates truncation occurs prior - makes this confusing.
    The message severity, etc is controlled by ASE and the client is just following suit according to the TDS spec. Its just lacking in the client docs. This can be remedied.
    ASE does provide the option to allow truncation and not abort.  It's a set command:
    Enter a query:
    1 > set arithabort numeric_truncation off
    Enter a query:
    1 > INSERT dbo.TARGET (S_Name_NVARCHAR,S_RedComponent_DEC_15_6,S_BlueComponent_DEC_12_2,S_GreenComponent_DEC_18_10) SELECT LEFT( S.Name_NVARCHAR,8000),S.GreenComponent_DEC,S.GreenComponent_DEC,S.GreenComponent_DEC FROM (SELECT * FROM SOURCE
    ) S
    4 rows Affected.
    Notice though ASE does NOT send truncation message. This is when it is well known and accepted to insert and truncate the numeric data.
    Cheers,
    -Paul

  • Exception is thrown when creating bean

              Hi, I have some questions about transaction.
              In my case, i call a stateful session bean through the stateless session bean.
              When the bean is created, following exception is thrown
              "javax.transaction.TransactionRolledbackException: Current server is the coordinator
              and transaction is not found. It was probably rolled back and forgotten already."
              The transaction attribute of the stateless session bean is "Required" and the
              one of stateful session bean is "NotSupported".
              I dont know what is happening, would anyone help me please.
              Thanks
              

    Try asking this in the interest.ejb group.
              Thanks.
              "Leo" <[email protected]> wrote in message news:3f7b7c21$[email protected]..
              >
              > Hi, I have some questions about transaction.
              > In my case, i call a stateful session bean through the stateless session bean.
              > When the bean is created, following exception is thrown
              >
              > "javax.transaction.TransactionRolledbackException: Current server is the coordinator
              > and transaction is not found. It was probably rolled back and forgotten already."
              >
              > The transaction attribute of the stateless session bean is "Required" and the
              > one of stateful session bean is "NotSupported".
              >
              > I dont know what is happening, would anyone help me please.
              >
              > Thanks
              >
              >
              

  • No exception is thrown when my server socket dies

    I have a server application running on sunOS 5.7.
    To this I have both Windows and SunOS clients connected via TCP/IP. (Server built with jdk 1.2.2 and client with 1.3.0)
    If the Server socket dies an exception is thrown in the windows clients but not in the sunOS client.
    I need the exception to be thrown in the sunOS as well.
    Is there anybody who knows how to get this done?
    Thanks in advance.
    /Henrik

    You could poll the connection to see if its there.
    If you want the client to register the event then have your client create a sort of listener of your own when it connects. By 'sort of listener' I mean extend the thread class and have it check the connection is not null every n seconds. If it is null then raise the exception yourself.
    Would this do it?
    Rob.

  • Memory leak when exceptions are thrown?

    Hello,
    I'm doing a simple database connect with the JDBC Oracle 8.1.6 oci8 drivers on Solaris. It seems whenever I try to repeatedly connect to a database, and an exception is thrown, such as database not found, or wrong password, the program size grows and grows until it runs out of memory. I've narrowed it down to being the getConnection operation as the casue of this memory leak.
    Now, if I repeatedly connect successfully, there is no problem, it will run all day, but if there are exceptions thrown, memory leaks. Has anyone else encountered this?
    I'll paste a sample program below which shows the problem. Maybe someone can help???
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    public class connect extends Thread {
    private oracle.jdbc.driver.OracleDriver oDriver = new oracle.jdbc.driver.OracleDriver();
    private Connection connection;
    * Open a connection to the database
    private void connectToDB() {
    try {
    connection = DriverManager.getConnection ("jdbc:oracle:oci8:@test", "test", "test");
    connection.close();
    } catch (SQLException e) {
    e.printStackTrace();
    System.out.println("couldn't connect");
    public void run() {
    try {
    DriverManager.registerDriver(oDriver);
    } catch (SQLException e) {}
    while(true) {
    try {
    sleep(1000);
    connectToDB();
    } catch (InterruptedException ie) {}
    public static void main(String[] args) {
    connect conn = new connect();
    conn.start();
    null

    Try this:
    private void connectToDB() {
    try {
    connection = DriverManager.getConnection ("jdbc:oracle:oci8:@test", "test", "test");
    } catch (SQLException e) {
    e.printStackTrace();
    System.out.println("couldn't connect");
    finally {
    connection.close();
    null

  • Exception is thrown when Memebr roles is used in XML JAZN

    Hi,
    I am trying to use the Member roles feature in the JAZN xml file. However, Once you run the application below exception is thrown.
    08/08/31 00:33:18 oracle.security.jazn.JAZNObjectNotFoundException
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLRealmRole.init(XMLRealmRole.java:310)
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLRoleManager.init(XMLRoleManager.java:186)
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLRealm.init(XMLRealm.java:200)
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLRealmManager.init(XMLRealmManager.java:167)
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLJAZNProvider.parseDataFile(XMLJAZNProvider.java:403)
    08/08/31 00:33:18      at oracle.security.jazn.spi.xml.XMLJAZNProvider.getRealmManager(XMLJAZNProvider.java:480)
    08/08/31 00:33:18      at oracle.security.jazn.spi.GenericProvider.getRealmManager(GenericProvider.java:143)
    08/08/31 00:33:18      at oracle.security.jazn.JAZNConfig.getRealmManager(JAZNConfig.java:1014)
    08/08/31 00:33:18      at oracle.security.jazn.oc4j.JAZNUserManager.getUMType(JAZNUserManager.java:5156)
    08/08/31 00:33:18      at oracle.security.jazn.oc4j.JAZNUserManager.getUM(JAZNUserManager.java:5208)
    08/08/31 00:33:18      at oracle.security.jazn.oc4j.JAZNUserManager.<init>(JAZNUserManager.java:5245)
    08/08/31 00:33:18      at com.evermind.server.deployment.UserManagerConfig$JAZN.construct(UserManagerConfig.java:629)
    08/08/31 00:33:18      at com.evermind.server.deployment.UserManagerConfig.delegatee(UserManagerConfig.java:289)
    08/08/31 00:33:18      at com.evermind.security.IndirectUserManager.getAdminUser(IndirectUserManager.java:126)
    08/08/31 00:33:18      at com.evermind.security.IndirectUserManager.getAdminUser(IndirectUserManager.java:126)
    08/08/31 00:33:18      at com.evermind.server.XMLApplicationServerConfig.setPassword(XMLApplicationServerConfig.java:3011)
    08/08/31 00:33:18      at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:95)
    08/08/31 00:33:18      at java.lang.Thread.run(Thread.java:595)
    Can anybody help me solving this problem?!

    Younis2,
    That was the important piece of information you needed to provide ;) I get the same exception if I try to do nested roles, but it doesn't prevent my application from starting - looks like it may be a bug - suggest you post a new thread with the word BUG in the title and give a really simple test case. I was able to reproduce quite simply by using tools->embedded oc4j preferences, and then editing the jazn configuration there to nest one role inside of another.
    John

  • Problem with database adapter on plsql procedure with in/out parameters

    running BPEL 10.1.3.1 and using the database adapter on a plsql procedure with in/out parameters I get errors
    the plsql procedure:
    create or replace procedure proc_with_clob_inout_parameter(
    p_string in varchar2,
    p_clob in out clob)
    is
    begin
    p_clob := p_string;
    end proc_with_clob_inout_parameter;
    In BPEL I call this procedure. When I only assign a value to the p_string parameters (in a BPEL assign) all is well. When I also assign a value to the p_clob parameter the error occurs:
    <part name="summary">
    <summary>
    file:/ora1/app/oracle/as101.3/bpel/domains/digitaaldossier/tmp/.bpel_janb_inout_1.0_f6908ccf864581b7265c362444e88075.tmp/twee.wsdl
    [ twee_ptt::twee(InputParameters,OutputParameters) ] - WSIF JCA Execute of
    operation 'twee' failed due to: Error while trying to prepare and execute
    an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_PARAMETER2 API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    ; nested exception is:
    ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_INOUT_PARAMETER API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    Check to ensure that the API is defined in the database and that the
    parameters match the signature of the API. Contact oracle support if error
    is not fixable.
    </summary>
    </part>
    In BPEL 10.1.2.0 this isn't a problem. I tested it against a 10.2.0.1 and a 10.2.0.2 database and in both situations I get the error with BPEL 10.1.3.1 and no error with BPEL 10.1.2.0
    it appears to be a problem in the database adapter...
    anyone with the same problems and/or a solution?

    Not of any use to you, but we had exactly the same problem on Friday when we applied AS 10.1.2.2 Patchset on top of BPEL 10.1.2.0.2.
    The clob in our pl/sql proc wan't declared as in/out but for some reasons JDeveloper had created a clob on the Output Parameter type in the db partner link xsd. I removed this and it worked. This code had been untouched , and working fine, for months.
    I'll be raising an SR today.
    Rob J

  • Reg:execute procedure with in out parameters

    hi,
    what is the code to execute a procedure with in out parameters.can anyone give me an example
    thanks

    872296 wrote:
    thanks for the reply.
    i am very much new to oracle database.i need this code to put in one of my informatica mapping.
    so can you just elaborate what does 'karthick' mean?is it the name of the procedure.No, karthick is the value of the variable that is being passed into the procedure called "P" in karthicks example, then if that procedure changes the value inside, the variable will have that new value passed back out of the procedure to it.
    PROCEDURE prc_mv (name VARCHAR2)
    IS
    BEGIN
    dbms_mview.refresh (mv_name);
    END prc_mv;
    PROCEDURE refresh (response IN OUT NUMBER)
    IS
    BEGIN
    dbms_mview.refresh('mv1','C');
    dbms_mview.refresh('mv2','C');
    response := 1;
    EXCEPTION
    WHEN OTHERS
    THEN
    response := 0;
    END refresh;
    can you give the code for this procedure.Yes.
    DECLARE
      v_response NUMBER;
    BEGIN
      refresh(v_response);
    END;Though your code is awful. There's no point in having the response parameter as an IN OUT if you're not going to pass IN a value and use that in the code anywhere. In your case it only needs to be an OUT parameter because you're just passing back OUT a value. You are also masking any exceptions that happen by using a WHEN OTHERS clause.
    Better code would be something like...
    FUNCTION refresh (mv_name) RETURN NUMBER IS
      v_response NUMBER := 0; -- default response value
      e_mv_not_exist EXCEPTION; -- exception variable
      PRAGMA EXCEPTION_INIT(e_mv_not_exist, -23401); -- connect exception name to internal oracle error number
    BEGIN
      dbms_mview.refresh(mv_name,'C');
      v_response := 1;
    EXCEPTION
      WHEN e_mv_not_exist THEN -- handle specific expected exception
        -- if the materialized view does not exist, handle it gracefully as we don't want to stop
        response := 0;
    END refresh;
    declare
      v_response NUMBER;
    begin
      v_response := refresh('mv1');
      if v_response = 0 then
        -- the materialized view did not exist
      else
        -- the materialized view refreshed ok
      end if;
    end;where your exception handler explicity checks for expected exceptions such as :
    ORA-23401: materialized view "SCOTT"."FRED" does not exist... and any other exceptions that you're not expecting will be raised for you to see.
    It's also better as a function because you don't need to pass in a response value, you just want to get a response value back.
    There's rarely a good need to use OUT or IN OUT parameters. (there's some cases, but it's not something to consider doing as part of your regular design)

  • Exception is thrown but exception.getMessage() is null

    Hi,
    I am wirting a code in which an exception is thrown, I catch this exception in the catch block, but when I display e.getMessage() it displays null.....Can any body help in telling why....
    Thanks
    Rajnish Verma

    getMessage() is just about useless. If you use the no-arg constructor for a Throwable, you'll get a null message. Much, much better for displaying information about Throwables is toString() which will include the class name of the Throwable and the message if it's not null. Out shop never uses getMessage()

  • Exception is thrown only while executing the jar file

    java.lang.NoClassDefFoundError: javax/mail/Address Exception is thrown only while executing the jar file. But the program compiles and executes good when executed for command prompt through the class files.
    I used javamail API in my program. Classpath and every others are set to the right one's. Executed fine when used java Random.class. But the problem is only with the jar file.
    Please help me out in this regard. Why the exception is thrown only in jar but not at class level.

    Assuming you're running your program using "java -jar", your jar file needs a Class-Path entry
    in the manifest file that references mail.jar.

  • JUnit - How to assert exception is thrown?

    If I use JUnit how do I assert an exception is thrown when I pass invalid parameters to a method I am testing? For example if I pass a username to a method that I know will cause the method to throw an InvalidUsernameException how do I assert this?

    public void testBadParameter() {
      try {
        objectUnderTest.myMethod(badParameter);
        fail("Foo!");
      } catch (ExcpectedException e) {
        //ok
    }

Maybe you are looking for

  • Want to view Photos from iPhoto on TV set

    I purchased Composite AV Cable from the Apple Store and was told that this was all I needed to view pictures from iPhoto on my TV. It didn't work because the TV didn't recognize the iPhone , so I returned the cable. Later I spoke to a friend and was

  • Passing Parameters dynamically to WEBAPI

    Greetings, How to dynamically can I pass variables value to WEAPI to execute a query? For example I have two variables Year (PCALYEAR) and Period (PCALM). I tried the below command and it did not work. CMD='PROCESS_VARIABLES' SUBCMD='VAR_SUBMIT' VAR_

  • Error Message when I use Flash websit

    I am on XP and have Flash 8 installed. Yet as I rollover navigation on site I see this box come up: Click to Activate and Use this control or Press Spacebar to activate and use this control. In some case a black ouline goes around an entire map or na

  • Partial Period Factor in INP1

    Dear Experts, I have copied INP1 to ZNP1& created new PPF as /807 in it. I have a wagetype 1102 - Attendance allowance that is to be paid to those having 0 days leave without pay in a month. I have set Processing Class 10 to WT 1102 as 7. Now even if

  • Re: Stolen Gift Card Procedure FAIL

    I recently suffered a similar theft, so I feel your pain. I had two (2) Best Buy gift cards - one worth $222.75, and another worth $50.00.  I was saving the cards for Black Friday shopping, but I decided to post the gift cards on Craigslist to see if