FUNCTION TO CALCULATE THE PRODUCT OF TWO NUMBERS AND RETURN THEIR VALUES IN ORACLE?



SQL> DECLARE
   2  A NUMBER;
   3  B NUMBER;
   4  ANSWER NUMBER;
   5  FUNCTION PRODUCT(A NUMBER, B NUMBER) RETURN  
   NUMBER
   6  AS C NUMBER;
   7  BEGIN
   8  C:=A*B;
   9  RETURN(C);
  10  END PRODUCT;
  11  BEGIN
  12  A:=&A;
  13  B:=&B;
  14  ANSWER:=PRODUCT(A,B);
  15  DBMS_OUTPUT.PUT_LINE('THE PRODUCT OF TWO
   NUMBERS IS  '||ANSWER);
  16  END;
  17  /
 Enter value for a: 8
 old  12: A:=&A;
 new  12: A:=8;
 Enter value for b: 5
 old  13: B:=&B;
 new  13: B:=5;
 THE PRODUCT OF TWO NUMBERS IS  40

 PL/SQL procedure successfully completed.

 SQL> START MULTI.SQL;
 Enter value for a: 6
 old  12: A:=&A;
 new  12: A:=6;
 Enter value for b: 5
 old  13: B:=&B;
 new  13: B:=5;
 THE PRODUCT OF TWO NUMBERS IS  30

 PL/SQL procedure successfully completed.

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart