Question

What is the best datatype to use for storing the value returned from a PL/SQL ascii() function call? Example...

declare
x number; /* number, pls_integer, binary_integer, int, etc...? */
begin
    x := ascii('a');
end;
/

This will be happening in a number of very low-level functions that will end up being called within loops, so speed and storage need to be considered. For PL/SQL number storage we have these datatypes...

BINARY_INTEGER
BINARY_INTEGER Subtypes... NATURAL, NATURALN, POSITIVE, POSITIVEN, SIGNTYPE

NUMBER
NUMBER Subtypes... DEC, DECIMAL, DOUBLE, PRECISION, FLOAT, INTEGER, INT, NUMERIC, REAL, and SMALLINT

PLS_INTEGER

Because of this statement I'm leaning towards using PLS_INTEGER:

You use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -2**31 .. 2**31. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic. For efficiency, use PLS_INTEGER for all calculations that fall within its magnitude range.

Would you agree that this is the best datatype to use, or is there something I'm not considering? Thanks!

Was it helpful?

Solution

PLS_INTEGER (now the same as BINARY_INTEGER) will yield the fastest performance (and so will buying a new server :) )

Really to see the performance gain, you would need be looping like crazy.

This says it all: http://www.oracle-base.com/articles/misc/performance-of-numeric-data-types-in-plsql.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top