This content has been marked as final. Show 2 replies
We can overload subprograms whose parameter differ in number,order and datatype family .But cannot overload if parameter differ only in sub type .
If i see the standard package , i get
subtype BINARY_FLOAT is NUMBER;
subtype BINARY_DOUBLE is NUMBER;
But i am able to overload two procedures , one has a binary_float parameter and other has binary_double .They are subtype of same datatype .i.e. number.So how is it possible.Aslo ,most of the subtypes have no difference at all . So why is there these number of subtypes? Oracle defines subtypes as datatype with some sort of constraint on the base data type ,but is it valid for all? for example smallint and decimal .
type NUMBER is NUMBER_BASE;
subtype FLOAT is NUMBER;
subtype REAL is FLOAT;
subtype "DOUBLE PRECISION" is FLOAT;
subtype INTEGER is NUMBER(38,0);
subtype INT is INTEGER;
subtype SMALLINT is NUMBER(38,0);
subtype DECIMAL is NUMBER(38,0);
subtype NUMERIC is DECIMAL;
subtype DEC is DECIMAL;
Some of those, like smallint, are ANSI SQL datatypes. See Table 2-6 ANSI Datatypes Converted to Oracle Datatypes in the SQL Language doc
Oracle allows the ANSI datatype name to be used and associates the ANSI name to the appropriate Oracle datatype
ANSI, DB2, and SQL/DS Datatypes
SQL statements that create tables and clusters can also use ANSI datatypes and datatypes from the IBM products SQL/DS and DB2. Oracle recognizes the ANSI or IBM datatype name that differs from the Oracle Database datatype name. It converts the datatype to the equivalent Oracle datatype, records the Oracle datatype as the name of the column datatype, and stores the column data in the Oracle datatype based on the conversions shown in the tables that follow.
But BINARY_FLOAT and BINARY_DOUBLE are each defined as unique datatypes (see Table 2-1 in that doc).
Because they are unique Oracle datatypes they can be overloaded.
You can force Oracle to accept your otherwise identical overloads by adding wholly superfluous parameters ... look at the following example:
In the second example just pass in TRUE (or) FALSE and ignore it in the procedure's code.
PROCEDURE test (rid IN NUMBER, tdate DATE, someval IN POSITIVE) PROCEDURE test (rid IN NUMBER, tdate DATE, someval IN NATURAL, tiebreaker IN BOOLEAN)