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;
/

TRY IT YOURSELF

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.