The document describes a student worksheet for a database management systems lab. It includes the student's name, class, semester, and ID. The task is to create a package with a procedure to calculate the average of user-entered numbers using a WHILE loop, stopping when 0 is entered. The code provided creates a package with a function to calculate the average of 3 input numbers and return the output. It is then called and the average displayed.
The document describes a student worksheet for a database management systems lab. It includes the student's name, class, semester, and ID. The task is to create a package with a procedure to calculate the average of user-entered numbers using a WHILE loop, stopping when 0 is entered. The code provided creates a package with a function to calculate the average of 3 input numbers and return the output. It is then called and the average displayed.
The document describes a student worksheet for a database management systems lab. It includes the student's name, class, semester, and ID. The task is to create a package with a procedure to calculate the average of user-entered numbers using a WHILE loop, stopping when 0 is entered. The code provided creates a package with a function to calculate the average of 3 input numbers and return the output. It is then called and the average displayed.
CLASS : 714 C SEMESTER : 3rd UID: 20BCS5039 SUBJECT : DBMS LAB
2. Create a package with procedure that shows the usage of
the WHILE loop to calculate the average of user entered numbers and entry of more numbers are stopped by entering number 0?
CODE :
--CREATION OF THE PACKAGE.
create or replace package WORKSHEET AS --HERE TO STORE AND DISPLAY THE OUTPUT THE PARAMETER PASSED INSIDE THE FUNCTION IS AVG1.
FUNCTION AVERAGE1(A in NUMBER,B in NUMBER,C in
NUMBER,AVG1 out NUMBER) return NUMBER; END;
--PACKAGE BODY create or replace PACKAGE BODY WORKSHEET AS FUNCTION AVERAGE1(A in NUMBER,B in NUMBER,C in NUMBER,AVG1 out NUMBER)
return NUMBER IS BEGIN
AVG1:=(A+B+C)/3;--THE ASSIGNMENT FOR THE
OUTPUT HAS BEEN DONE AS NO ASSIGNMENT TO INPUT IS POSSIBLE. return (AVG1); END AVERAGE1; END WORKSHEET; --CALLING DECLARE AVG1 NUMBER; BEGIN AVG1:=WORKSHEET.AVERAGE1(34,56,78,AVG1);