Interview :: PL/SQL
A function returns a value while a stored procedure doesn?t return a value.
Whenever an Error occurs Exception arises. Error is a bug whereas exception is a warning or error condition.
Faster access of data blocks in the table.
- Too_many_rows
- No_Data_Found
- Value_error
- Zero_error etc.
You can declare the User defined exceptions under the DECLARE section, with the keyword EXCEPTION.
Syntax:
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
- etc.
A trigger is a PL/SQL program which is stored in the database. It is executed immediately before or after the execution of INSERT, UPDATE, and DELETE commands.
12 triggers.
There are 12 types of triggers in PL/SQL that contains the combination of BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and ALL keywords.
- BEFORE ALL ROW INSERT
- AFTER ALL ROW INSERT
- BEFORE INSERT
- AFTER INSERT etc.
A trigger is automatically executed without any action required by the user, while, a stored procedure is explicitly invoked by the user.