ERROR 1292 (22007): Truncated incorrect DOUBLE value 和ORA-01722: invalid number
其實這種錯誤和隱式轉換有關
主要是由於轉換的時候不能轉換為期望的格式的然後出的問題
比如 1p這個字元要轉換為 int(number)是不可能的
MYSQL 錯誤模擬如下:
myql> show variables like 'sql_mode%';
+---------------+--------------------------------------------+
| Variable_name | Value |
+---------------+--------------------------------------------+
| sql_mode | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
1 row in set (0.01 sec)
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table jjjkk (id varchar(20),name varchar(20));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into jjjkk values('1','gaopeng');
Query OK, 1 row affected (0.00 sec)
mysql> update jjjkk set name='gaop' where id=1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update jjjkk set name='gaop' where id=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> insert into jjjkk values('1p','gaopeng');
Query OK, 1 row affected (0.01 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> update jjjkk set name='gaop' where id=1;
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '1p'
MYSQL 中存在隱式轉換ORACLE中通常會在執行計劃中給出to_char之類的標示
但是MYSQL執行計劃沒有
如上列子雖然'1'可以轉換這個時候沒有報錯。但是新插入的'1p'是不能轉換的
這個在ORACLE中也存在這樣的問題。所以報錯
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '1p'
當然我是嚴格的SQL_MODE,否則則是WARINGS
可以如下試試轉換:
SELECT CONVERT('1',SIGNED);
SELECT CONVERT('1p',SIGNED);
然後演示一下ORACLE的報錯:
SQL> create table testmmm( id varchar2(20),name varchar2(20));
Table created
SQL> insert into testmmm values('1','gaopeng');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from testmmm where id=1;
ID NAME
-------------------- --------------------
1 gaopeng
SQL> insert into testmmm values('1p','gaopeng');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from testmmm where id=1;
select * from testmmm where id=1
ORA-01722: invalid number
如果模擬
SQL> select to_number('1p') from dual;
select to_number('1p') from dual
ORA-01722: invalid number
同樣的情況
我們檢視一下執行計劃中的隱式轉換資訊:
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER("ID")=1)
僅此記錄MYSQL和ORACLE同樣的報錯
主要是由於轉換的時候不能轉換為期望的格式的然後出的問題
比如 1p這個字元要轉換為 int(number)是不可能的
MYSQL 錯誤模擬如下:
myql> show variables like 'sql_mode%';
+---------------+--------------------------------------------+
| Variable_name | Value |
+---------------+--------------------------------------------+
| sql_mode | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
1 row in set (0.01 sec)
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table jjjkk (id varchar(20),name varchar(20));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into jjjkk values('1','gaopeng');
Query OK, 1 row affected (0.00 sec)
mysql> update jjjkk set name='gaop' where id=1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update jjjkk set name='gaop' where id=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> insert into jjjkk values('1p','gaopeng');
Query OK, 1 row affected (0.01 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> update jjjkk set name='gaop' where id=1;
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '1p'
MYSQL 中存在隱式轉換ORACLE中通常會在執行計劃中給出to_char之類的標示
但是MYSQL執行計劃沒有
如上列子雖然'1'可以轉換這個時候沒有報錯。但是新插入的'1p'是不能轉換的
這個在ORACLE中也存在這樣的問題。所以報錯
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '1p'
當然我是嚴格的SQL_MODE,否則則是WARINGS
可以如下試試轉換:
SELECT CONVERT('1',SIGNED);
SELECT CONVERT('1p',SIGNED);
然後演示一下ORACLE的報錯:
SQL> create table testmmm( id varchar2(20),name varchar2(20));
Table created
SQL> insert into testmmm values('1','gaopeng');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from testmmm where id=1;
ID NAME
-------------------- --------------------
1 gaopeng
SQL> insert into testmmm values('1p','gaopeng');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from testmmm where id=1;
select * from testmmm where id=1
ORA-01722: invalid number
如果模擬
SQL> select to_number('1p') from dual;
select to_number('1p') from dual
ORA-01722: invalid number
同樣的情況
我們檢視一下執行計劃中的隱式轉換資訊:
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER("ID")=1)
僅此記錄MYSQL和ORACLE同樣的報錯
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-2076512/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mybatis Data truncation: Truncated incorrect DOUBLE value: '*'MyBatis
- SQLSTATE [22007]: Invalid datetime format: 1292 IncorrectSQLORM
- com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLEMySqlJDBCLDA
- SQLLoader ORA-01722 invalid numberSQL
- oracle ORA-01722 報錯 "invalid number"Oracle
- 【問題處理】ORA-01722: invalid number
- python: invalid value encountered in divide以及invalid value encountered in double_scalars報錯PythonIDE
- sqlldr 時碰到錯誤 ORA-01722: invalid numberSQL
- 隱式轉換錯誤:ORA-01722: invalid number
- mysql error 1292MySqlError
- ERROR ITMS-90542: “Invalid CFBundleSupportedPlatforms value.”ErrorPlatform
- ORA-01722:invalid number-解決GAT專案中車輛維修Bug(續)
- Invalid double崩潰分析
- nginx: [error] invalid PID number "" in "/var/run/nginx.pid"NginxError
- MySQL ERROR 1366(HY000):Incorrect string value:''for column''at row 1解決方案MySqlError
- MySQL 亂碼實戰解決ERROR 1366 (HY000): Incorrect string value: 'MySqlError
- java.sql.SQLException: Incorrect string valueJavaSQLException
- kettle建立資源庫Incorrect integer value
- 【MySQL】Incorrect string value 問題一則MySql
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- mybatis竟然報"Invalid value for getInt()"MyBatis
- ORACLE匯出文字到MYSQL 報錯 Incorrect integer value: ''OracleMySql
- ORA-06502: PL/SQL: numeric or value error: character to number conversion error錯誤的解決方法SQLError
- OGG Get Error "Statistics reply buffer exceeded. Results truncated..."Error
- Oracle - ORA-01789: Query block has incorrect number of result columnsOracleBloC
- 【BUG記錄】MySQL插入Emoji表情報錯"Incorrect string value"MySql
- Syntax error, unrecognized expression: li[value=]ErrorZedExpress
- mysql 報錯:ERROR 1366 (HY000): Incorrect string value: ‘\xD5\xC5\xC8\xFD‘ for column ‘name‘ at row 1MySqlError
- 解決 Incorrect datetime value: '0000-00-00 00:00:00' 報錯
- The value for the useBean class attribute SecurityOrgPages is invalid. in tomcat 5.5BeanTomcat
- ORA-31600: invalid input value INDEX PARTITION for parameterIndex
- MySQL: Incorrect string value: '\xF0\xA4\xBD\x82'分析MySql
- ERROR 2026 (HY000): SSL connection error: unknown error numberError
- struct.error: 'h' format requires -32768 number 32767StructErrorORMUI
- error: invalid type argument of unary ‘*‘ (have ‘int‘) *__first = __tmp;Error
- err Invalid input of type: 'dict'. Convert to a byte, string or number first
- An invalid XML character (Unicode: 0x10) was found in the value of attributeXMLUnicode
- nagios監控windows 報NSClient - ERROR: Invalid passwordiOSWindowsclientError