calling a package function in oracle that has in and out parameter in a script

I have a package called
PKG_ESTIMATED_FREIGHT. This has a function called GET_ESTIMATED_FREIGHT
Function parameters are in_ship_id,in_recshp_id ( both are in parameters) one out parameter is out_method

I have a script and I need to call this function. How do I call that has an out parameter?

script is order_freight.

INSERT INTO adwaram.order_freight(ship_id,
                                                                   estimated_freight
-
-
-)
values(in_ship_id,
,DSS.PKG_ESTIMATED_FREIGHT.GET_ESTIMATED_FREIGHT(NULL,c_inbound_rec.recshp_id,v_method)
-
-
-
-
)
v_method I have declared as varchar2(2000);

getting an error

ORA-06572: Function GET_ESTIMATED_FREIGHT has out arguments
ORA-06512: at line 111
LVL 6
anumosesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
call the function first, with a variable for the out parameter
then run the insert

as we don't have your function definition, i'm assuming all numbers for the params
no risk in copying the function definition header

declare
  fval number;
  v_method number;
begin
  -- set value of c_inbound_rec.recship 
  -- set value of v_method
  fval := DSS.PKG_ESTIMATED_FREIGHT.GET_ESTIMATED_FREIGHT(NULL,c_inbound_rec.recshp_id,v_method);
  INSERT INTO adwaram.order_freight(ship_id,estimated_freight) values (in_ship_id, fval);
end;
/

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ganesh GuruduSenior ConsultantCommented:
light change in Greet code.

declare

  v_method varchar2(2000);
begin
  -- set value of c_inbound_rec.recship 
  -- set value of v_method
select DSS.PKG_ESTIMATED_FREIGHT.GET_ESTIMATED_FREIGHT(NULL,c_inbound_rec.recshp_id,v_method) from dual;
  INSERT INTO adwaram.order_freight(ship_id,estimated_freight) values (in_ship_id, v_method);
end;
/

Open in new window

0
slightwv (䄆 Netminder) Commented:
>>light change in Greet code.

You need to SELECT INTO to capture the output of the function.  Even after you add that, you shouldn't do it that way.  It does an unnecessary context switch.

Go with the method Geert posted.  It should be the most efficient.
0
Ganesh GuruduSenior ConsultantCommented:
@slightwv
Thanks for the correction.

In a case this function will return 2 values ( 1 is return value and the out parameter)

fval := DSS.PKG_ESTIMATED_FREIGHT.GET_ESTIMATED_FREIGHT(NULL,c_inbound_rec.recshp_id,v_method);
and the insert should have v_method variable as per the requirement. if the user needs return value to insert then this is good.

INSERT INTO adwaram.order_freight(ship_id,estimated_freight) values (in_ship_id, v_method);
0
anumosesAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.