473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PL/SQL - Can function have OUT, IN OUT parameter ?

Hi guys,
Can someone help me...
I want to know... can we have OUT, IN OUT parameters in function? :confused:
And can we use it in select statement ?

Thanks a lot !
Take Care

Richa :)
Jul 10 '06 #1
13 105406
Yes, we have in-out parameter in function. we can use it in select statement.
we can have more than one OUT parameter in function.But to execute this unction all this function in anonomous block and use dbms_output.put_line :)
Jul 27 '06 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2. Create Function Addition
  3. (
  4. @Num1 Int,
  5. @Num2 Int
  6. )
  7. Returns Int
  8. As
  9. Begin
  10.  Return(@Num1 + @Num2)
  11. End
  12.  
  13. Select DBO.Addition(3, 5) 
  14.  
  15. O/P
  16. ------------
  17. 8
  18.  
  19.  

we have create one function which accepts two parameters and will return one value in place of its name. thus, the fucntions which accepts parameters, these are inputs and what fucntion return, is output.

Mahesh
:) :) :)
Jul 31 '06 #3
vijil
14
Hai richasaraf ,
U can create function only in in mode.but u can create procedure in 3 ways(in,out,in out)
Aug 8 '06 #4
hellow man
u cant create a function that have morethan one out variable
a function is that it gets any number of inputs and returns only one value
A procedure can help u to satisfy ur needs .A procedure can have any number of in (input) variables and any number of out(return variable)variables.
A procedure can have variables that acts as both in and out variables

Expand|Select|Wrap|Line Numbers
  1.  
  2. create or replace procedure pro_name(a in number,b ijn number,c out number,d out number,e in out number) is
  3. begin
  4.     c:=a+b;
  5.     d:=a-b;
  6.     e:=a+b-e;
  7. end pro_name;
  8.  
  9.  
  10. this procedure can be called like this
  11.  
  12. declare
  13. sum number;
  14. minus number;
  15. var1 number:=2;
  16. begin
  17. ------------
  18. pro_name(10,5,sum,minus,var1);
  19. -----------
  20. ---------
  21. -------------
  22. ----------
  23. end;
  24.  
  25.  
here sum will be 15(10+5)
minus will be 5(10-5)
var1 will be 13(10+5-2)
bye
see u
Aug 29 '06 #5
Dear Richa
a function only return one value, only accep parameters IN not IN OUT or OUT.
eg. Create or Replace Function Richa (var1 number, var2 in varchar2) Return Date, Varchar2 or number.

example.
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Create Or Replacr Function Telephone(PersonID number) Return Varchar2 Is
  4. Cursor tel is
  5.  Select tel_telefono telefono
  6.    from tcli_telefono
  7.   where tel_codcli = PersonID;
  8. --
  9. vTelefonos  varchar2(500) Default null;
  10. vComa       varchar2(1)   := ',';
  11. --
  12. Begin
  13.  For reg in tel loop
  14.   vTelefonos := Reg.Telefono||vComa||vTelefonos;
  15.   --
  16.  End Loop;
  17.   Return( Rtrim(vTelefonos,','));
  18. End Telephone;
  19.  
  20.  
Aug 31 '06 #6
a Function returns Exactly only one value. we canot use the OUT parameter in function.
and also we can call a function from SQL prompt.

for Example
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. CREATE OR REPLACE FUNCTION ADD(I NUMBER, J NUMBER)IS
  4. K NUMBER;
  5. BEGIN
  6. K:=I+J;
  7. RETURN(K);
  8. END ADD;
  9.  
  10.  
  11. --CALLING A FUNCTION:
  12.  
  13. DECLARE
  14. N NUMBER;
  15. BEGIN
  16. N:=ADD(10,20);
  17. DBMS_OUTPUT.PUT_LINE('THE ADDITION OF TWO NUMBERIS :'||N);
  18. END;
  19.  
  20.  
  21. --OR
  22.  
  23.  
  24. SELECT ADD(10,20) FROM DUAL;
  25.  
Sep 4 '06 #7
Hi guys,
Can someone help me...
I want to know... can we have OUT, IN OUT parameters in function? :confused:
And can we use it in select statement ?

Thanks a lot !
Take Care

