In Oracle, the number type data to_char () is displayed as 0 less, or the value is,

Source: Internet
Author: User

In Oracle, the number type data to_char () is displayed as 0 less, or the value is,

Problem description:

When the to_char () function is used in Oracle, when the number value is a decimal number, it is often not displayed for a single digit 0.

For example, select to_char (0.02) from dual, and the result is. 02.

Improved to select to_char (0.02, 'fm0. 100') from dual, and found that the number of digits is 0.

Of course, there is still a problem here. When the parameter is 'fm0. 100', if the value is greater than two digits or the decimal point is greater than four digits, the conversion will be wrong ,:

I didn't think of a good way to add 9, for example, select to_char (11.2321212, 'fm9999990. 99999999 ') from dual, generally the conversion should not report an error, but I don't think this is the best way. It's too stupid to know if there is any better way. This to_char () the function is really cool. By default, when there is no parameter, it is as good as toString (). As for FM, just remove it and add it for execution, after comparing the results, we can see its role.

 

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.