rem This is a simple program to illustrate PL/SQL
rem An upper limit is passed as a parameter to the
rem program and the sum of the integers less equal that
rem value is calculated
set serveroutput on size 20000
declare
i binary_integer;
upper_limit binary_integer;
sum_ints binary_integer;
begin
-- Loop to add:
sum_ints := 0;
upper_limit := &1;
for i in 1..upper_limit loop
sum_ints := sum_ints + i;
end loop;
-- Display the total:
dbms_output.new_line;
dbms_output.put_line ('The sum of the integers from 1 to ' ||
upper_limit || ' is: ' || sum_ints);
end;
/