PL/SQL Program to add two numbers using function
Here you will learn that how to create PL/SQL program to add two numbers using function.
PL/SQL Program to add two numbers using function
1 2 3 4 5 6 7 8 | -- Create function CREATE OR REPLACE FUNCTION add_numbers(num1 IN NUMBER, num2 IN NUMBER) RETURN NUMBER IS sum_res NUMBER; -- Variable to store result BEGIN sum_res := num1 + num2; -- Add the numbers RETURN sum_res; -- Return result END; / |
Calling the Function:
1 2 3 4 5 6 7 | DECLARE result NUMBER; BEGIN result := add_numbers(50, 45); -- Call function with two numbers DBMS_OUTPUT.PUT_LINE('The sum of the two numbers is: ' || result); END; / |
Output
The sum of the two numbers is: 95
Check out our other PL/SQL programs examples