Answer to Question #258563 in Databases | SQL | Oracle | MS Access for Tarurendra Kushwah

Question #258563

Write a procedure and call it into main pl/sql program to find a factorial of a number.


1
Expert's answer
2021-10-31T12:06:40-0400
/*creating the procedure to find the factorial of a number*/
 CREATE PROCEDURE
my_factorial_procedure(IN my_number INT)
BEGIN
DECLARE my_result INT;
DECLARE j INT;
SET my_result=1;
SET j=1;
WHILE j<=my_number DO
SET my_result=my_result*j;
SET j=j+1;
END WHILE; SELECT my_number AS Number,my_result AS Factorial;
END;
/*we invoke this procedure by passing the value which we want to get the factorial as an argument*/
CALL my_factorial_procedure(2);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS