Search code examples
sqloracleoracle-sqldeveloper

Why is F5 returning rounded numbers in the script output window, when F9 is returning the correct value in the query result window


When I execute the query using F5 the result is rounding a decimal value up. When I execute the query using F9 the decimal value is correct.

SELECT SW_UNIQUE_ID, SW_TOTAL_TRANSACTIONS, SW_PROCESSED, SW_REMOVED, 
SW_AMOUNT_PROCESSED
FROM SWBATCH
WHERE SW_UNIQUE_ID = 1

The correct result in the query result window is

1, 977, 977, 0, 55607906.17

The incorrect (rounded) result in the script output window is

1, 977, 977, 0, 55607906.2

Solution

  • SQLPlus style column formatting for numbers is coming into play.

    You can bypass this by using SET SQLFORMAT ANSICONSOLE

    set sqlformat ansiconsole
    select 55607906.17 numbers from dual;
    
    NUMBERS       
       55607906.17 
    

    Or you can set the format yourself in your script.

    column numbers format 999999999.99
    select 55607906.17 numbers from dual;
    

    enter image description here