Conversion function: To_char () One use to convert a number to a string __ function

Source: Internet
Author: User
Tags numeric value


format: To_char (Number,format) that is to_char (numeric, format)

Usage: 1, the TO_CHAR function that does not specify the format converts the numeric value to a simple string form.

Example: To_char (123) Results 123

To_char (-123) Results-123

2, with the format of element 9

Example: To_char (1234, ' 9999 ') results 1234

To_char (567, ' 9999 ') results 567

To_char (-567, ' 9999 ') results-567

To_char (1234567, ' 9999 ') results

To_char (45.789, ' 9999 ') results 46

To_char (567, ' 9999.99 ') results 567.00

To_char (-567, ' 9999.99 ') results-567.00

To_char (1234567, ' 9999.99 ') results #######

To_char (45.789, ' 9999.99 ') results 45.79

To_char (567, ' 9,999,999 ') results 567

To_char (-567, ' 9,999,999 ') results-567

To_char (1234567, ' 9,9999,999 ') results 1,234,567

To_char (0.44, ' 9,999,999 ') results 0

3, with the format of the element $

Example: To_char (1234, ' $9999 ') results $1234

To_char (-567, ' $9999 ') results-$567

4, in the format of element b if the integer part of the converted value is 0, it appears as a space

Example: To_char (567, ' B999.9 ') results 567.0

To_char ( -567, ' B999.9 ') results-567.0

To_char (0.44, ' B999.9 ') results. 4

5, with the element MI format negative number is converted to the end with a minus sign

Example: To_char (567, ' 999MI ') results 567

To_char ( -567, ' 999MI ') results 567-

6, with the format of the element s to convert to the number of positive and negative numbers characters

Example: To_char (567, ' S999 ') results +567

To_char ( -567, ' S999 ') results-567

To_char (567, ' 999S ') results 567+

To_char ( -567, ' 999S ') results 567-

7, with the element PR format with angle brackets surround negative numbers

Example: To_char (567, ' 9999PR ') results 567

To_char ( -567, ' 9999PR ') results <567>

8. Insert a decimal point in the specified position with the format of element D

Example: To_char (567, ' 9999d99 ') results 567.00

To_char ( -567, ' 9999d99 ') results-567.00

To_char (567.866, ' 9999d99 ') results 567.87

9. Eeee Scientific Counting method

Example: To_char (567, ' 9.9EEEE ') results 5.7E+02

To_char (9.9EEEE ') results 4.5E+01

To_char (0.0666, ' 9.9EEEE ') results 6.7E-02

To_char function is a good reputation, the conversion function is very strong



The original text from: http://blog.sina.com.cn/s/blog_4cbadf5a0100f7u7.html

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.