PL/SQL number data

Source: Internet
Author: User

Number (<p>, <s>)

Precision p value range: 1 ~ 38
Valid bit s value range:-84 ~ 127

Maximum integer digit = p-s


S is a positive number, and the specified position on the right of the decimal point starts rounding.
Negative Number of s. The specified position on the left of the decimal point starts rounding.
S is 0 or unspecified, rounded to the nearest integer
When p is less than s, it indicates that the number is a number with an absolute value less than 1, and the first s-p digit from the right of the decimal point must be 0, and the second decimal point is reserved.


-- Num_test start ------------------------------------------------

Connected to Oracle9i Enterprise Edition Release 9.0.1.1.1
Connected as aspire


SQL>
SQL> SET linesize 1000;
SQL> CREATE TABLE hjm_num_test
2 (a NUMBER,
3 B NUMBER (5, 2 ),
4 c NUMBER (5,-2 ),
5 d NUMBER (5, 0 ),
6 e NUMBER (5 ),
7 f NUMBER (2, 5 ));

Table created

SQL> INSERT INTO hjm_num_test
2 (a, B, c, d, e, f) VALUES (123.3333, 123.3333, 123.3333, 123.3333, 123.3333,-0.0003 );

1 row inserted

SQL> INSERT INTO hjm_num_test
2 (a, B, c, d, e, f) VALUES (197.9333, 197.9333, 197.9333, 197.9333, 197.9333, 0.00012567 );

1 row inserted

SQL> COMMIT;

Commit complete

SQL> SELECT * FROM hjm_num_test;

A B C D E F
1 123.3333 123.33 100 123 123 -0.00030
2 197.9333 197.93 200 198 198 0.00013

(Displayed in the pl/SQL dev SQL window)

-- Num_test end --------------------------------------------------------

The results seem to be correct, but now there is a problem. When I am not running in the pl/SQL dev window and I am running in isqlplus, the results will be a little different. Note, column F of row 1st:

A B C D E F
123.3333 123.33 100 123 123 -0003
197.9333 197.93 200 198 198 . 00013

(Displayed in isqlplus)

It removes the last 0! The same effect can be tested with sqlplus.

However, my intention should be to retain the 0, because number () specifies the valid bit to be 5 after all.

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.