AIM:
To find the sum of series in SQL.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the number of terms n.
Step 3: Start the loop.
Step 4: Compute the sum.
Step 5: Increment the sum.
Step 6: Exit the loop.
Step 7: Output the sum.
Step 8: Stop the program.
PROGRAM:
SQL> set serveroutput on
SQL> declare
2 n number(3):=&n;
3 i number(3):=1;
4 x number(3):=0;
5 begin
6 loop
7 x:=x+i;
8 exit when i=n;
9 i:=i+1;
10 end loop;
11 dbms_output.put_line('sum='x);
12 end;
13 /
EmoticonEmoticon