Day-16 Interview Questions
Day-16 Interview Questions
PL/SQL is important in database development because it allows for more complex and
flexible operations than SQL alone. It enables developers to create reusable code,
enforce business rules, and handle errors effectively within the database.
3. How can you handle exceptions in PL/SQL, and why is exception handling
important?
In PL/SQL, you can handle exceptions using the EXCEPTION block. Exception
handling is crucial because it helps control the flow of the program in the presence of
errors, ensuring that the application can respond gracefully to unexpected issues.
You can create a stored procedure using the CREATE OR REPLACE PROCEDURE
statement, followed by the procedure's name, input parameters, and the procedural
code block.
Local variables are declared within a stored procedure and are only accessible within
that procedure. Global variables are typically declared at the database level and can be
accessed by multiple stored procedures.
8. What is a trigger, and how does it work in a database?
You can create a trigger using the CREATE TRIGGER statement, specifying the event
(e.g., AFTER INSERT), the triggering table, and the trigger code block.
10. What are the common use cases for "AFTER INSERT," "AFTER UPDATE," and
"AFTER DELETE" triggers?
"AFTER INSERT" triggers are used for actions that follow the insertion of new data.
"AFTER UPDATE" triggers are used for actions following data updates, and "AFTER
DELETE" triggers are used for actions after data deletion, such as logging changes or
maintaining referential integrity.