Function overloading advantage..

Hi,
One of the package feature is function overloading i.e same name objects with different parameters or different datatype parameters.
how does it(function overloading) increase the performance ?
what are the benefits with function overloading ?
Thanks in advance.
RP

how does it(function overloading) increase the performance ?It doesn't.
what are the benefits with function overloading ?Consider this:
SQL> CREATE OR REPLACE PACKAGE pkg AS
  2     PROCEDURE print(p IN VARCHAR2);
  3     PROCEDURE print(p IN DATE, msk IN VARCHAR2 := 'DD-MON-YYYY');
  4     PROCEDURE print(p IN NUMBER);
  5     PROCEDURE print(p IN VARCHAR2, totem IN VARCHAR2);
  6  END;
  7  /
Package created.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY  pkg AS
  2   PROCEDURE print(p IN VARCHAR2) IS
  3   BEGIN
  4    dbms_output.put_line(p||'!');
  5   END;
  6   PROCEDURE print(p IN DATE, msk IN VARCHAR2 := 'DD-MON-YYYY' ) IS
  7   BEGIN
  8    print(to_char(p, msk));
  9   END;
10   PROCEDURE print(p IN NUMBER) IS
11   BEGIN
12    print(to_char(p));
13   END;
14   PROCEDURE print(p IN VARCHAR2, totem IN VARCHAR2) IS
15   BEGIN
16    print(totem||' '||p);
17   END;
18  END;
19  /
Package body created.
SQL>
SQL> set serveroutput on
SQL>
SQL> exec pkg.print(user)
B!
PL/SQL procedure successfully completed.
SQL> exec pkg.print(sysdate)
07-MAR-2006!
PL/SQL procedure successfully completed.
SQL> exec pkg.print(sysdate, 'HH24:MI:SS')
11:18:59!
PL/SQL procedure successfully completed.
SQL> exec pkg.print(1234)
1234!
PL/SQL procedure successfully completed.
SQL> exec pkg.print(user, '>>>')
B!PL/SQL procedure successfully completed.
SQL> exec pkg.print(to_char(sysdate), 'HH24:MI:SS')
HH24:MI:SS 07-MAR-06!
PL/SQL procedure successfully completed.
SQL> I can pass any value into my package without having to worry about its datatype. Similarly I can pass different numbers of arguments into the procedure without worrying. Of course, a similar effect can be gained from using default values but we don't always want that.
Incidentally, note what happened when I passed in a date as a character string.
Cheers, APC

