PL/SQL Array Sum - Plsql Typing CST Test
Loading…
PL/SQL Array Sum — Plsql Code
Sums elements of an array.
DECLARE
type num_array IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
nums num_array;
sum NUMBER := 0;
BEGIN
nums(1) := 1; nums(2) := 2; nums(3) := 3; nums(4) := 4; nums(5) := 5;
FOR i IN 1..5 LOOP
sum := sum + nums(i);
END LOOP;
DBMS_OUTPUT.PUT_LINE('Sum: ' || sum);
END;Plsql Language Guide
PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension to SQL. It combines SQL's data manipulation capabilities with procedural constructs like loops, conditions, and exceptions, enabling complex business logic execution directly within the database.
Primary Use Cases
- ▸Writing stored procedures and functions
- ▸Creating database triggers
- ▸Automating batch jobs
- ▸Data validation and business rule enforcement
- ▸Complex reporting and ETL tasks
Notable Features
- ▸Seamless SQL integration
- ▸Support for cursors and collections
- ▸Exception handling and error propagation
- ▸Procedural constructs: loops, conditions, variables
- ▸Package-based modular development
Origin & Creator
Developed by Oracle Corporation in the late 1980s to extend SQL with procedural capabilities.
Industrial Note
PL/SQL is the backbone of Oracle database applications, supporting triggers, stored procedures, and batch processing in enterprise environments.