简体   繁体   English

ORA-01722:编号无效

[英]ORA-01722: invalid number

When i execute the below SQL command using single quotes to enter a number, i got an error if remove the single quotes,it is successfully updated. 当我使用单引号执行以下SQL命令以输入数字时,如果删除单引号,则会发生错误,它已成功更新。 knowing that the type of the field HEIGHT is NUMBER. 知道字段HEIGHT的类型为NUMBER。

The strange thing is that i tried to use the same sql statement with single quotes on different machines, some machines execute it successfully, others do not.(same oracle version,same table structure...) 奇怪的是我试图在不同的机器上使用相同的sql语句并用单引号引起来,有些机器成功执行了它,而其他机器却没有成功。

Any explanation please 请任何解释

SQL>  UPDATE TBL_DEVICE_INFO SET HEIGHT='14.5'  WHERE ID='6ujbfI';
 UPDATE TBL_DEVICE_INFO SET HEIGHT='14.5'  WHERE ID='6ujbfI'
                                   *
ERREUR à la ligne 1 :
ORA-01722: invalid number



SQL>  UPDATE TBL_DEVICE_INFO SET HEIGHT=14.5  WHERE ID='6ujbfI';

1 row updated.

This is most likely a locale problem. 这很可能是语言环境问题。

That is, some machines have the decimal symbol "." 也就是说,某些机器的十进制符号为“”。 (period), and some have "," (comma). (句点),有些带有“,”(逗号)。

You can test it by putting it like this: 您可以通过如下所示对其进行测试:

UPDATE TBL_DEVICE_INFO 
   SET HEIGHT = to_number('14.5', '99D9','NLS_NUMERIC_CHARACTERS = ''. ''') 
   WHERE ID='6ujbfI'

When the number is in single qoutes, oracle will do an implicit conversion to number using the characters set in the database. 当数字在单个qoutes中时,oracle将使用数据库中设置的字符进行隐式转换为数字。

You can change the default by setting the NLS_NUMERIC_CHARACTERS parameter: 您可以通过设置NLS_NUMERIC_CHARACTERS参数来更改默认值:

alter session set NLS_NUMERIC_CHARACTERS = '. ';

but that will also reflect to data returned by the system so make sure that it doesn't break anything in your application if you change that. 但这也将反映到系统返回的数据中,因此请确保在您更改应用程序时不会破坏应用程序中的任何内容。

Strings should be quoted using single quotes, numbers shouldn't be. 字符串应使用单引号引起来,数字则不应。

Maybe you're using a different client on the machines where the invalid syntax works? 也许您在无效语法起作用的计算机上使用其他客户端?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM