DATABASE MANAGEMENT SYSTEM (DBMS – 313302)
UNIT IV – PL/SQL PROGRAMMING
Prepared by: Shreya Govande
Important 4 & 6 Marks Questions with Answers
Q: What is PL/SQL? Explain its structure.
Ans: PL/SQL (Procedural Language / SQL) is Oracle’s extension of SQL allowing procedural
programming. Structure: DECLARE – defines variables; BEGIN – executes logic; EXCEPTION –
handles errors; END – terminates block.
Q: What are the advantages of PL/SQL?
Ans: Reduces network traffic, supports modular programming, provides error handling, improves
performance.
Q: What is a cursor in PL/SQL?
Ans: A cursor is a pointer to the result set of a query. Types: Implicit (automatic) and Explicit (manual).
Used for row-by-row processing.
Q: What is a trigger?
Ans: A trigger is a stored PL/SQL program that executes automatically in response to database events
such as INSERT, UPDATE, DELETE.
Q: Explain control statements in PL/SQL with examples.
Ans: PL/SQL supports IF, CASE, LOOP, WHILE, and FOR. Example: FOR i IN 1..5 LOOP
DBMS_OUTPUT.PUT_LINE(i); END LOOP.
Q: Explain exception handling in PL/SQL.
Ans: Exceptions handle runtime errors. Syntax: BEGIN ... EXCEPTION WHEN NO_DATA_FOUND
THEN ... WHEN OTHERS THEN ... END;
Q: Explain different types of triggers.
Ans: Before, After, Row-level, Statement-level triggers. Example: CREATE TRIGGER log_delete
AFTER DELETE ON Student BEGIN INSERT INTO LogTable VALUES (USER, SYSDATE, 'Deleted
record'); END;
Q: Explain the use of stored procedures and functions.
Ans: Procedures perform tasks; functions return values. Example: CREATE FUNCTION
total_marks(roll INT) RETURN NUMBER IS ... RETURN t; END; Benefits: reusability, modularity,
performance.