Dear debas and friends,
1)what is the use of NOCOPY parameter?
2)function overloading
-------------------------------
which are the correct function overloading:
1) function f1(c in number)
return number
function f2(c in number)
return number
2) function f1(c in varchar)
return number
function f2(c in varchar)
return number
3)function f1(c in number)
return varchar
function f2(c in number)
return varchar
4)function f1(c in varchar)
return varchar
function f2(c in number)
return number
5) function f1(c in varchar)
return varchar
function f2(c in varchar)
return varchar
6) function f1(c in number)
return varchar
function f2(c in varchar)
return varchar
7)function f1(c in number)
return number
function f2(c in varchar)
return varchar
8)function f1(c in varchar)
return number
function f2(c in varchar)
return varchar
9)function f1(c in number)
return varchar
function f2(c in varchar)
return number
10)function f1(c in varchar)
return number
function f2(c in number)
return varchar
11)function f1(c in varchar)
return varchar
function f2(c in number)
return varchar
12)function f1(c in number)
return number
function f2(c in number)
return varchar
13)function f1(c in varchar)
return varchar
function f2(c in varchar)
return number
14)function f1(c in number)
return varchar
function f2(c in varchar)
return varchar
Thanks and reply..
Arun
6 11507
Function overloading means 2 or more functions with same name but with different signature.
In oracle function overloading can only be defined with in package.
None of your ex shows function overloading as name is different.
Example of FUNCTION OVERLOADING
-------------------------------------------------------------
Package specification -
CREATE OR REPLACE PACKAGE PKG_UTIL
-
AS
-
FUNCTION TRANS_DATE(DT IN DATE)RETURN NUMBER;
-
FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE;
-
END PKG_UTIL;
-
Package body -
CREATE OR REPLACE PACKAGE BODY PKG_UTIL AS
-
-
FUNCTION TRANS_DATE(DT IN DATE)RETURN NUMBER IS
-
BEGIN
-
RETURN ROUND((DT-TO_DATE('01011970','MMDDYYYY'))*86400);
-
END TRANS_DATE;
-
-
FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE IS
-
BEGIN
-
RETURN (TO_DATE('01011970','MMDDYYYY') +(DT/(86400)));
-
END TRANS_DATE;
-
-
END PKG_UTIL;
-
In this case the name of both the functions are same
But their signature is different.
while the first function accepts a date as parameter and returns a number
the 2nd accepts a number and returns a date.
The NOCOPY compiler hint increases the possibility of aliasing (that is, having two different names refer to the same memory location). This can occur when a global variable appears as an actual parameter in a subprogram call and then is referenced within the subprogram. The result is indeterminate because it depends on the method of parameter passing chosen by the compiler.
If you exit a subprogram successfully, PL/SQL assigns values to OUT parameters. However, if you exit with an unhandled exception, PL/SQL does not assign values to OUT parameters (unless they are NOCOPY parameters).
Restrictions on NOCOPY
=============================
The use of NOCOPY increases the likelihood of parameter aliasing.
Remember, NOCOPY is a hint, not a directive. In the following cases, the PL/SQL compiler ignores the NOCOPY hint and uses the by-value parameter-passing method;
No error is generated:
■ The actual parameter is an element of an associative array. This restriction does not apply if the parameter is an entire associative array.
■ The actual parameter is constrained, such as by scale or NOT NULL. This restriction does not apply to size-constrained character strings. This restriction does not extend to constrained elements or attributes of composite types.
■ The actual and formal parameters are records, one or both records were declared using %ROWTYPE or %TYPE, and constraints on corresponding fields in the records differ.
■ The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields in the records differ.
■ Passing the actual parameter requires an implicit datatype conversion.
■ The subprogram is called through a database link or as an external procedure.
Arun I Hope this much will suffice your purpose.
Restrictions on NOCOPY
=============================
The use of NOCOPY increases the likelihood of parameter aliasing.
Remember, NOCOPY is a hint, not a directive. In the following cases, the PL/SQL compiler ignores the NOCOPY hint and uses the by-value parameter-passing method;
No error is generated:
■ The actual parameter is an element of an associative array. This restriction does not apply if the parameter is an entire associative array.
■ The actual parameter is constrained, such as by scale or NOT NULL. This restriction does not apply to size-constrained character strings. This restriction does not extend to constrained elements or attributes of composite types.
■ The actual and formal parameters are records, one or both records were declared using %ROWTYPE or %TYPE, and constraints on corresponding fields in the records differ.
■ The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields in the records differ.
■ Passing the actual parameter requires an implicit datatype conversion.
■ The subprogram is called through a database link or as an external procedure.
Arun I Hope this much will suffice your purpose.
This helped me a lot. Thanks debas.
oohh, well and good..
thanks,
Arun..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Doran_Dermot |
last post by:
Hi All,
I've seen lots of code in which the attributes of a class are accessed and
modified using two separate methods. For example:
class Problems:
def __init__( self, refNum ):...
|
by: Dave Theese |
last post by:
Hello all,
I'm trying to get a grasp of the difference between specializing a function
template and overloading it. The example below has a primary template, a
specialization and an overload. ...
|
by: WittyGuy |
last post by:
Hi,
What is the major difference between function overloading and function
templates?
Thanks!
http://www.gotw.ca/resources/clcm.htm for info about ]
|
by: zeus |
last post by:
I know function overloading is not supported in C.
I have a few questions about this:
1. Why? is it from technical reasons? if so, which?
2. why wasn't it introduced to the ANSI?
3. Is there any...
|
by: JaSeong Ju |
last post by:
I would like to overload a C function. Is there any easy way to do this?
|
by: asdf |
last post by:
They looks so similar. Anybody would like to tell me their differences?
Thanks a lot.
|
by: lordkain |
last post by:
is it possible to do some kind of function overloading in c? and that
the return type is different
|
by: subramanian100in |
last post by:
The following is a beginner's question.
Suppose TYPE1 and TYPE2 are two types for which suitable ctors and
operator= are defined.
Suppose I have
class Test
{
TYPE1 mem1;
|
by: Matthew |
last post by:
Am I correct in thinking there is no method/function overloading of any
kind in any version of PHP?
Thanks,
Matthew
|
by: mesut |
last post by:
hi colleagues,
I don't know if this is the right group for but it's in C# so I try.
I have a #3 procedural function called GetInfo.. and those are 3
overloaded methods. I would like to use the...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |