Mahmood Shahrokni
Mahmood Shahrokni

Reputation: 236

real part of a division result in pl sql

I need the real part of a division result in pl sql. I have searched whole the google although i could not find it. It seems Oracle round the result to the nearest real number

numb:=(numb/10);
dbms_output.put_line(numb); 

Upvotes: 2

Views: 6347

Answers (1)

Carlo
Carlo

Reputation: 1579

Here's a block of code that calculates integer and fractional part of the number:

DECLARE
    numb NUMBER := 987;
    n1   NUMBER;
    n2   NUMBER;
BEGIN
    n1 := TRUNC(numb / 10);
    n2 := MOD(numb, 10);

    dbms_output.put_line('n1=' || n1); -- n1=98
    dbms_output.put_line('n2=' || n2); -- n2=7
END;

Upvotes: 3

Related Questions