Check If a "number" is an integer or a float (Oracle PL/SQL):
declare
v_is_int number(1);
type num_list_type is table of number(10,2)
index by pls_integer;
num_list num_list_type;
function isInt(n number)
return integer is
begin
if remainder(n,1) = 0 then -- is integer
return(1);
else -- is float
return(0);
end if;
end isInt;
begin
num_list(1):=3.2;
num_list(2):=2.5;
num_list(3):=2;
num_list(4):=1;
num_list(5):=0.7;
num_list(6):=0;
num_list(7):=0.3;
dbms_output.put_line('====== RESULT ========');
for i in num_list.FIRST .. num_list.LAST loop
v_is_int:=isInt(num_list(i));
dbms_output.put_line(rpad(num_list(i),3)||' => '||CASE v_is_int when 1 then 'Integer' else 'Float' END);
end loop;
dbms_output.put_line('======================');
end;
/
====== RESULT ========
3.2 => Float
2.5 => Float
2 => Integer
1 => Integer
.7 => Float
0 => Integer
.3 => Float
======================