Get Error Description Oracle
Contents |
Error Handling" in Oracle Database PL/SQL Language Reference. See the end of this chapter for TimesTen-specific considerations. The following topics are covered: Understanding exceptions Trapping exceptions Showing oracle sqlerrm errors in ttIsql Differences in TimesTen: exception handing and error behavior Understanding exceptions
Oracle Raise Exception With Message
This section provides an overview of exceptions in PL/SQL programming, covering the following topics: About exceptions Exception types About functions for error trapping are contained in which section of a pl/sql block exceptions An exception is a PL/SQL error that is raised during program execution, either implicitly by TimesTen or explicitly by your program. Handle an exception by trapping it with a handler or oracle sql error codes propagating it to the calling environment. For example, if your SELECT statement returns multiple rows, TimesTen returns an error (exception) at runtime. As the following example shows, you would see TimesTen error 8507, then the associated ORA error message. (ORA messages, originally defined for Oracle Database, are similarly implemented by TimesTen.) Command> DECLARE > v_lname VARCHAR2 (15); > BEGIN > SELECT last_name INTO v_lname >
Oracle Predefined Exceptions
FROM employees > WHERE first_name = 'John'; > DBMS_OUTPUT.PUT_LINE ('Last name is :' || v_lname); > END; > / 8507: ORA-01422: exact fetch returns more than requested number of rows 8507: ORA-06512: at line 4 The command failed. You can handle such exceptions in your PL/SQL block so that your program completes successfully. For example: Command> DECLARE > v_lname VARCHAR2 (15); > BEGIN > SELECT last_name INTO v_lname > FROM employees > WHERE first_name = 'John'; > DBMS_OUTPUT.PUT_LINE ('Last name is :' || v_lname); > EXCEPTION > WHEN TOO_MANY_ROWS THEN > DBMS_OUTPUT.PUT_LINE (' Your SELECT statement retrieved multiple > rows. Consider using a cursor.'); > END; > / Your SELECT statement retrieved multiple rows. Consider using a cursor. PL/SQL procedure successfully completed. Exception types There are three types of exceptions: Predefined exceptions are error conditions that are defined by PL/SQL. Non-predefined exceptions include any standard TimesTen errors. User-defined exceptions are exceptions specific to your application. In TimesTen, these three types of exceptions are used in the same way as in Oracle Database. Exception Description How to handle Predefined TimesTen error One of approximately 20 errors that occur most often in PL/S
Churchill Run-time errors arise from design faults, coding mistakes, hardware failures, and many other sources. Although you cannot oracle exception when others anticipate all possible errors, you can plan to handle certain oracle raise_application_error kinds of errors meaningful to your PL/SQL program. With many programming languages, unless you disable error checking,
Types Of Exceptions In Oracle
a run-time error such as stack overflow or division by zero stops normal processing and returns control to the operating system. With PL/SQL, a mechanism called exception https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm handling lets you "bulletproof" your program so that it can continue operating in the presence of errors. This chapter discusses the following topics: Overview of PL/SQL Error Handling Advantages of PL/SQL Exceptions Predefined PL/SQL Exceptions Defining Your Own PL/SQL Exceptions How PL/SQL Exceptions Are Raised How PL/SQL Exceptions Propagate Reraising a PL/SQL Exception Handling Raised https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/07_errs.htm PL/SQL Exceptions Tips for Handling PL/SQL Errors Overview of PL/SQL Error Handling In PL/SQL, a warning or error condition is called an exception. Exceptions can be internally defined (by the run-time system) or user defined. Examples of internally defined exceptions include division by zero and out of memory. Some common internal exceptions have predefined names, such as ZERO_DIVIDE and STORAGE_ERROR. The other internal exceptions can be given names. You can define exceptions of your own in the declarative part of any PL/SQL block, subprogram, or package. For example, you might define an exception named insufficient_funds to flag overdrawn bank accounts. Unlike internal exceptions, user-defined exceptions must be given names. When an error occurs, an exception is raised. That is, normal execution stops and control transfers to the exception-handling part of your PL/SQL block or subprogram. Internal exceptions are raised implicitly (automatically) by the run-time system. User-defined exceptions must be raised explicitly by RAISE statements, which can also raise predefined exceptions. To han
and other http://www.oracle.com/pls/db92/db92.error_search?prefill=ORA- troubleshooting information in these books. List of Message Types https://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems050.htm ORA-00000 to ORA-00899 ORA-00900 to ORA-01499 ORA-01500 to ORA-02099 ORA-02100 to ORA-04099 ORA-04100 to ORA-07499 ORA-07500 to ORA-09857 ORA-09858 to ORA-12299 ORA-12300 to ORA-12399 ORA-12400 to ORA-12699 ORA-12700 to ORA-19399 ORA-19400 to ORA-24279 ORA-24280 to ORA-29249 oracle raise ORA-29250 to ORA-32799 ORA-32800 to ORA-32999 ORA-33000 to ORA-65535 BFILE-Related Messages (LFI) DBNEWID Messages (NID) DBVERIFY Messages (DBV) Export Messages (EXP) External Naming Messages (NNF) External Tables Messages (KUP) Import Messages (IMP) interMedia Audio Messages (AUD) interMedia Image Messages (IMG) interMedia Video Messages (VID) Network get error description Security Messages (NZE) Object Type Translator Initialization Messages (O2I) Object Type Translator Type File Messages (O2F) Object Type Translator Unparser Messages (O2U) Oracle Names Client Messages (NNC) Oracle Names Control Utility Messages (NNL) Oracle Names Server Messages (NNO) Oracle Names Server Network Presentation Layer Messages (NPL) Oracle Net Messages (TNS) Oracle OLAP Catalog Metadata Messages (AMD) Oracle Text Messages (DRG) Oracle Trace Collection Services Messages (EPC) Parameter Messages (LCD) Parameter Messages (LRM) PCF FIPS Messages (PCF) PL/SQL and FIPS Messages (PLS) Pro*C/C++ Messages (PCC) Pro*COBOL Messages (PCB) Recovery Manager Messages (RMAN) Remote Operation Messages (NCR) Simple Network Management Protocol Messages (NMP) SQL Runtime Messages (SQL) SQL*Module Messages (MOD) Summary Advisor, Explain Rewrite, and Explain Materialized View Messages (QSM) XML Parser Messages (LPX) XML Schema Processor Messages (LSX) Copyright © 2016, Oracle. All rights reserved.
its error-number argument. If the argument is omitted, it returns the error message associated with the current value of SQLCODE. SQLERRM with no argument is useful only in an exception handler. Outside a handler, SQLERRM with no argument always returns the message normal, successful completion. For internal exceptions, SQLERRM returns the message associated with the Oracle error that occurred. The message begins with the Oracle error code. For user-defined exceptions, SQLERRM returns the message user-defined exception, unless you used the pragma EXCEPTION_INIT to associate the exception with an Oracle error number, in which case SQLERRM returns the corresponding error message. For more information, see "Retrieving the Error Code and Error Message: SQLCODE and SQLERRM". Syntax Description of the illustration sqlerrm_function.gif Keyword and Parameter Description error_number A valid Oracle error number. For a list of Oracle errors (ones prefixed by ORA-), see Oracle Database Error Messages. Usage Notes SQLERRM is especially useful in the OTHERS exception handler, where it lets you identify which internal exception was raised. The error number passed to SQLERRM should be negative. Passing a zero to SQLERRM always returns the following message: ORA-0000: normal, successful completion Passing a positive number to SQLERRM always returns the message User-Defined Exception unless you pass +100, in which case SQLERRM returns the following message: ORA-01403: no data found You cannot use SQLERRM directly in a SQL statement. Assign the value of SQLERRM to a local variable first: my_sqlerrm := SQLERRM; ... INSERT INTO errors VALUES (my_sqlerrm, ...); When using pragma RESTRICT_REFERENCES to assert the purity of a stored function, you cannot specify the constraints WNPS and RNPS if the function calls SQLERRM. Example The following example retrieves the error message associated with an unhandled exception, and stores it in an audit table. The SUBSTR function truncates the message if it is too long to fit in the table. CREATE TABLE errors (code NUMBER, message VARCHAR2(128), happened TIMESTAMP); DECLARE name employees.last_name%TYPE; my_code NUMBER; my_errm VARCHAR2(32000); BEGIN SELECT last_name INTO name FROM employees WHERE employee_id = -1; EXCEPTION WHEN OTHERS THEN my_code := SQLCODE; my_errm := SQLERRM; dbms_output.put_line('Error code ' || my_code || ': ' || my_errm); -- Normally we would call another procedure, declared with PRAGMA -- AUTONOMOUS_TRANSACTION, to insert information about errors. INSERT INTO errors VALUES (my_code,