PL/SQL Interview Questions – Set 02

Explain the Rollback statement?

The Rollback statement is issued when the transaction ends. Following conditions are true for a Rollback statement:

  • The work done in a transition is undone as if it was never issued.
  • All locks acquired by transaction are released.

Write a unique difference between a function and a stored procedure.

A function returns a value while a stored procedure doesn?t return a value.

What is the difference between the implicit and explicit cursors?

Implicit cursor is implicitly declared by Oracle. This is a cursor to all the DDL and DML commands that return only one row.

Explicit cursor is created for queries returning multiple rows.

What is a trigger in PL/SQL?

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.

Which command is used to delete a package?

The DROP PACKAGE command is used to delete a package.

How to execute a stored procedure?

There are two way to execute a stored procedure.

From the SQL prompt, write EXECUTE or EXEC followed by procedure_name.

EXECUTE or [EXEC] procedure_name;
Simply use the procedure name

procedure_name;

What is the basic structure of PL/SQL?

PL/SQL uses BLOCK structure as its basic structure. Each PL/SQL program consists of SQL and PL/SQL statement which form a PL/SQL block.

PL/SQL block contains 3 sections.

  • The Declaration Section (optional)
  • The Execution Section (mandatory)
  • The Exception handling Section (optional)

Which command is used to delete a trigger?

DROP TRIGGER command.

Explain the SAVEPOINT statement.

With SAVEPOINT, only part of transaction can be undone.

How exception is different from error?

Whenever an Error occurs Exception arises. Error is a bug whereas exception is a warning or error condition.