0% found this document useful (0 votes)
16 views2 pages

Ice 7 Database

The document outlines the benefits of subprograms, including modularity, reusability, maintainability, performance, error handling, and encapsulation. It also provides an example of a PL/SQL query that utilizes user-defined exceptions, highlighting the advantages of exceptions such as graceful error handling, centralized management, clear debugging, and custom handling. Overall, it emphasizes the importance of structured programming and effective error management in software development.

Uploaded by

nkunalotricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Ice 7 Database

The document outlines the benefits of subprograms, including modularity, reusability, maintainability, performance, error handling, and encapsulation. It also provides an example of a PL/SQL query that utilizes user-defined exceptions, highlighting the advantages of exceptions such as graceful error handling, centralized management, clear debugging, and custom handling. Overall, it emphasizes the importance of structured programming and effective error management in software development.

Uploaded by

nkunalotricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Ice 7 database

What are the benefits of subprograms?


Benefits of Subprograms (Functions & Procedures)
 Modularity: Breaks code into smaller, manageable pieces.
 Reusability: Code can be reused across different parts of the application.
 Maintainability: Easier to update logic in one place.
 Performance: Optimized once and reused.
 Error Handling: Centralized error management.
 Encapsulation: Hides complexity from users.

Create 3 PL/SQL queries that have user-defined exceptions that were discussed in Learning
Unit 7.
DECLARE
salary_negative EXCEPTION;
employee_salary DECIMAL(10, 2) := -5000;
BEGIN
IF employee_salary < 0 THEN
RAISE salary_negative;
END IF;
DBMS_OUTPUT.PUT_LINE('Salary: ' || employee_salary);
EXCEPTION
WHEN salary_negative THEN
DBMS_OUTPUT.PUT_LINE('Error: Negative salary');
END;
what are the advantages of exceptions?
Advantages of Exceptions
1. Graceful Error Handling: Prevents program crashes and manages errors smoothly.
2. Centralized Management: Handles errors in one place, reducing redundancy.
3. Clear Debugging: Easier to identify issues with specific error messages.
4. Custom Handling: Define custom error conditions based on business logic.

You might also like