.NET code adds a trailing 0 to the numbers with 1 or 3 fractional digits stored in Oracle DB
I created a support ticket to Oracle. They told me that it is a BUG
Round a number and keep trailing zeroes in oracle
Sounds like you need to_char...
SELECT to_char(TRUNC(7836.721), '9999990.000') numbr
FROM dual;
NUMBR
------------
7837.000
This does assume that you're after 3 decimal places for any number, rather than 7.12 going to 7.00.
ETA:
It seems like a very strange requirement, but here you go:
WITH sample_data AS (SELECT 123 numbr FROM dual UNION ALL
SELECT 123.12 numbr FROM dual UNION ALL
SELECT 123.1234 numbr FROM dual UNION ALL
SELECT 123.12345 numbr FROM dual UNION ALL
SELECT 0.12345 numbr FROM dual UNION ALL
SELECT 1.2345678901234567890123456789012345678901234567890123e50 numbr FROM dual UNION ALL
SELECT NULL numbr FROM dual UNION ALL
SELECT 1.23e-50 numbr FROM dual)
SELECT numbr,
ROUND(numbr) || CASE WHEN numbr != TRUNC(numbr) THEN
RPAD('.', LENGTH(numbr -TRUNC(numbr)), '0') END new_numbr
FROM sample_data;
NUMBR NEW_NUMBR
---------- --------------------------------------------------------------------------------
123 123
123.12 123.00
123.1234 123.0000
123.12345 123.00000
0.12345 0.00000
1.23456789 1.2345678901234567890123456789012346E+50
1.23E-50 0.000000000000000000000000000000000000000
Related Topics
Split Words with a Capital Letter in SQL
SQL Select to Get the First N Positive Integers
I Keep Getting the Error "Relation [Table] Does Not Exist"
How to Add a Auto_Increment Primary Key in SQL Server Database
Is There a Difference Between Select * and Select [List Each Col]
Best Equivalent for Isinteger in SQL Server
Function for Week of the Month in MySQL
Is There a Version Control System for Database Structure Changes
Is There a SQL Implementation of Pbkdf2
How to Rename Something in SQL Server That Has Square Brackets in the Name
Ssis Source Format Implicit Conversion for Datetime
Errors in SQL Server While Importing CSV File Despite Varchar(Max) Being Used for Each Column
SQL Query for 7 Day Rolling Average in SQL Server