How can I call a function inside a procedure in plsql

40,500

Solution 1

create or replace procedure P
    a_variable_name number;
begin
    a_variable := a_function('a parameter');
end;
/

Solution 2

Here is the sample code that will help you calling a function from a procedure.

    create or replace FUNCTION ADD_TEN(P_IN VARCHAR2) RETURN VARCHAR2
    AS
    L_RESULT VARCHAR2(4000);
    BEGIN
    L_RESULT:=P_IN+10;
    RETURN L_RESULT;
    END;



    create or replace PROCEDURE CALL_FUNCTON(P_IN VARCHAR2)
        AS
        L_FINAL_RESULT VARCHAR2(4000);
        BEGIN
        L_FINAL_RESULT:=ADD_TEN(P_IN);
        DBMS_OUTPUT.PUT_LINE(L_FINAL_RESULT);
        -- USE L_FINAL_RESULT IN YOUR BUSINESS LOGIC
        END;

EXECUTE CALL_FUNCTON(5);
Share:
40,500
Lara Dax
Author by

Lara Dax

Updated on November 02, 2020

Comments

  • Lara Dax
    Lara Dax over 3 years

    I want to call a function inside a procedure and get it's value so I can use within the procedure but I have no idea how to do that ?? Any ideas ?? My function is the following one , this function returns a collection of employees' ids whose salary out of the max or min salary , I want to use this value in a procedure to update the salaries of those employees to the minimum salary ??