PL/SQL.
Internal exceptions
• They are those defined by Oracle.
• It is not necessary to declare them.
• They do not need the clause: RAISE. They are raised
automatically when a program:
• Violates any Oracle rule.
• Exceeds any of the established limits for the resources it
needs (e.g. memory).
• Like any exception, they are handled in the block:
EXCEPTION
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
PL/SQL. Internal exceptions
• Each error that may occur during the execution of a
program has an associated number.
• As the error number is difficult to remember, the
most frequent errors also have a name to facilitate
their management.
• Internal exceptions are those that have an error
number and a name predefined by the system that
identifies them.
• They are defined in the STANDARD.
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
PL/SQL. Internal exceptions
Name NºError SQL Code
CURSOR_ALREADY_OPEN ORA–6511 –6511
DUP_VAL_ON_INDEX ORA-00001 -1
INVALID_CURSOR ORA-01001 -1001
INVALID_NUMBER ORA-01722 -1722
LOGIN_DENIED ORA–01017 -1017
NO_DATA_FOUND ORA-01403 +100
NOT_LOGGED_ON ORA–01012 -1012
PROGRAM_ERROR ORA-06501 -6501
STORAGE_ERROR ORA-06500 -6500
TIMEOUT_ON_RESOURCE ORA–00051 –51
TOO_MANY_ROWS ORA-01422 -1422
VALUE_ERROR ORA-06502 -6502
ZERO_DIVIDE ORA-01476 -1476 cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
PL/SQL. Internal exceptions
● CURSOR_ALREADY_OPEN
An attempt is made to open a cursor that is already open.
It must be closed before it can be reopened.
● DUP_VAL_ON_INDEX
An attempt is made to store a value that already exists in a column that does not
support duplicates.(P KEY, UNIQUE).
● NO_DATA_FOUND
• SELECT..INTO (implicit cursor) does not return any rows.
• A row of an undefined table is referenced.
● TOO_MANY_ROWS
SELECT INTO (implicit cursor) returns more than one row.
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
PL/SQL. Internal exceptions
19. Implement a procedure that increases the salary of the
highest earner in the given department by 100 euros.
TOO_MANY_ROWS
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
PL/SQL. Internal exceptions
20. Implement a procedure, Insert_Depart, that inserts
a given department. Contemplate the exception:
DUP_VAL_ON_INDEX
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB
References
● Reconocimiento: Gema Cervigón Mota.
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
cc-by-sa Gema Cervigón. Guadalupe Bermejo UT7 DDBB 7