Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Retaining Trailing Zero In a Number Column?

Re: Retaining Trailing Zero In a Number Column?

From: Hans Forbrich <forbrich_at_telusplanet.net>
Date: Wed, 23 Apr 2003 22:54:31 GMT
Message-ID: <3EA71888.D0834793@telusplanet.net>


DTS wrote:

> Hey group,
> This is probably a common question, but searching through the docs
> has revealed nothing. If I have a field in my table that is intended
> to be used as a price and I'm using the Number datatype [Number(8,2)],
> how can I keep the trailing zero on my prices (140.50 --> 140.5)

Unless specified otherwise, Oracle (the engine) will provide this as a raw 'number' to the front end. You need to format the result in the front end, and that formatting will potentially be handled differently in different front end utilties.

Some alternatives:

  1. for most tools you can format by converting to a CHAR and using a picture spec in the retrieve request; eg: select to_char(column_name, '999.99') ......
  2. if you happen to be using SQL*Plus you can use the Column formatting capability as described in the SQL*Plus manuals.
  3. many report writers have a method for specifying the format on a column-by-column basis. Some actually allow you to use a 'money' format spec.
  4. if using C, check out the printf statement.

YMMV
Hans Received on Wed Apr 23 2003 - 17:54:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US