So the assignments goes like this:
Make a PL/SQL function that takes in 2 parameters (exmaple p1 and p2). The function then has to calculate the sum of all the numbers between the range of p1 and p2. P1 doesn't always have to be smaller than P2.
The function returns the sum of the range.
The problem is that I don't understand the syntax of PL/SQL that well.
I have something like this but this only compares the numbers and returns the bigger number
DECLARE
a number;
b number;
c number;
FUNCTION findMax(x IN number, y IN number)
RETURN number
IS
z number;
BEGIN
IF x > y THEN
Z := x;
ELSE
Z:= y;
END IF;
RETURN z;
END;
BEGIN
a:= 23;
b:= 45;
c := findMax(a, b);
dbms_output.put_line(' The sum of all the numbers between (23,45): ' || c);
END;
/