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.
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......
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.
we can use out parameter in function......We can also use Ref Cursor for returning more than one value in function...like as pkg and procedure...........
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...
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
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.
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.