由于非数字字符错误,插入失败
hy
表:
create table Players (PlayerNo number (4) not null, Name varchar2(15), date_of_birth date,leagno varchar(4));
错误插入:
insert into PLAYERS (PlayerNo,Name,date_of_birth,leagno) VALUES (1,'Philipp K','Jan-10-1999','1')
出了什么问题?
错误代码:
Fehler beim Start in Zeile 1 in Befehl:
insert into PLAYERS (PlayerNo,Name,date_of_birth,leagno) VALUES (1,'Philipp K','Jan-10-1999','1')
Fehlerbericht:
SQL-Fehler: ORA-01858: Ein nicht-numerisches Zeichen wurde gefunden, während ein numerisches Zeichen erwartet wurde
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
hy
table:
create table Players (PlayerNo number (4) not null, Name varchar2(15), date_of_birth date,leagno varchar(4));
wrong insert:
insert into PLAYERS (PlayerNo,Name,date_of_birth,leagno) VALUES (1,'Philipp K','Jan-10-1999','1')
whats wrong?
error code:
Fehler beim Start in Zeile 1 in Befehl:
insert into PLAYERS (PlayerNo,Name,date_of_birth,leagno) VALUES (1,'Philipp K','Jan-10-1999','1')
Fehlerbericht:
SQL-Fehler: ORA-01858: Ein nicht-numerisches Zeichen wurde gefunden, während ein numerisches Zeichen erwartet wurde
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用的日期字符串与 oracle 期望的不匹配。默认格式 iirc 是 DD-Mon-YYYY,而不是您尝试使用的 Mon-DD-YYYY。
The date string you're using doesn't match what oracle is expecting. The default format, iirc, is DD-Mon-YYYY, not Mon-DD-YYYY as you're trying to use.
您需要使用 TO_DATE 以正确的格式提供日期。
You need to supply date using TO_DATE with the right format.
错误解释如下:
这意味着您传递给 date_of_birth 列的值格式错误。默认情况下,Oracle 希望日期采用 DD-MON-YYYY 格式。您传递的日期采用 MON-DD 格式-YYYY。
有两种(或者三种)方法
to_date('Jan-10-1999', 'MON-DD-YYYY')
The error explains:
What this means is the value you are passing to the date_of_birth column is in the wrong format. By default Oracle expects dates to be in the format DD-MON-YYYY. You are passing a date in the format MON-DD-YYYY.
There are two - well three - ways of dealing with this.
to_date('Jan-10-1999', 'MON-DD-YYYY')