ORA-01722: invalid number

Scenario: The same code has the same database table structure, but the production environment does not report an error, but the test environment reports an error: ORA-01722: invalid number,

analysis: The problem was found after analysis, and a conditional field in the query statement was a character type, and the transmission The parameter is of Long type. The query will not report an error in the production library, and the test library will report an error. It is determined that it should be a database data problem.

Scenario reproduction:
Create a test table:
create table test_invalide_num
(
  Id NUMBER(12) not null,
  STATUS_CD VARCHAR2(6) not null
)
where the status_cd field is a character type, and then we insert numbers, as shown in the following figure:



Then query, the result is normal There is no error, as shown in the following figure:



Then we insert another piece of data, if the following figure:


Then the query is performed, and the result is an error, as shown in the figure below:



Summary: The query condition parameter type must match, although it may not report an error if it does not match, but it does match. It must not report an error, and if the type does not match, it will not work if there is an index, which will affect performance.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326265076&siteId=291194637