Re: cast numeric with scale and precision to numeric plain

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: cast numeric with scale and precision to numeric plain
Date: 2009-10-19 16:21:37
Message-ID: 6844.1255969297@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sim Zacks <sim(at)compulab(dot)co(dot)il> writes:
> Numeric with scale precision always shows the trailing zeros.
> Numeric plain only shows numbers after the decimal point that are being
> used.

That statement is false:

regression=# select 1234.000::numeric;
numeric
----------
1234.000
(1 row)

I'm not sure offhand what is the easiest way to suppress trailing
zeroes, but casting to plain numeric is not the route to a solution.

Really this is a textual formatting problem. You might find that the
best bet is something with trim() or a regexp. The trick would be
not removing zeroes that are significant ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brad Nicholson 2009-10-19 16:30:46 Re: autovacuum and immediate shutdown issues
Previous Message Tom Lane 2009-10-19 16:07:03 Re: autovacuum and immediate shutdown issues