Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: pls_integer datatype.

Re: pls_integer datatype.

From: <kenneth.koenraadt_at_no-spam.hotmail.com>
Date: Sat, 26 Oct 2002 17:37:36 GMT
Message-ID: <3dbace3f.3690817@news.mobilixnet.dk>


I am not sure I understand your question correctly, so :

INTEGER, + INT datatypes are subtypes of NUMBER.

NUMBER (and thus INTEGER + INT) is the native format in which Oracle stores numbers, and it is optimized for storage efficiency.

A consequence of this is that you cannot perform aritmethic operations directly on NUMBERs. When calculating on them, PL/SQL automatically converts them into a binary type, and converts it back to NUMBER afterwards :

declare
a NUMBER(5) := 1;
b NUMBER(5) := 2;
c BINARY_INTEGER := 1;
begin
  a := 2*b + 3; /'*Conversion is automaticallly done here */   c:= 2*c + 2; /* No conversion here, cause BINARY_INTEGER is a binary type and can be calculated on directly */ end;
/

So since conversion is done automatically, you may as well use BINARY_INTEGER in your code *every time you can*, because :

a)When mixing BINARY_INTEGER and NUMBER in calculations, conversion is done anyway.

b) Since BINARY_INTEGER and PLS_INTEGER are faster than NUMBER (because conversion is not necessary), you will gain some marginal performance when using them instead of NUMBER whenever possible.

Hope that helps.

On Sat, 26 Oct 2002 10:49:32 +0000 (UTC), Daz <none_at_hotmail.com> wrote:

>Hi,
>
>when doing stuff like:
>
>select count(x)=20
> into variable=20
> from table;
>
>i usually define the variable type as just plain ol integer.. will =
>changing that to pls_integer cause any implicit datatype conversions to =
>be done in the into, and thus should it be avoided?=20
>
>the same goes for procs/functions returning integers or binary_integers =
>.. does assigning them to a pls_integer do an implicit conversion ?
>
>
>thanks.
>
>Daz.
>
>using Oracle 8.1.7.2
Received on Sat Oct 26 2002 - 12:37:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US