题
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.
解决方案
*原因:使用日期格式模型转换的输入数据不正确。输入数据不包含格式模型需要数字的数字。
您使用的日期字符串与Oracle期望的内容不匹配。默认格式IIRC是DD-MON-YYYY,而不是您试图使用的Mon-Dd-Yyyy。
其他提示
INSERT
INTO PLAYERS
(
PlayerNo,
Name,
date_of_birth,
leagno
)
VALUES
(
1,
'Philipp K',
TO_DATE('Jan-10-1999','Mon-dd-yyyy'),
'1'
)
您需要使用正确格式使用to_date提供日期。
错误解释了:
“使用日期格式模型转换的要转换的输入数据不正确。输入数据不包含格式模型需要数字的数字”
这意味着您传递给date_of_birth列的值是错误的格式。默认情况下,Oracle希望日期处于格式DD-MON-YYYY。您正在以Mon-dd-Yyyy格式通过日期。
处理此问题有两种 - 三个好方法。
- 使用明确格式面具:
to_date('Jan-10-1999', 'MON-DD-YYYY')
- 改变 NLS_DATE_FORMAT参数, ,在会话甚至数据库级别。 F在这里更多 和 这里.
- 更改您的插入声明以以预期格式传递日期。
不隶属于 StackOverflow