Plz clarryfy this.Scinario is whether we can use out mode in functions?.I thought it's not possible. But in interview they are asking this.if i am telling no,they are not accepting me.Plz clarify this anyone.

Showing Answers 1 - 25 of 25 Answers

Ramesh

  • Sep 28th, 2005
 

It is possible using out mode in functions.

Regards

Ramesh G

  Was this answer useful?  Yes

Tez

  • Oct 9th, 2005
 

Yes , PL/SQL provides an indirect way of returning values which are nothing but OUT parameters...... we specify the keyword OUT along with the name of the formal parameter...... If you know java....... this OUT parameter should get registered using the method registerOutParameter( )......... to specify the lack in value presently......

  Was this answer useful?  Yes

Sourabh

  • Oct 10th, 2005
 

Hi Friends,

We Can use the OUT parameter mode in the arguments to the function to return more than 1 value indirectly from the function.

Regards,

Sourabh

  Was this answer useful?  Yes

rajat_dba

  • Mar 3rd, 2006
 

yes we can use OUT parameter ... if you go thorough the difference between function and procedure you can easily understand it . regrdsrajat dey

  Was this answer useful?  Yes

create or replace function OutBoundFunc(outBnd out varchar2)
return varchar2
is
BEGIN
outBnd := 'Sukalyan';
return 'Chakraborty';
END;


and call like:

declare
myOutPar varchar2(300) := '';
myReturn varchar2(300) := '';
BEGIN
myReturn = outboundfunc(myOutPar);
dbms_output.Put_line(myReturn || '---' || myOutPar);
END;

  Was this answer useful?  Yes

malavika

  • Sep 20th, 2007
 

Can you plz explain the code you have written ?
Regds
Malavika

  Was this answer useful?  Yes

kailaskaki

  • Nov 16th, 2007
 

simple....First one is function and second block of code is block to call function.
while calling the function, return value will assign in one variable and out value will be in in out parameter...

  Was this answer useful?  Yes

ashishdixit

  • May 28th, 2008
 

i think this would solve your confusion...
CREATE OR REPLACE FUNCTION out_func (v_empno IN emp.empno%type,v_sal OUT emp.sal%type)
RETURN emp.ename%type
is
v_ename emp.ename%type;
BEGIN
select sal,ename into v_sal,v_ename from emp where empno = v_empno;
return (v_ename);
end;
/

--calling body

declare
var_to_hold_return_Val emp.ename%type;
var_to_hold_out_param emp.sal%type;
begin
var_to_hold_return_Val :=out_func(7369,var_to_hold_out_param);
dbms_output.put_line ('this value is returned using return clause ' ||var_to_hold_return_Val);
dbms_output.put_line ('this value is returned using out param  '||var_to_hold_out_param);
end;
/


--output

this value is returned using return clause SMITH
this value is returned using out param  800

PL/SQL procedure successfully completed.

  Was this answer useful?  Yes

vishadk

  • Mar 7th, 2010
 

I believe you are asking about the use of 'out' in the function declaration.
One can use 'Out' mode in the functions in the manner simlar to procedure i.e.

Create or Replace function fun_out_example
(parameter1  data_type,
 parameter2 out data_type)  
return data_type
is

The function fun_out_example gives the data_type and the parameter2 as the output.

  Was this answer useful?  Yes

There is no difference between function and package, except function must and should return a value while procedure do not.

But it is not a good practice to use out mode in functions.

However a default value is returned by return key word.

Ex: If you give one out mode, i.e. out + return key word, total 2 values are returned.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions