Practical Practice 11

Oracle Practice
Write a program to find power of any number x ^ y in PLSQL block.
Write a program to find power of any number x ^ y in PLSQL block.
SOLUTION
--Static code
set serveroutput on
DECLARE
x NUMBER := 3;
y NUMBER := 2;
result NUMBER := 1;
BEGIN
result := power(x,y);
DBMS_OUTPUT.PUT_LINE('Result of ' || x || ' ^ ' || y || ' = ' || result);
END;

--Dynamic code
set serveroutput on
DECLARE
x NUMBER := &x;
y NUMBER := &y;
result NUMBER := 1;
BEGIN
result := power(x,y);
DBMS_OUTPUT.PUT_LINE('Result of ' || x || ' ^ ' || y || ' = ' || result);
END;
/

--Dynamic code set serveroutput on DECLARE x NUMBER := &x; y NUMBER := &y; result NUMBER := 1; BEGIN result := power(x,y); DBMS_OUTPUT.PUT_LINE('Result of ' || x || ' ^ ' || y || ' = ' || result); END; /