Pl/sql Error Code Message
Contents |
shot at without result. —Winston Churchill Run-time errors arise from design faults, coding mistakes, hardware failures, and many other sources. Although you
Oracle Raise Exception With Message
cannot anticipate all possible errors, you can plan to handle certain kinds sqlerrm in pl/sql of errors meaningful to your PL/SQL program. With many programming languages, unless you disable error checking, a functions for error trapping are contained in which section of a pl/sql block 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 handling lets you
Pl Sql Exception Handling Examples
"bulletproof" your program so that it can continue operating in the presence of errors. This chapter contains these topics: Overview of PL/SQL Runtime Error Handling Advantages of PL/SQL Exceptions Summary of 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 PL/SQL Exceptions Tips for Handling
Pl Sql Sqlcode
PL/SQL Errors Overview of PL/SQL Compile-Time Warnings Overview of PL/SQL Runtime Error Handling In PL/SQL, an error condition is called an exception. Exceptions can be internally defined (by the runtime 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 handle raised exceptions, you write separate routines called exception handlers. After an
errors. The latter are called exceptions. Note: The language of warning and error messages oracle sql error code depends on the NLS_LANGUAGE parameter. For information about this parameter, see
Oracle Sql Codes List
Oracle Database Globalization Support Guide. Topics Compile-Time Warnings Overview of Exception Handling Internally Defined Exceptions Predefined Exceptions oracle sqlcode list User-Defined Exceptions Redeclared Predefined Exceptions Raising Exceptions Explicitly Exception Propagation Unhandled Exceptions Error Code and Error Message Retrieval Continuing Execution After Handling Exceptions Retrying Transactions After Handling https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm Exceptions See Also: "Exception Handling in Triggers" "Handling FORALL Exceptions After FORALL Statement Completes" Tip: If you have problems creating or running PL/SQL code, check the Oracle Database trace files. The USER_DUMP_DEST initialization parameter specifies the current location of the trace files. You can find the value of this parameter by issuing SHOW PARAMETER https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm USER_DUMP_DEST. For more information about trace files, see Oracle Database Performance Tuning Guide. Compile-Time Warnings While compiling stored PL/SQL units, the PL/SQL compiler generates warnings for conditions that are not serious enough to cause errors and prevent compilation—for example, using a deprecated PL/SQL feature. To see warnings (and errors) generated during compilation, either query the static data dictionary view *_ERRORS (described in Oracle Database Reference) or, in the SQL*Plus environment, use the command SHOW ERRORS. The message code of a PL/SQL warning has the form PLW-nnnnn. For the message codes of all PL/SQL warnings, see Oracle Database Error Messages. Table 11-1 summarizes the categories of warnings. Table 11-1 Compile-Time Warning Categories Category Description Example SEVERE Condition might cause unexpected action or wrong results. Aliasing problems with parameters PERFORMANCE Condition might cause performance problems. Passing a VARCHAR2 value to a NUMBER column in an INSERT statement INFORMATIONAL Condition does not affect performance or correctness, but you might want to change it to make
SQL TuningSecurityOracle UNIXOracle LinuxMonitoringRemote supportRemote plansRemote servicesApplication Server ApplicationsOracle FormsOracle PortalApp UpgradesSQL ServerOracle ConceptsSoftware SupportRemote Support Development Implementation Consulting StaffConsulting PricesHelp Wanted! Oracle PostersOracle Books Oracle Scripts Ion Excel-DB http://www.dba-oracle.com/t_raise_application_error.htm Don Burleson Blog
RAISE_APPLICATION_ERROR tips Oracle Database Tips by Burleson Consulting March 3, 2015 Question: What does the PL/SQL raise_application_error http://awads.net/wp/2006/08/01/little-known-way-to-get-the-error-message-in-plsql/ code do? Answer: The raise_application_error is actually a procedure defined by Oracle that allows the developer to raise an exception and associate an error number and message with the procedure. oracle sql This allows the application to raise application errors rather than just Oracle errors. Error numbers are defined between -20,000 and -20,999. Oracle provides the raise_application_error procedure to allow you to raise custom error numbers within your applications. You can generate errors and their associated text starting with -20000 and proceeding through -20999 (a grand total of 1,000 error numbers that you sql error code can use). Below we illustrate the use of the raise_application_error procedure. Using the raise_application_error procedure: DECLARE Balance integer := 24; BEGIN IF (nBalance <= 100) THEN Raise_Application_Error (-20343, 'The balance is too low.');END IF;END; In this example, error number -20343 is raised if the value of nBalance isn't greater than 100, yielding a message that looks like this: ORA-20343: The balance is too low. All other numbers belong to Oracle for its own errors. The message can be anything that will fit in a varchar2(2000). The final parameter passed to the procedure is a Boolean(true/false) that tells the procedure to add this error to the error stack or replace all errors in the stack with this error. Passing the value of 'True' adds the error to the current stack, while the default is 'False'. SQL> create or replace procedure test_var2 (n_test IN number := 0,3 n_result OUT number)4 as5 begin 6 if n_test > 100 then7 raise_application_error(-20010,'Number Too Large');8 end if;9 n_result := n_test;10 end; 11 / Procedure created. SQL> declare2 n_numb number := &Number;3 n_2 number := 0;4 begin5 test_var(n_numb, nreturn the error message associated with the error code of the most recently raised exception in your PL/SQL block. The first function is SQLERRM. The second is the less known function DBMS_UTILITY.FORMAT_ERROR_STACK. Which one to use? To answer this question, let us first review the details of each function. SQLERRM Syntax: SQLERRM [(error_number)] It returns the error message associated with its error_number argument: SQL> BEGIN 2 DBMS_OUTPUT.put_line (SQLERRM (-1)); 3 END; 4 / ORA-00001: unique constraint (.) violated PL/SQL procedure successfully completed. If the argument is omitted (useful only in an exception handler), it returns the error message associated with the current value of SQLCODE (i.e. the error code of the most recently raised exception): SQL> BEGIN 2 RAISE NO_DATA_FOUND; 3 EXCEPTION 4 WHEN OTHERS 5 THEN 6 DBMS_OUTPUT.put_line (SQLERRM); 7 END; 8 / ORA-01403: no data found PL/SQL procedure successfully completed. Outside an exception handler, SQLERRM with no argument, or with argument equals to 0, always returns "ORA-0000: normal, successful completion": SQL> BEGIN 2 DBMS_OUTPUT.put_line (SQLERRM); 3 DBMS_OUTPUT.put_line (SQLERRM(0)); 4 END; 5 / ORA-0000: normal, successful completion ORA-0000: normal, successful completion PL/SQL procedure successfully completed. SQLERRM with an argument of 1 (the user-defined exception error number) returns "User-Defined Exception": SQL> BEGIN 2 DBMS_OUTPUT.put_line (SQLERRM(1)); 3 END; 4 / User-Defined Exception PL/SQL procedure successfully completed. SQLERRM with an invalid error code argument returns "ORA-NNNNN: Message NNNNN not found; product=RDBMS; facility=ORA" If the number is negative, and "-NNNNN: non-ORACLE exception" if the number is positive: SQL> BEGIN 2 DBMS_OUTPUT.put_line (SQLERRM (7)); 3 DBMS_OUTPUT.put_line (SQLERRM (-9)); 4 END; 5 / -7: non-ORACLE exception ORA-00009: Message 9 no