473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 11507
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 Problems: def __init__( self, refNum ):...
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 primary template, a specialization and an overload. ...
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 info about ]
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 wasn't it introduced to the ANSI? 3. Is there any...
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 have class Test { TYPE1 mem1;
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 are 3 overloaded methods. I would like to use the...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
0
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...
0
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...
1
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)...
0
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...
0
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....

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.