Oracle PL/SQL - Integer and Real Literals

Introduction

All values the program are denoted as alphanumeric representations, or literals.

Integer literals represent signed numeric values without decimal points.

Real literals represent signed fractional numbers with decimal points.

If you use a decimal point, the literal automatically becomes real even though the value could still be an integer.

You don't have to place a zero before the decimal point, so 0.5 and .5 are exactly the same.

Zero could also be represented as a real number, using the notation 0.0.

Demo

SQL>
SQL> declare-- from   www .j a va 2  s .c om
  2        v_int1_nr BINARY_INTEGER :=5;  -- integer
  3        v_int2_nr BINARY_INTEGER :=-5; -- integer
  4        v_int3_nr BINARY_INTEGER :=0;  -- integer
  5        v_int4_nr BINARY_INTEGER :=+5; -- integer
  6
  7        v_real1_nr NUMBER :=5.0; -- real             --7
  8        v_real2_nr NUMBER :=5.;  -- real             --8
  9        v_real3_nr NUMBER :=-7.123; -- real
 10        v_real4_nr NUMBER :=0.5; -- real            --10
 11        v_real5_nr NUMBER :=.5;  -- real            --11
 12        v_real6_nr NUMBER :=0.0; -- real            --12
 13        v_real7_nr NUMBER :=2/3; -- real
 14  begin
 15        DBMS_OUTPUT.PUT_LINE(v_real3_nr);
 16  end;
 17  /
-7.123

PL/SQL procedure successfully completed.

SQL>

Related Topic