ORACLE-023: annoying ora-01722 Invalid numbers

Source: Internet
Author: User

Once a period of time to write SQL statements, always inexplicably reported ora-01722.
For this error, especially for a complex SQL statement, is very depressed, because many times do not know.
Through each encounter summary, in fact, is not so difficult to solve, the main reason is:
1, for two types of mismatch (a numeric type, a non-numeric type, the same value) to perform the assignment operation;
2, two types do not match the value of the comparison operation (for example, "=");
3, the value of the To_number function, not the number, for example, To_number (' a ') is certainly not, to_number (' 12306 ') is normal.

To avoid these problems, it is necessary to deal with different types of problems when writing SQL statements.
For example, if you want to compare, both with To_number cast (to_number (field a) = To_number (field b)),
or convert to a string type at the same time (field a| | "= Field b| |", all connecting an empty string to make it into a string type).

When using the To_number function in a statement, ensure that the value must be in the number format, or write the exception handling.

When we come across this error, we'll start by checking the fields of all the numeric types we use, and then we'll solve the problem.


ORACLE-023: annoying ora-01722 Invalid numbers

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.