Oracle pre-defined exception

Source: Internet
Author: User

Oracle provides a series of predefined exceptions in the STANDARD package. They are useful tools for debugging Oracle PL/SQL programs. For most errors, the negative number is used as the error number. You can use the SQLCODE built-in function to see the error code and use SQLERRM to get an exception built-in message.

Exception Error When
Access_assist_null ORA-06530 When attempting to access an uninitialized object
CASE_NOT_FOUND ORA-06592 This exception occurs if a CASE statement without an ELSE clause is defined and no CASE statement meets runtime conditions.
COLLECTION_IS_NULL ORA-06531 This exception occurs when the program accesses a non-initialized nested table or VARRAY.
CURSOR_ALREADY_OPEN ORA-06511 The cursor has been opened. If you try to OPEN the cursor again, this exception occurs.
DUP_VAL_ON_INDEX ORA-00001 This exception is thrown when you insert a duplicate value with a unique INDEX constraint (the value is determined as conflicting by the INDEX)
INVALID_CURSOR ORA-01001 This operation is not allowed. For example, if you close a closed cursor
INVALID_NUMBER ORA-01722 When a numeric value is assigned a non-numeric value, this exception occurs. This exception also occurs when the LIMIT clause returns a non-positive number during batch reading.
LOGIN_DENIED ORA-01017 The program will throw this exception when logging on with the wrong user name and password.
NO_DATA_FOUND ORA_06548 When the select into structure is used and the statement returns a NULL value, this exception occurs when you access the deleted table in the nested table or the uninitialized element in the index by table (combined array ).
NOT_LOGGED_ON ORA-01012 When the program sends a database call, but there is no connection (usually, after the connection is actually disconnected from the session)
PROGRAM_ERROR ORA-06501 Errors that have not been officially captured by Oracle often occur because of a large number of Object functions in the database.
ROWTYPE_MISMATCH ORA-06504 If the cursor structure is not suitable for PL/SQL cursor variables or the actual cursor parameter is different from the cursor parameter, this exception occurs.
SELF_IS_NULL ORA-30625 This exception occurs when a non-static member method of the object type is called (the object type instance is not initialized ).
STORAGE_ERROR ORA-06500 This exception is thrown when the memory is not allocated enough SGA quota or is damaged.
SUBSCRIPT_BEYOND_COUNT ORA-06533 This exception occurs when the space allocated to the nested table or VARRAY is smaller than the used subobject (similar to the java ArrayIndexOutOfBoundsException)
SUBSCRIPT_OUTSIDE_LIMIT ORA-06532 When an invalid index value is used to access the nested table or VARRAY
SYS_INVALID_ROWID ORA-01410 When an invalid string is converted to ROWID
TIMEOUT_ON_RESOURCE ORA-00051 When the database cannot safely lock resources
TOO_MANY_ROWS ORA-01422 A common error occurs when multiple rows are returned using select into and a query. This exception is also thrown if the subquery returns multiple rows and the comparison operator is equal.
USERENV_COMMITSCN_ERROR ORA-01725 Only the USERENV ('commitscn ') function can be used as the top-level expression in the VALUES clause of the INSERT statement or as the right operand in the SET clause of the UPDATE statement.
VALUE_ERROR ORA-06502 When a variable is assigned to another variable that cannot hold the variable
ZERO_DIVIDE ORA-01476 This exception occurs when a number is divided by 0.

EXCEPTION can be easily captured and processed in SQL blocks (except for compilation exceptions and exceptions thrown in Declaration blocks, A good PL/SQL programming habit is to avoid assigning values to variables in declared blocks ). If the predefined exceptions above meet the requirements, you can use them. If not, you can define your own exceptions like a JAVA program and use raise exception to throw an EXCEPTION.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.