There is no difference between these 2 types in and after Oracle Database Version 10g.
But prior to 10g these types were not exactly the same:
PLS_INTEGER uses machine arithmetic, unlike the library arithmetic usage of NUMBER or BINARY_INTEGER data types.
Prior to 10g though only BINARY_INTEGER was allowed in Index-By (Associative array) tables.
Machine arithmetic is always faster than the Library Arithmetic:
Reason being that for any mathematical operation machine arithmetic will go to the hardware to get an answer while Library arithmetic will go to a software library to get the results. Software library is generally slower since it emulates the functionality of the hardware.
For this reason, PLS_INTEGER was the preferred option in versions prior to 10g.
Some additional information on NUMBER, INTEGER, PLS_INTEGER and BINARY_INTEGER:
INTEGER is defined in STANDARD package as a subtype of NUMBER data type.
BINARY_INTEGER is subtype of INTEGER.
PLS_INTEGER is subtype of BINARY_INTEGER.
INTEGER and NUMBER are platform independent.
One point to keep in mind while using the PLS_INTEGER is that in case of overflow PL/SQL engine will throw an exception while in case of BINARY_INTEGER it will not throw any exception if the result is being assigned to a NUMBER data type.
But prior to 10g these types were not exactly the same:
PLS_INTEGER uses machine arithmetic, unlike the library arithmetic usage of NUMBER or BINARY_INTEGER data types.
Prior to 10g though only BINARY_INTEGER was allowed in Index-By (Associative array) tables.
Machine arithmetic is always faster than the Library Arithmetic:
Reason being that for any mathematical operation machine arithmetic will go to the hardware to get an answer while Library arithmetic will go to a software library to get the results. Software library is generally slower since it emulates the functionality of the hardware.
For this reason, PLS_INTEGER was the preferred option in versions prior to 10g.
Some additional information on NUMBER, INTEGER, PLS_INTEGER and BINARY_INTEGER:
INTEGER is defined in STANDARD package as a subtype of NUMBER data type.
BINARY_INTEGER is subtype of INTEGER.
PLS_INTEGER is subtype of BINARY_INTEGER.
INTEGER and NUMBER are platform independent.
One point to keep in mind while using the PLS_INTEGER is that in case of overflow PL/SQL engine will throw an exception while in case of BINARY_INTEGER it will not throw any exception if the result is being assigned to a NUMBER data type.
No comments:
Post a Comment