How to avoid trailing zero (after decimal point) for numeric type column

From: Praveen Kumar <praveenkumar52028(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, david(dot)g(dot)johnston(at)gmail(dot)com
Subject: How to avoid trailing zero (after decimal point) for numeric type column
Date: 2018-02-27 12:13:25
Message-ID: CAG2WJO2QjSh_fvbD4gjF21=2je5XFiiQwCRUWuyD9FSj+58jpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello Team,

We have recently migrated our database from Oracle
And there are few of my tables with numeric column type.

In below example
I did insertion from java program with below code snippet

Double object = 10.0;
String inserRecordQuery_NEWWAY11 = "INSERT INTO BLOB_TEST_TABLE(id)VALUES
(?)";
selectPrepareStmt.setObject(1, object,Types.NUMERIC);
int count = selectPrepareStmt.executeUpdate();

it inserted like this.

[image: Inline image 2]

In this case, when a decimal point is equal to 0 then, I don't want to see
the precision and the value in the column should just 10

And If I execute code,

Double object = 10.5801
String inserRecordQuery_NEWWAY11 = "INSERT INTO BLOB_TEST_TABLE(id)VALUES
(?)";
selectPrepareStmt.setObject(1, object,Types.NUMERIC);
int count = selectPrepareStmt.executeUpdate();

Now ,the value in the column should be 10.5801 as the precision is greater
than ZERO

Because of this, the migrated data (from Oracle) is without PRECISION ZERO
and the new data which is being inserted is with PRECISION ZERO.

[image: Inline image 3]

Is there a possible setting in PostgreSQL server to achieve this?

FYI -

Oracle's NUMBER column type is handling it as I expected.
I migrate Oracle's NUMBER column as just NUMERIC column in PostgreSQL

Thanks,
Praveen

Browse pgsql-bugs by date

  From Date Subject
Next Message laveen tepan 2018-02-27 12:39:48 Help me for the Query
Previous Message Amit Langote 2018-02-27 08:50:04 Re: BUG #15093: hash partition exector plan is error!!!!