简体   繁体   中英

how to call an oracle procedure and a function inside another procedure

I have a situation, where I need to do the following.

Step1: Call a procedure with the given input values and get the 2 output values.

step2: Call the function with input parameters along with one of the output value from Step1(procedure call)

Step3: Extract the output value from the return value of Step2.

Please help, how to handle this situation.

Thanks

A very basic example, with made up variable names, data types (all numbers for simplicity) and procedure/function names and signatures:

create or replace procedure wrapper_proc as
  -- define local variables; use appropriate data types!
  l_input_1 number;
  l_input_2 number;
  l_output_1 number;
  l_output_2 number;
  l_result number;
begin
  -- Step1: Call a procedure with the given input values and get the 2 output values.
  l_input_1 := 42;
  l_input_2 := 128;
  your_proc (l_input_1, l_input_2, l_output_1, l_output_2);
  -- l_output_1 and l_output_2 are not set by that first procedire

  -- step2: Call the function with input parameters along with one of the output value from Step1(procedure call)
  -- assuming same two original inuts, and one of the procedure outputs...
  l_result := your_func (l_input_1, l_input_2, l_output_2);

  --Step3: Extract the output value from the return value of Step2.
  -- do something unspecified with l_result
  dbms_output.put_line('Final result was: ' || l_result);
end;
/

Or if you want to pass the input values into that wrapper procedure:

create or replace procedure wrapper_proc (
  -- arguments; use appropriate data types!
  p_input_1 number,
  p_input_2 number
) as
  -- define local variables; use appropriate data types!
  l_output_1 number;
  l_output_2 number;
  l_result number;
begin
  -- Step1: Call a procedure with the given input values and get the 2 output values.
  your_proc (p_input_1, p_input_2, l_output_1, l_output_2);
  -- l_output_1 and l_output_2 are not set by that first procedire

  -- step2: Call the function with input parameters along with one of the output value from Step1(procedure call)
  -- assuming same two original inuts, and one of the procedure outputs...
  l_result := your_func (p_input_1, p_input_2, l_output_2);

  --Step3: Extract the output value from the return value of Step2.
  -- do something unspecified with l_result
  dbms_output.put_line('Final result was: ' || l_result);
end;
/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM