Oracle PL/SQL - NUMBER type without rounding

Introduction

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.

Demo

SQL>
SQL> declare--   www  .j a v  a2s  . c o  m
  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.

SQL>

Related Topic