Similar Messages

  • Function Overloading concept in PL/SQL

    hi all,
    do we have Function Overloading concept in PL/SQL? If so, how to implement it? can anybody help me out with an example?

    Yep.
    SQL> create or replace
      2  package test_package as
      3
      4     function blah(param IN NUMBER) return number;
      5     function blah(param IN DATE) return number;
      6     function blah(param IN VARCHAR2) return number;
      7
      8     -- or
      9
    10     function blah(param IN NUMBER) return date;
    11     function blah(param IN NUMBER) return varchar2;
    12     function blah(param IN NUMBER) return char;
    13
    14  end test_package;
    15  /
    Package created.

  • Function Overloading in PL/SQL

    Hi Guyz,
    I have 2 questions regarding function overloading.
    1) Is it necessary for the functions to be inside a package to perform function overloading ?
    2) I have 2 functions :-
    a) function check_hello( P_INPUT1 VARCHAR2, P_INPUT2 NUMBER) RETURN BOOLEAN
    b) function check_hello( P_INPUT1 VARCHAR2, P_INPUT2 NUMBER) RETURN VARCHAR2
    The difference is the return type . I dont think this is possible since the signature of the arguments are the same. I just need to confirm that its not possible.
    Thanks.

    Hi,
    user3913664 wrote:
    Hi Guyz,
    I have 2 questions regarding function overloading.
    1) Is it necessary for the functions to be inside a package to perform function overloading ?Yes; stand-alone functions cannot be overloaded.
    2) I have 2 functions :-
    a) function check_hello( P_INPUT1 VARCHAR2, P_INPUT2 NUMBER) RETURN BOOLEAN
    b) function check_hello( P_INPUT1 VARCHAR2, P_INPUT2 NUMBER) RETURN VARCHAR2
    The difference is the return type . I dont think this is possible since the signature of the arguments are the same. I just need to confirm that its not possible.Exactly. How could you, the system, or anyone else determine which one to use?
    Give them different names, or add another argument if you really want them to have the same name.

  • Will ellipsis contradict function overloading

    Recently I was reading the Oracle tech magazin. There was an article in it about the next java major release ( J2SE 1.5 tiger). It said the tiger release will support the ellipsis ("...") concept for parameter passing. I have seen this in C/C++ for passing variable number of arguments in functions like printf() or scanf(). I am not sure has there such a concept already in java but if we are going to have such a mechanism, wont that affect the function overloading concept? Please post ur opinions
    thanks
    boolee

    The method will have a signature ending in (I think the current spec says) Object[], so it shouldn't affect the method overloading much.

  • Function overloading in flex?

    Hi
    Is it possible to function overloading in flex?
    Any send me example.
    Regards
    D.Mahesh Babu

    ActionScript aims to follow the EcmaScript 4 language specification which does not include method overloading. The two have diverged somewhat because EcmaScript 4 is still in a proposal stage and is subject to change. Read more here:
    http://en.wikipedia.org/wiki/ECMAScript
    A proposed EcmaScript feature called generic functions may offer capabilties similar to method overloading. It is possible such a feature may find its way into ActionScript 4, but I'm not aware of any official announcements to that effect.

  • Function overloading ... Is there any benefit ?

    Where is the benefit if I write this ..
    using function overloading :
    add(Integer, Integer);
    add(String, String);
    instead of
    addInt(Integer, Integer);
    addStr(String, String);
    Is there any benefit ?

    why you are saying "add() *does not contain an argument type name*"?The statement that you are still claiming to find unclear was 'embed the argument type names in the function name'. The function name 'add()' doesn't do that. Your alternative function name 'addInt() does do that. 'Int'. A type name. Embedded in the function name.
    Am I missing something ?Yes. I don't see how you can agree that add() is shorter than addInt() without also seeing that the difference consists precisely of the embedded type name. Frankly, I don't think you have been reading very carefully.

  • Function Overloading in sql

     is there any way by which one can over load function with out affecting any change in .net code or sql proc or function which refer that function

    No, there is no way to "overload" a function.
    However, what you are describing can be done by creating a layer of stored procs and views the .Net code calls instead of direct accessing the database.  This gives the SQL developer the ability to change the physical database and change the layer
    to match the same output, without changing the .Net code.
    See "Stored procedures vs dynamic SQL":
    http://msdn.microsoft.com/en-us/library/ee658127.aspx

  • Function overloading on return types

    consider following two overloaded functions
    public int functionA(int a,int b);
    public char functionA(int a,int b)and if i call them like this
    int returnInt = functionA(a,b)
    char returnChar = functionA(a,b)in this scenario which function to call can be decided depending on the
    return type then why java don have overloading on the basis of return type ?

    Try it.

  • Query Compilation Error - Function overloaded

    I'm trying to use 2 document style web services in a query. When I test the query
    I get:
    tart server side stack trace:
    java.rmi.RemoteException: EJB Exception:; nested exception is:
         java.rmi.RemoteException: Query Compilation Error (Type Checks) 1-3-1-3: Function
    Employees1:ProcessDocument() is overloaded.
    java.rmi.RemoteException: Query Compilation Error (Type Checks) 1-3-1-3: Function
    Employees1:ProcessDocument() is overloaded.
         at com.bea.ldi.server.QueryBean.execute(Unknown Source)
         at com.bea.ldi.server.QueryBean_1ao78o_EOImpl.execute(QueryBean_1ao78o_EOImpl.java:306)
         at com.bea.ldi.server.QueryBean_1ao78o_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:821)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    End server side stack trace
    Can someone tell me what this error means?
    Thank you,
    Jason

    Release Note Entry:
    When designing Workshop web services, you may need to alter the
    Targetnamespace for a web service if a method name in this web service
    clashes with a method name in another web service that uses the same
    Targetnamespace.
    "Mike Reiche" <[email protected]> wrote:
    >
    "A function with the same name has multiple definitions in the configuration.
    Check
    you configuration"
    Check for multiple definitions of Employees1:ProcessDocument() in your
    CFLD file(s).
    - Mike
    "Jason Levine" <[email protected]> wrote:
    I'm trying to use 2 document style web services in a query. When I test
    the query
    I get:
    tart server side stack trace:
    java.rmi.RemoteException: EJB Exception:; nested exception is:
         java.rmi.RemoteException: Query Compilation Error (Type Checks) 1-3-1-3:
    Function
    Employees1:ProcessDocument() is overloaded.
    java.rmi.RemoteException: Query Compilation Error (Type Checks) 1-3-1-3:
    Function
    Employees1:ProcessDocument() is overloaded.
         at com.bea.ldi.server.QueryBean.execute(Unknown Source)
         at com.bea.ldi.server.QueryBean_1ao78o_EOImpl.execute(QueryBean_1ao78o_EOImpl.java:306)
         at com.bea.ldi.server.QueryBean_1ao78o_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:821)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    End server side stack trace
    Can someone tell me what this error means?
    Thank you,
    Jason

  • JSP 2.0 EL Function Overloading

    Can methods defined as EL functions be overloaded?
    I have a class with two overloaded methods. Both of them are declared with "public static" and one of them is defined as an EL function through a taglib. When trying to invoke the method defined as an EL function, I get an error indicating it's trying to run the other version of the method, not the version defined as an EL function.
    What's weird is that if I rearrange the order of the overloaded methods in my class it works fine. It's as if EL is just looking for the first method with a name matching what's defined in the tablib and attempting to run it.
    I'm running WebLogic Server 10 on WinXP.

    Either declare it non-public or assign it another name.

  • Pl/sql function overload package program and how to execute

    --creation overload package
    create or replace package pkg_overload is
    procedure get_emp(p_empid in number,p_empsal out number);
    procedure get_emp(p_ename in varchar2, p_empsal out number);
    end;
    -- define its body
    create or replace package body pkg_overload is
    procedure get_emp(p_empid in number,p_empsal out number) is
    begin
    select sal
    into p_empsal
    from emp
    where empno=p_empid;
    end;
    procedure get_emp (p_ename in varchar2,p_empsal out number) is
    begin
    select sal
    into p_empsal
    from emp
    where ename=p_ename;
    end;
    end pkg_overload;
    /* output of this :PACKAGE pkg_overload compiled
    Warning: execution completed with warning
    -- My question is about the warning and how to execute it
    --I tried that way to execute that program
    /*variable g_sal number;
    execute pkg_overload.get_emp(77934,:g_sal);
    RESULT
    Error starting at line 911 in command:
    execute pkg_overload.get_emp(77934,:g_sal)
    Error report:
    ORA-06550: line 1, column 7:
    PLS-00905: object SUBHAJIT.PKG_OVERLOAD is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    emp table code
    -- File created - Thursday-April-12-2012
    -- DDL for Table EMP
    CREATE TABLE "SUBHAJIT"."EMP"
    (     "EMPNO" NUMBER(4,0),
         "ENAME" VARCHAR2(10 BYTE),
         "JOB" VARCHAR2(9 BYTE),
         "MGR" NUMBER(4,0),
         "HIREDATE" DATE,
         "SAL" NUMBER(7,2),
         "COMM" NUMBER(7,2),
         "DEPTNO" NUMBER(2,0)
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "USERS" ;
    REM INSERTING into SUBHAJIT.EMP
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,null,20);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,300,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,500,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7566,'JONES','MANAGER',7839,to_date('02-APR-81','DD-MON-RR'),2975,null,20);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7654,'MARTIN','SALESMAN',7698,to_date('28-SEP-81','DD-MON-RR'),1250,1400,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7698,'BLAKE','MANAGER',7839,to_date('01-MAY-81','DD-MON-RR'),2850,null,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7782,'CLARK','MANAGER',7839,to_date('09-JUN-81','DD-MON-RR'),2450,null,10);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7788,'SCOTT','ANALYST',7566,to_date('09-DEC-82','DD-MON-RR'),3000,null,20);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7839,'KING','PRESIDENT',null,to_date('17-NOV-81','DD-MON-RR'),5000,null,10);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7844,'TURNER','SALESMAN',7698,to_date('08-SEP-81','DD-MON-RR'),1500,0,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7876,'ADAMS','CLERK',7788,to_date('12-JAN-83','DD-MON-RR'),1100,null,20);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7900,'JAMES','CLERK',7698,to_date('03-DEC-81','DD-MON-RR'),950,null,30);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7902,'FORD','ANALYST',7566,to_date('03-DEC-81','DD-MON-RR'),3000,null,20);
    Insert into SUBHAJIT.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7934,'MILLER','CLERK',7782,to_date('23-JAN-82','DD-MON-RR'),1300,null,10);
    -- Constraints for Table EMP
    ALTER TABLE "SUBHAJIT"."EMP" MODIFY ("EMPNO" NOT NULL ENABLE);
    Edited by: 923746 on Apr 12, 2012 1:18 PM

    >
    Warning: execution completed with warning
    >
    The package compiled with warnings. Post the exact error message.
    The code compiled with no errors for me in the SCOTT schema using that EMP table.

  • Function overloading not supported by RMI-IIOP?

    Hi, I am successfully connecting to a stateful session EJB running under
    WebLogic 5.1, sp5 as an RMI-IIOP client. Here's the problem. If I try to
    invoke an overloaded public method on my bean I get the following error:
    Remote Error: CORBA UNKNOWN 0 Maybe; nested exception is:
    org.omg.CORBA.UNKNOWN: minor code: 0 completed: Maybe
    If I comment out all versions but one of the overloaded method and rebuild,
    everything's peachy, I can call the method.
    Is method overloading not supported by RMI-IIOP? Each version of the
    overloaded method does get added to the weblogic.ejbc generated IDL file,
    but again if there are multiple overloaded versions it doesn't work.
    Thx,
    Sandy Barletta

    Eduardo, have you had a chance to test this yet?
    Thx,
    Sandy
    "Eduardo Ceballos" <[email protected]> wrote in message
    news:[email protected]..
    This is a bug, I suspect. This should of course work. I'll look into it.
    Sandy Barletta wrote:
    Hi, I am successfully connecting to a stateful session EJB running under
    WebLogic 5.1, sp5 as an RMI-IIOP client. Here's the problem. If I try to
    invoke an overloaded public method on my bean I get the following error:
    Remote Error: CORBA UNKNOWN 0 Maybe; nested exception is:
    org.omg.CORBA.UNKNOWN: minor code: 0 completed: Maybe
    If I comment out all versions but one of the overloaded method and
    rebuild,
    everything's peachy, I can call the method.
    Is method overloading not supported by RMI-IIOP? Each version of the
    overloaded method does get added to the weblogic.ejbc generated IDLfile,
    but again if there are multiple overloaded versions it doesn't work.
    Thx,
    Sandy Barletta

  • Function Overloading

    Hi,
    In this sample program:
    Class Test{
    void Method(byte b) {
    public static void main(String[] args) {
    Test t = new Test() ;
    t.Method(7) ; // Is illegal
    byte b = 7 ; // Legal
    As a function is selected (during the call) based on the type of variable (used as parameters) during compilation, 7 in this case is an Integer. In the same lines the second line is should also be illegal but why does java is alllowing that to haapen during compliation just because 7 is falls in the ranger of a byte.

    Your analysis is pretty correct.
    7 is an integer literal in Java, so calling the method will not work, since an int is not a valid parameter for a method taking a byte.
    For the assignment [JLS �5.2|http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.2] comes into effect:
    In addition, if the expression is a constant expression (�15.28) of type byte, short, char or int :
    * A narrowing primitive conversion may be used if the type of the variable is byte, short, or char, and the value of the constant expression is representable in the type of the variable.

  • Function overloading concepts

    I am a little doubtful about the output of the following code:
    public class Test {
         void c(Object a){}
         void c(Float a){}
         void c(Number a){}
         void m(){
              c(null);
         public static void main(String[] args) {
              Test t = new Test();
              t.m();
    I an not able to find out the reason why the Float version of the c() will be called?

    DeltaGeek wrote:
    Hendawy wrote:
    The reason behind this is that a null value is a void reference to, i.e. a pointer to nothing. Since it is a pointer (address), it is actually a number. That's why the float version is best matching in your code.Wow...just....not even close.
    When determining what method to call, the compiler will find the most specific method it can that matches the arguments you pass in. Since you're passing in an uncast null, it can match any reference type.
    In this case, Float happens to be the most specific reference type it could use. This is also why adding an overload for Integer will cause a compilation error, as you now have multiple methods with the maximum level of specificity.
    Also note that casting the null to one of Float or Integer would resolve the compile error but hide the design problem.But i have a doubt; if i follow your approach then this code must work:
    public class Test {
         void c(Object a){}
         void c(Float a){}
         void c(Number a){}
         void c(DerivedInteger a){}
         void m(){
              c(null);
         public static void main(String[] args) {
              Test t = new Test();
              t.m();
    class MyInteger extends Number{
         public double doubleValue() {
              return 0;
         public float floatValue() {
              return 0;
         public int intValue() {
              return 0;
         public long longValue() {
              return 0;
    class DerivedInteger extends MyInteger{
    because U is the most specific one,

  • Overloading PL/SQl functions

    HI Friends
    I have an Issue .I need to overload a function in PL/SQL by changing the no of arguments(like C++ or java) .As per oracle doc, it is possible to do with in a PACKAGE . Can anyone suggest me How to do with out using package as a standalone function.Have anyone done that , then pl send me some tip or sample.
    thanks and Happy programming
    gopal V

    Hi Gopal
    Yes, you cannot do a standalone overloaded function, but as you rightly pointed out it can be done in package
    - and that makes sense because the whole purpose of clubbing procedures and functions into package is to bring a
    semblance of Object orientation into PL/SQL with function overloading (You still do not have operator overloding like in C++),
    encapsulation etc.
    Qurashi

Maybe you are looking for

  • IPod is recognized by iTunes but songs won't show up on device

    I bought a brand new 32gb ipod touch 5th generation last weekend. I put about 8gb of music onto it. the music displayed under the "on my device" section of my ipod in itunes however when i disconnected my ipod the only songs on it were ones that were

  • Business Process Monitoring - E-mail notification

    Hi all! I'm using BPM but i´m having problems with the e-mail notifications. In the Jobs option I´m receiving the e-mails correctly, but in the dialog transactions I do not receive anything. The main problem is that I can see in RZ20 (in the satellit

  • Transaction report hp officejet 6600

    HP Officejet 6600. RE: Transaction report from faxes sent. When my transaction report prints out it does not print out the date or the time. I would like to know how to adjust settings to include date and time fax was sent.  Thank you

  • Is it possible to install a 7200 rpm drive into a Macbook running a 5400?

    Is it possible to install a 7200 rpm drive into a Macbook running a 5400 rpm drive? And if so does anyone know what brand of drive is stock in the Macbook? What is a good brand? Seagate? Hitachi? Western?

  • Disabling input

    Hi, How to use "at selection-screen output" event for disabling input of certain fields. Please explain with easy example. Thanks, Mahathi