Oracle-ORA-01722 invalid number Error

Source: Internet
Author: User

Suddenly one day, good system error: ORA-01722 invalid number

Environment: Oracle9 + JDBC access to the database. It was okay before. This error was suddenly found.

Later I learned why

1. The following SQL statement is executed in the Code:

Select mdn from tablename where mdn = 13800000000

The mdn field in the tablename table is a varchar2 () type field. Because of the implicit type conversion function of Oracle fields

The preceding SQL statement is usually feasible. When oracle parses this condition during a query, it first compares to_number (mdn) with where mdn = 13812345678, if we can ensure that all numbers are stored in the mdn field, this statement will never be reported (there may be efficiency problems), but some people mistakenly add several letters 133aa000000 to the mdn, if the above statement still exists and the table does not contain 13800000000 of the user's data, when the query scans for 133aa000000, to_number (mdn) reports an error in the ORA-01722 invalid number

2. Therefore, it is best to write SQL statements properly:

Select mdn from tablename where mdn = '201312'

No problems!

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.