The questions can come in any order, so make sure you are selecting right option for all questions.
PL/SQL Simple BlocksWrite a PL/SQL simple procedure named computeArea which accepts 4 parameters. The first parameter is radius of type number. The remaining are output parameters in the order area, diameter and circumference. This procedure is used to compute area, diameter and circumference of the circle. Declare one constant variable PI and initialize with the value 3.142.
Hint:
Area of a circle = pi * radius2
Circumference = 2 * pi * r
Diameter = 2 * r
Use the below skeleton:
Procedure name: computeArea
Input parameters: radius of type number
Output parameters: area of type number, diameter of type number and circumference of type number.
Note:
Do not change the procedure name
Do not change the argument count and order
Do not change the output text.
Instructions:
1. Create the procedure successfully
2. Once the procedure is created, check the functionality of the procedure using different anonymous block call.
3. DO NOT submit the anonymous block. Submit only the CREATE PROCEDURE query.
CREATE OR REPLACE PROCEDURE computeArea( radius IN NUMBER, area OUT NUMBER, diameter OUT NUMBER, circumference OUT NUMBER ) IS PI CONSTANT NUMBER := 3.142; BEGIN area := PI * POWER(radius, 2); diameter := 2 * radius; circumference := 2 * PI * radius; END; / SET SERVEROUTPUT ON; DECLARE r NUMBER := 5; a NUMBER; d NUMBER; c NUMBER; BEGIN computeArea(r, a, d, c); DBMS_OUTPUT.PUT_LINE(a); DBMS_OUTPUT.PUT_LINE(d); DBMS_OUTPUT.PUT_LINE(c); END; /