Richa :)

hi
function can have out arguments also. if the function has an out arguments then we can't use it in select or dml statments
Nov 2 '06 #8
Hi guys,
Can someone help me...
I want to know... can we have OUT, IN OUT parameters in function? :confused:
And can we use it in select statement ?

Thanks a lot !
Take Care

Richa :)

hi
function can have out arguments also. if the function has an out arguments then we can't use it in select or dml statments

Thanks and Regards
saravanan p
Nov 2 '06 #9
debasisdas
8,127 Expert 4TB
Hi guys

We can use all the three parameter modes (IN,OUT, IN OUT ) in a function.

Please find the details regarding PL/SQL Function.
Jun 28 '07 #10
Saii
145 Expert 100+
yes, a function can have all three modes for parameters but underlying fact is that function should return only one value. So it is better to restrict the function parameter mode to IN, in case you want to have a functionality wherein you have an OUT parameter, use a procedure instead.
Jun 28 '07 #11
Hi guys,
Can someone help me...
I want to know... can we have OUT, IN OUT parameters in function? :confused:
And can we use it in select statement ?

Thanks a lot !
Take Care

Richa :)
You can not use OUT parameters in function.

-Rohit
Dec 12 '07 #12
amitpatel66
2,367 Expert 2GB
You can not use OUT parameters in function.

-Rohit
We can use OUT MODE in function as well. CHeck this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> create or replace function add_num1(a IN NUMBER,b OUT NUMBER) RETURN NUMBER IS
  3.   2  BEGIN
  4.   3  dbms_output.put_line(a);
  5.   4  b:= a;
  6.   5  RETURN a;
  7.   6  END add_num1;
  8.   7  /
  9.  
  10. Function created.
  11.  
  12. SQL> var num1 number;
  13.  
  14. SQL> ed
  15. Wrote file afiedt.buf
  16.  
  17.   1  declare
  18.   2  ab number;
  19.   3  begin
  20.   4  ab:=add_num1(10,:num1);
  21.   5  dbms_output.put_line(:num1||','||ab);
  22.   6* end;
  23. SQL> /
  24. 10
  25. 10,10
  26.  
  27. PL/SQL procedure successfully completed.
  28.  
  29.  
We cannot use this funciton from select statement:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> select add_num1(10,:num1) from dual;
  3. select add_num1(10,:num1) from dual
  4.        *
  5. ERROR at line 1:
  6. ORA-06572: Function ADD_NUM1 has out arguments
  7.  
  8.  
Dec 12 '07 #13
debasisdas
8,127 Expert 4TB
You can use all the three modes in function .

find a related discussion here regarding function with IN OUT parameter.
Dec 12 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: pablo | last post by:
Dear Newsgroupers, The 'main' page contains a call to a function in an included file. This function puts a html-form on the screen. Before the form gets posted (to the 'main' page) some prior...
1
by: Alex Vinokur | last post by:
========================= Windows 2000 Professional Digital Mars C/C++ 8.36 STLport 4.5.3 ========================= I have got a problem with compilation of the following piece of code using...
10
by: rg | last post by:
Hi all, I was wondering if anyone had dealt with a similar problem. I need to use a template function as the parameter for a particular function (also template function). The program compiles...
6
by: komal | last post by:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function...
10
by: Juke All | last post by:
When I compile the code (below), I get this error: cannot convert parameter 1 from 'int' to 'union dna' Without saying: FOO x; x.val = 100; ....is it possible to use a union as a function...
5
by: Rolf Wester | last post by:
Hi, I want to pass a C-function as a function parameter but I don't know how to that correctly. In the example below how would I have to declare the function argument in the my_sort function...
2
by: Glenn Lerner | last post by:
If I pass a reference type (such as DataSet) to a function, I'm assuming only a reference is passed (not a copy). So there is no need to declare function parameter as ref for those types? Example:...
5
by: Joe | last post by:
Hi, I like to know what do you specify in the function parameter (in the function implementation) if you want the string that you pass in with the function call to be changed while its in the...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
3
by: giloosh | last post by:
can i pass a hash as a function parameter. ive seen it been used before but i can't figure out how to do it. i would like to call a function like this for example ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.