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.