472,328 Members | 1,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Function Overloading

kiss07
99
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
May 7 '07 #1
6 11399
debasisdas
8,127 Expert 4TB
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.
May 7 '07 #2
debasisdas
8,127 Expert 4TB
Example of FUNCTION OVERLOADING
-------------------------------------------------------------
Package specification
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE PKG_UTIL
  2. AS
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER;
  4. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE;
  5. END PKG_UTIL;
  6.  
Package body
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE BODY PKG_UTIL AS
  2.  
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER IS
  4. BEGIN
  5. RETURN ROUND((DT-TO_DATE('01011970','MMDDYYYY'))*86400);
  6. END TRANS_DATE;
  7.  
  8. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE IS
  9. BEGIN
  10. RETURN (TO_DATE('01011970','MMDDYYYY') +(DT/(86400)));
  11. END TRANS_DATE;
  12.  
  13. END PKG_UTIL;
  14.  
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.
May 7 '07 #3
debasisdas
8,127 Expert 4TB
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).
May 7 '07 #4
debasisdas
8,127 Expert 4TB
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.
May 7 '07 #5
r035198x
13,262 8TB
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.
May 7 '07 #6
kiss07
99
oohh, well and good..

thanks,

Arun..
May 7 '07 #7

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

Similar topics

7
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...
4
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...
16
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...
39
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...
45
by: JaSeong Ju | last post by:
I would like to overload a C function. Is there any easy way to do this?
7
by: asdf | last post by:
They looks so similar. Anybody would like to tell me their differences? Thanks a lot.
15
by: lordkain | last post by:
is it possible to do some kind of function overloading in c? and that the return type is different
10
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...
10
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
14
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.