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 :)
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 :)
-
-
Create Function Addition
-
(
-
@Num1 Int,
-
@Num2 Int
-
)
-
Returns Int
-
As
-
Begin
-
Return(@Num1 + @Num2)
-
End
-
-
Select DBO.Addition(3, 5)
-
-
O/P
-
------------
-
8
-
-
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
:) :) :)
Hai richasaraf ,
U can create function only in in mode.but u can create procedure in 3 ways(in,out,in out)
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 -
-
create or replace procedure pro_name(a in number,b ijn number,c out number,d out number,e in out number) is
-
begin
-
c:=a+b;
-
d:=a-b;
-
e:=a+b-e;
-
end pro_name;
-
-
-
this procedure can be called like this
-
-
declare
-
sum number;
-
minus number;
-
var1 number:=2;
-
begin
-
------------
-
pro_name(10,5,sum,minus,var1);
-
-----------
-
---------
-
-------------
-
----------
-
end;
-
-
here sum will be 15(10+5)
minus will be 5(10-5)
var1 will be 13(10+5-2)
bye
see u
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. -
-
-
Create Or Replacr Function Telephone(PersonID number) Return Varchar2 Is
-
Cursor tel is
-
Select tel_telefono telefono
-
from tcli_telefono
-
where tel_codcli = PersonID;
-
--
-
vTelefonos varchar2(500) Default null;
-
vComa varchar2(1) := ',';
-
--
-
Begin
-
For reg in tel loop
-
vTelefonos := Reg.Telefono||vComa||vTelefonos;
-
--
-
End Loop;
-
Return( Rtrim(vTelefonos,','));
-
End Telephone;
-
-
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 -
-
-
CREATE OR REPLACE FUNCTION ADD(I NUMBER, J NUMBER)IS
-
K NUMBER;
-
BEGIN
-
K:=I+J;
-
RETURN(K);
-
END ADD;
-
-
-
--CALLING A FUNCTION:
-
-
DECLARE
-
N NUMBER;
-
BEGIN
-
N:=ADD(10,20);
-
DBMS_OUTPUT.PUT_LINE('THE ADDITION OF TWO NUMBERIS :'||N);
-
END;
-
-
-
--OR
-
-
-
SELECT ADD(10,20) FROM DUAL;
-
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
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
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. 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.
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
You can not use OUT parameters in function.
-Rohit
We can use OUT MODE in function as well. CHeck this: -
-
SQL> create or replace function add_num1(a IN NUMBER,b OUT NUMBER) RETURN NUMBER IS
-
2 BEGIN
-
3 dbms_output.put_line(a);
-
4 b:= a;
-
5 RETURN a;
-
6 END add_num1;
-
7 /
-
-
Function created.
-
-
SQL> var num1 number;
-
-
SQL> ed
-
Wrote file afiedt.buf
-
-
1 declare
-
2 ab number;
-
3 begin
-
4 ab:=add_num1(10,:num1);
-
5 dbms_output.put_line(:num1||','||ab);
-
6* end;
-
SQL> /
-
10
-
10,10
-
-
PL/SQL procedure successfully completed.
-
-
We cannot use this funciton from select statement: -
-
SQL> select add_num1(10,:num1) from dual;
-
select add_num1(10,:num1) from dual
-
*
-
ERROR at line 1:
-
ORA-06572: Function ADD_NUM1 has out arguments
-
-
You can use all the three modes in function .
find a related discussion here regarding function with IN OUT parameter.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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:...
|
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...
|
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...
|
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
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| | |