473,811 Members | 3,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function Overloading

kiss07
99 New Member
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 11529
debasisdas
8,127 Recognized Expert Expert
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 Recognized Expert Expert
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 Recognized Expert Expert
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 Recognized Expert Expert
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 MVP
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 New Member
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
2174
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 ): self._refNum = refNum self._title = "" self._problem = ""
4
6493
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. Note that the overload is identical to the specialization except, of course, for the missing "template <>". I don't know if my questions will be a bit too broad or not, but I thought I'd give it shot... When is overloading preferable to...
16
16298
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 ]
39
2192
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 C implementation supporting this feature? I assume some of you will claim that there is no need in function overloading, so I would like to know your arguments too. Thanks,
45
3296
by: JaSeong Ju | last post by:
I would like to overload a C function. Is there any easy way to do this?
7
6133
by: asdf | last post by:
They looks so similar. Anybody would like to tell me their differences? Thanks a lot.
15
2789
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
2191
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;
10
3496
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
1653
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 OOP approach to refactor this. The functions are working fine but I would like to have a OOP approach can someone help me refactoring this??????
0
9731
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10393
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7671
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.