Catching unnamed Oracle errors

How do you handle specific Oracle errors such as the following:
declare
  dummy varchar2(100);
begin
  select distinct y into dummy
  from
    (select 'x' x, 'y' y
     from dual
     union all
     select 'x' x, 'y' y
     from dual)
  order by x;
  exception when ???
end;What would go in the ??? part if I wanted to specifically handle the ORA-01791 error.
Message was edited by:
SamB

something like this...
SQL> DECLARE
  2   dummy VARCHAR2(100);
  3   v_error EXCEPTION;
  4  
  5   PRAGMA EXCEPTION_INIT(v_error, -01791);
  6  BEGIN
  7   SELECT DISTINCT y
  8   INTO dummy
  9   FROM (SELECT 'x' x, 'y' y FROM dual
10         UNION ALL
11      SELECT 'x' x, 'y' y FROM dual)
12   ORDER BY x;
13  EXCEPTION
14   WHEN v_error THEN
15     DBMS_OUTPUT.PUT_LINE('Exception Raised.');
16  END;
17  /
Exception Raised.
PL/SQL procedure successfully completed.

Similar Messages

  • Oracle Error Code and Message for Query Timeout

    Hi,
    I need to catch the oracle error code and message for query timeout.
    I am using Oracle 9i and could not find any relevant error code/message
    for query timeout in Oracle Error Messages.
    If anyone has encountered such error messages, please let me know the
    Oracle Code or Error message.
    Thanks & Regards,
    Kanjana

    Fly is correct in that Oracle will normally let a query run forever in the absense of a user profile or dbms_resource setting that limits a users (query) resouce usage.
    The errors returned for these condition would probably vary but errors ORA-02092 "exceeded session limit on CPU usage, you are being logged off" and ORA-02093 "exceeded call limit on CPU usage" might be of interest.
    But for distributed queries Oracle does impose a time limit. See Oracle error ORA-02049 "timeout: distributed transaction waiting for lock"
    HTH -- Mark D Powell --

  • Oracle error codes

    Hello,
    My application is handling exceptions like this:
    try{
    resultSet = pStatement.executeQuery();
    catch(SQLException e){
    conn.close();
    if(e.getErrorCode() == 942)
    // handle with table or view doesn't exist
    else
    // handle with other errors
    Is there a way to not hard code the error codes?
    Is there any java constants to oracle error or messages in the jdbc driver?
    Thanks,
    Vladimir.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Marcus Uddenhed ([email protected]):
    I need to know where i can find,
    a description to the error codes
    in Oracle.<HR></BLOCKQUOTE>
    null

  • How to display Oracle error in web page

    Hi ,
    I am developing an application in Weblogic 10.2 and java . The data is fetched in oracle and i storre it in vector and display the same in the webpage .Whenever an oracle error or exception occurs , i need that ORA message to be displayed on the page , instead i get the error from Weblogic server being displayed on the page .The weblogic exception takes the precedence and it is displayed. Can anyone let me knwo how to display the oracle error instead of these head breaking lines , since it irritates the end users
    <Feb 10, 2009 6:38:31 AM MST> <Error> <HTTP> <BEA-101020> <[ServletContext(id=11
    504434,name=DefaultWebApp,context-path=/DefaultWebApp)] Servlet failed with Exce
    ption
    java.lang.NullPointerException
    at jsp_servlet.__ttt_cust_info._jspService(__ttt_cust_info.java:505)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    (ServletStubImpl.java:1077)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run(WebAppServletContext.java:7047)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
    dSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
    121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:3902)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2773)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    >

    I'm not convince that the null pointer exception is coming from the database. Rather, whatever you wrote to package the result might be at fault. Regardless, typically, to avoid the web container swallowing an exception is to catch it yourself. Your database call will need to catch the exception and repackage it for the JSP. A bad style would be to use scriptlet and catch the exception, but it could be useful for debugging.

  • Oracle error in drueixe

    [Reposted fropm the intermedia forum as suggested]
    All of a sudden I got my intermedia logs filled with :
    16:04:18 07/17/01 End batch, return code is 1
    16:04:18 07/17/01 DRG-50857: oracle error in drtldml(dml)
    16:04:18 07/17/01 ORA-20000: erreur interMedia Text :
    DRG-50857: oracle error in drueixe
    ORA-01653: impossible d'itendre la table CTXSYS.DR$INDEX_ERROR de 92176 dans l'espace table DRSYS
    ORA-27059: skgfrsz : riduction impossible de la taille du fichier
    Linux Er
    Intermedia will consume all he cpu every few minutes and then add this to its logfile.
    What should I do ?
    System is Oracle 8.1.7.0.0.1 on linux, has been running happily for a few months beore this
    <I>quote:Originally posted by Omar Alonso:
    Are you trying to create an index or to sync' one?</I>
    <B>I</B> am doing nothing myself.
    Just launched intermedia on a database, and let it do what it's prone to do.
    I think this database was not indexed by intermedia for some time, so it may have some catching up to do, but I didn't request anything out of the ordinary.
    This database is used by IFS, but I'm not sure that's relevant
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Omar Alonso:
    Are you trying to create an index or to sync' one?<HR></BLOCKQUOTE>
    <b>I</b> am doing nothing myself.
    Just launched intermedia on a database, and let it do what it's prone to do.
    I think this database was not indexed by intermedia for some time, so it may have some catching up to do, but I didn't request anything out of the ordinary.
    This database is used by IFS, but I'm not sure that's relevant
    null

  • Sql loader (catching record length error)

    Guys is there any command in sqlldr that can catch record length error (less or more than certain length).I am using java to execute my sqlldr and would like to know if it is possible to catch those error.
    thanks
    Manohar.

    Use CHAR instead aof VARCHAR
    LOAD DATA
    INFILE *
    APPEND INTO TABLE test
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
      first_id,
      second_id,
      third_id,
      language_code,
      display_text    CHAR(2000)
    )From the docu:
    A VARCHAR field is a length-value datatype.
    It consists of a binary length subfield followed by a character string of the specified length.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76955/ch05.htm#20324

  • Is there try and catch in oracle query ?

    hi
    is there try and catch in oracle query ?
    try
    do some update
    catch
    if there was error go to here
    }

    >
    is there try and catch in oracle query ?
    >
    Yes - except it uses BEGIN --- EXCEPTION --- END where BEGIN replaces the try and EXCEPTION replaces the catch.
    BEGIN
    -- Calculation might cause division-by-zero error.
       pe_ratio := stock_price / net_earnings;
       dbms_output.put_line('Price/earnings ratio = ' || pe_ratio);
    EXCEPTION  -- exception handlers begin
    -- Only one of the WHEN blocks is executed.
       WHEN ZERO_DIVIDE THEN  -- handles 'division by zero' error
          dbms_output.put_line('Company must have had zero earnings.');
          pe_ratio := null;
       WHEN OTHERS THEN  -- handles all other errors
          dbms_output.put_line('Some other kind of error occurred.');
          pe_ratio := null;
    END;  -- exception handlers and block end here
    /The multiple WHEN conditions correspond to using multiple 'catch' statements in Java.

  • How to catch SMPP gateway error type ?

    Hi,
    How can i catch different SMPP error type return by SMSC server ?
    I want to catch result like 0x45,0x01,0x0B,0x58,0x15.... in my code. I can see eventgateway.log logging the error message but how do i get error type in my code ?
    Thanks

    Hi,
    There are different approaches, you can use a validate activity or you can check the validate check box in an assign activity...
    Have a look on the links bellow...
    http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_appx_ref.htm#SOASE86011
    http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_manipdoc.htm#SOASE1824
    http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_manipdoc.htm#SOASE87095
    Hope this helps...
    Cheers,
    Vlad

  • Capturing oracle error codes into a variable

    Hi
    Can someone show me how it is possible to save an Oracle defined error code into a variable? What I am trying to do is when a stored procedure fails an Oracle error is raised, such as ORA-xxxx, then pass this code into variable to be saved into a log.
    How do I achieve this?

    user633278 wrote:
    How do I achieve this?Function SQLCODE in PL/SQL exception handler returns error code. SQLERRM returns message:
    SQL> declare
      2      x number;
      3  begin
      4      x := 1/0;
      5    exception
      6      when others
      7        then
      8          dbms_output.put_line('Error code: ' || SQLCODE);
      9          dbms_output.put_line('Error message: ' || SQLERRM);
    10  end;
    11  /
    Error code: -1476
    Error message: ORA-01476: divisor is equal to zero
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Oracle errors in Weblogic Error logs appear in non english

    We have a problem with weblogic error logging. Specifically, in a managed server's log file, Oracle errors such as ORA-XXXX show in Greek, not English. We are assuming
    that this is because the timezone is Europe/Athens. However, the weblogic application server runs with user.language=en, user.country=US. What's more, there are 4 application servers and 2 of them have this problem. The oracle database is accessed via weblogic datasources.
    Oracle database server Setup: Oracle Server 11gR2 running on Oracle Linux 64 bit, timezone set to Europe/Athens
    Weblogic Server: Weblogic 10.3.5 running on Oracle Linux 64 bit, timezone set to Europe/Athens
    The managed server, according to jrockit, the jvm runs with the following language related system properties:
    user.language=en, user.country=US, user.timezone=Europe/Athens
    The question is: How do we tell oracle / weblogic to log english text for the ORA errors?
    Thanks,
    Chris

    I digged in the weblogic installation directory and it seems like the domain configuration wizard messed up the jdbc configs for the data sources.
    The config xml files for the data sources in the /domain root/config/jdbc directory had oracle driver but the test query was for pointbase. I double checked from the database.xml file in the init-info directory and corrected the entry in the datasource config xmls and voila!.. the errors were gone.
    I am not sure if this was the right approach and whether i have solved the issue or simply patched it.. so I am keeping the question open. If any one has any inputs I will be grateful.
    If the mods/admins feel that the thread should be marked as solved I will surely do so.
    Thanks.

  • How to catch SAP application errors in BPM.

    Hi,
    I have a IDOC to Soap Sync Scenario where I send the message to a Webservice. I have used a BPM since we need to catch the resposne of this message and map it to a RFC. For ex if I get a success resposne I need to map success if not than I need to catch the error and map it to the RFC. Now here in some cases like if the target system (webservice) is down than XI raises a sap application error:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Inbound Message
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: Connection refused (errno:239)</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Normally XI stops the process in these cases and does not proceed to the next step but I need to catch this message and map the content in the AdditionalText to the target RFC. Can anyone let me know how to catch this SAP Application Error in BPM and map it to the RFC.
    Thanks,
    Bhargav

    Hi Gaurav,
    As I have mentioned I need to catch the application error in the BPM. If you see the discussion that is mentioned after the blog you have mentioned it is stated that the fault messages or the application error cannot be caught in BPM.
    In the blog that you stated we can catch the fault message and map it to a message structure but only to that extent after that it would stop the BPM process at that step but would not proceed further as shown in the screenshot given in the blog it would fail as "application error restart not possible".
    I need to proceed further and capture this error to an RFC Structure and call a proxy.
    Here after the error it does not proceed to the next step.
    Thanks,
    Bhargav

  • [SOLVED] FRM-40508:ORACLE error: unable to INSERT record

    Hi all,
    I have migrated this form from 4.5 to 10g (Version 10.1.2.0.2 ). This form inserts a record into the database table when all the fields in the form are filled and a button Save is presed.
    At the time when I press the Save button, I get this error. FRM-40508:ORACLE error: unable to INSERT record
    So I went on to see the "Display Error" from help and found to be the database error, inserting into a table.
    The error message is ORA-00932: inconsistent datatypes: expected DATE got NUMBER
    The form where I press Save button has 3 date fields and I checked the properties of them and they are Date only.
    I also generated to object list report and tried to find some answer, but no use.
    Please help me in debugging this form.
    Edited by: Charan on Aug 18, 2011 4:05 PM

    I think you need to get a description of the table and compare all the "database" columns in the form with the ones in the database table to see that the types match. Somewhere there's a mismatch. Also check the block(s) "query data source columns" and see if there's any
    columns in there that the type does not match the table. (check the sizes of things too while you're at it.)

  • Oracle error 1012 ("Not Logged On") & AUTOTRAN=Y

    Hi.
    I have a problem trying to access an Oracle 8.0.6
    database from a 6.5 Tuxedo server.
    Both TMS and server execute tpopen correctly
    All services are declared as AUTOTRAN
    Everything seems to be OK according to the logsgenerated by Oracle XA libraries
    However, I always get the Oracle error 1012 ("Not Logged On")
    when executing SQL statements from my pro*C server.
    I just can't figure out why this error occurs.
    I also tried to explicitly open a transaction from the client,
    but the result is exactly the same (tpbegin is successfull,
    however).
    Could someone help me to make this work ?
    Thanks.

    Solved by removing "DB=<db>" from my OPENINFO string, as far as this parameter
    should only be used when using proc*C "EXEC SQL ... AT <db>" statements.
    "Mathieu Chauvin" <[email protected]> wrote:
    >
    Hi.
    I have a problem trying to access an Oracle 8.0.6
    database from a 6.5 Tuxedo server.
    Both TMS and server execute tpopen correctly
    All services are declared as AUTOTRAN
    Everything seems to be OK according to the logsgenerated by Oracle XA libraries
    However, I always get the Oracle error 1012 ("Not Logged On")
    when executing SQL statements from my pro*C server.
    I just can't figure out why this error occurs.
    I also tried to explicitly open a transaction from the client,
    but the result is exactly the same (tpbegin is successfull,
    however).
    Could someone help me to make this work ?
    Thanks.

  • Oracle error ORA-01461when trying to insert into an ORACLE BLOB field

    I am getting Oracle error ‘ORA-01461: can bind a LONG value only  for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
    BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
    ORACLE version is 11.2.0.1
    The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
    Here is my code:
    <cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
    <cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
    <cfset file_mime = 'data:image/' & file_mime & ';base64,'>
    <cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
    <cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
    <cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
    <cffile action="readbinary" file="#ramfile#" variable="image_bin">
    <cffile action="delete" file="#ramfile#">
    <cfquery name="InsertImage" datasource="#datasource#">
    INSERT INTO test_images
    image_blob
    SELECT
    <cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
    FROM          dual
    </cfquery>

    Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.

  • Oracle error ORA-604 when opening a connection

    I am facing an issue with my WCF service which is using ODP.NET version 4.112.2.0(x64) and Oracle 11g.
    The service runs without any problems on the test servers but on production server (Windows 2008 R2) when an attempt is made to call any service method it fails with the following Oracle error code Ora-604. the message is
    ORA-604: error occurred at recursive SQL level %s
    The exception is thrown when a call to meethod Open is made to open a connection.
    There is no inner exception. So far I have tried checking the connection string, the user permissions and setting the TNS_ADMIN environment variable but nothing has worked.
    Another thing to mention is that another WCF service which uses some of the same stored procedure I am using is working fine on the same server.
    Has anyone seen this before?
    Thanks,
    A

    Do you have a login trigger?
    select * from dba_triggers where triggering_event like 'LOGON%'
    If so, try disabling it.
    Does the working service use the same credentials as this problem service?
    Are you able to connect using sqlplus, with the same credentials from the same client to the same database? If it's not an ODP.NET specific problem, the dba guys might be able to help better: General Database Discussions
    Greg

Maybe you are looking for