Oracle PL/SQL - NUMBER type without rounding


You can use the NUMBER data type without specifying either precision or scale.

This allows you to work with numeric data without fear that your data could be rounded.

This is especially critical with financial operations.


SQL> declare--   ww w.  ja  va 2 s .  com
  2       v1_nr NUMBER     := 2/3;
  3       v2_nr NUMBER(5,2):= 2/3;
  4  begin
  5      DBMS_OUTPUT.put_line(v1_nr*3||' and '||v2_nr*3);
  6  end;
  7  /
2 and 2.01

PL/SQL procedure successfully completed.


Related Topic