What are some predefined exceptions in PL/SQL?

A list of predefined exceptions in PL/SQL:

  • DUP_VAL_ON_INDEX
  • ZERO_DIVIDE
  • NO_DATA_FOUND
  • TOO_MANY_ROWS
  • CURSOR_ALREADY_OPEN
  • INVALID_NUMBER
  • INVALID_CURSOR
  • PROGRAM_ERROR
  • TIMEOUT _ON_RESOURCE
  • STORAGE_ERROR
  • LOGON_DENIED
  • VALUE_ERROR

In PL/SQL, predefined exceptions are built-in exceptions provided by Oracle that handle common error conditions. Some of the commonly used predefined exceptions in PL/SQL include:

  1. NO_DATA_FOUND: Raised when a SELECT INTO statement returns no rows.
  2. TOO_MANY_ROWS: Raised when a SELECT INTO statement returns more than one row.
  3. INVALID_NUMBER: Raised when a conversion of a character string to a number fails.
  4. ZERO_DIVIDE: Raised when a division or modulus operation is attempted with a divisor of zero.
  5. CURSOR_ALREADY_OPEN: Raised when trying to open a cursor that is already open.
  6. INVALID_CURSOR: Raised when a cursor operation is attempted on an invalid cursor.
  7. LOGIN_DENIED: Raised when a program attempts to log in with an invalid username/password.
  8. PROGRAM_ERROR: Raised when a PL/SQL program violates an Oracle rule or exceeds a system-dependent limit.
  9. STORAGE_ERROR: Raised when a PL/SQL program runs out of memory.
  10. VALUE_ERROR: Raised when an arithmetic, conversion, truncation, or constraint violation error occurs.

These are just a few examples, and there are more predefined exceptions available in PL/SQL. You can use these exceptions to handle common errors and exceptions gracefully in your PL/SQL code.