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 105446
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| | |