Oracle converts numbers to formatted strings, oracle strings

Source: Internet
Author: User

Oracle converts numbers to formatted strings, oracle strings

Problem description
If oracle stores number (0.00) data, the value 0 indicates 2.1, the value 2.10 indicates 3.88, and the value 3.88 indicates,
If the corresponding information is taken directly from the database, it is shown:
0 2.1 3.88 if two decimal places are retained, it will change. If it needs to be consistent with the database:
Solution
To retain two valid decimal places:

SELECT TO_CHAR(3.2,'FM99999999999990D00') FROM DUAL

There is too much nonsense. The example is as follows:
Reference instance:

select to_char(a, '99D90'),    to_char(a, '90D90'),    to_char(a, 'FM90D99'),    rtrim(to_char(a, 'FM90D99'), to_char(0, 'D'))from (    select 50 a from dual    union all select 50.57 from dual    union all select 5.57 from dual    union all select 0.35 from dual    union all select 0.4 from dual)order by a;TO_CHA TO_CHA TO_CHA RTRIM(------ ------ ------ ------   .35   0.35 0.35   0.35   .40   0.40 0.4    0.4  5.57   5.57 5.57   5.57 50.00  50.00 50.    50 50.57  50.57 50.57  50.57

Reference:

For details, click here.
Official documentation: oracle format doc
Example: example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.