How exceptions are raised in oracle?

How exceptions are raised in oracle?

Oracle exceptions are raised internally and user need not explicitly raise them. For example, when a number is attempted to be divided by ZERO, ZERO_DIVIDE exception is raised.
User defined exceptions need to be raised explicitly using RAISE command.

Example:
DECLARE
      total_stock NUMBER := 100;
      cust_sales NUMBER;
      sales_exceeded EXCEPTION;
BEGIN
      SELECT SUM (sales) INTO cust_sales
            FROM invoice WHERE customer_id = 1001;
      IF cust_sales > total_stock
      THEN
            RAISE sales_exceeded;
      END IF;
EXCEPTION
            WHEN sales_exceeded
      THEN
            DBMS_OUTPUT.PUT_LINE
                  (' Customer sales exceeded the stock quantity’);
END;

How exceptions are raised in oracle?

There are four ways that you or the PL/SQL runtime engine can raise an exception:

1. Exceptions are raised automatically by the program.
2. The programmer raises a user defined exceptions.
3. The programmer raises pre defined exceptions explicitly.

How exceptions are raised in oracle?

Internal exceptions are raised implicitly by the run-time system. However, user-defined exceptions must be raised explicitly by RAISE statements.
What are conversion functions?
CHARTOROWID, CONVERT, HEXTORAW, RAWTOHEX, ROWIDTOCHAR, TO_CHAR, TO_DATE, TO_NUMBER.....
What is nested function?
When one function is called inside the other, it is called a nested function....
What are SQL functions in oracle?
There are two types of functions – Single row that operates row by row. Group function operates on multiple rows..
Post your comment