[英]SQL ORA-01722: invalid number
Having trouble while using Oracle Application Express. 使用Oracle Application Express时遇到问题。 I'm currently learning Database management in college and using APEX.
我目前正在大学学习数据库管理并使用APEX。 All customer information was created using a generator so no personal information is in here.
所有客户信息都是使用生成器创建的,因此此处不存在任何个人信息。
The issue I'm having is caused when I try to run the script to insert information into the walks table. 当我尝试运行脚本以将信息插入walk表时,我遇到的问题就出现了。 I get an invalid number error.
我收到无效的数字错误。
INSERT INTO WALKS
VALUES (TIMESTAMP '2018-3-12 20:42:43', TIMESTAMP '2018-3-12 21:42:43', '13-JUN-18', 'San Antonio', 'TX', 1, 537028782);
INSERT INTO WALKS
VALUES (TIMESTAMP '2018-2-13 17:51:45', TIMESTAMP '2018-2-13 18:51:45', '10-OCT-18', 'San Antonio', 'TX', 2, 388191065);
The Create Table I used was 我使用的创建表是
CREATE TABLE Walks
(StartTime TIMESTAMP NOT NULL,
EndTime TIMESTAMP,
WalkDate INTEGER NOT NULL,
City VARCHAR2(15) NOT NULL,
State VARCHAR2(2) NOT NULL,
CustomerID INTEGER NOT NULL,
WalkerID VARCHAR2(9) NOT NULL,
CONSTRAINT Walk_Cust_fk FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),
CONSTRAINT Walk_Wlkr_fk FOREIGN KEY (WalkerID) REFERENCES Walkers(SocSecNum),
CONSTRAINT Walk_pk PRIMARY KEY (CustomerID, WalkerID));
CustomerID is an integer NOT NULL and WalkerID is a varchar2(9). CustomerID是整数NOT NULL,WalkerID是varchar2(9)。 If that helps at all.
如果这有帮助的话。
Just can't figure out when when I run this I get this error. 只是无法弄清楚当我运行这个时我得到这个错误。 Any help is appreciated.
任何帮助表示赞赏。
You have declared WalkDate
as an integer. 您已将
WalkDate
声明为整数。 I assume you mean date
: 我假设你的意思是
date
:
CREATE TABLE Walks (
StartTime TIMESTAMP NOT NULL,
EndTime TIMESTAMP,
WalkDate INTEGER NOT NULL,
City VARCHAR2(15) NOT NULL,
State VARCHAR2(2) NOT NULL,
CustomerID INTEGER NOT NULL,
WalkerID VARCHAR2(9) NOT NULL,
CONSTRAINT Walk_Cust_fk FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),
CONSTRAINT Walk_Wlkr_fk FOREIGN KEY (WalkerID) REFERENCES Walkers(SocSecNum),
CONSTRAINT Walk_pk PRIMARY KEY (CustomerID, WalkerID)
);
I would recommend writing the INSERT
as: 我建议将
INSERT
编写为:
INSERT INTO WALKS (StartTime, EndTime, WalkDate, City, State, CustomerId, WalkerId)
VALUES (TIMESTAMP '2018-3-12 20:42:43', TIMESTAMP '2018-3-12 21:42:43', DATE '2018-06-13', 'San Antonio', 'TX', 1, 537028782);
The use of the DATE
keyword means that you don't have to rely on system date format settings. 使用
DATE
关键字意味着您不必依赖系统日期格式设置。 Listing all the columns is simply a best practice when using INSERT
. 列出所有列只是使用
INSERT
时的最佳实践。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.