The table and statement in question are below, the date results in an error when I try enter it
CREATE TABLE cteam_ExpenseReport (
ERNo NUMBER NOT NULL,
ERDesc VARCHAR2(50) NOT NULL,
ERSubmitDate DATE,
ERStatusDate DATE ,
ERStatus CHAR(8)NOT NULL,
SubmitUserNo NUMBER NOT NULL,
ApprUserNo NUMBER NOT NULL
);
INSERT INTO cteam_ExpenseReport
(ERNo, ERDesc, ERSubmitDate, ERStatusDate, ERStatus, SubmitUserNo, ApprUserNo)
VALUES (1,'Sales Presentation','8/10/2002','8/26/2002','APPROVED',3,4);
String can not be directly converted to date. You can use either to_date
or date
function as following:
INSERT INTO cteam_ExpenseReport
(ERNo, ERDesc, ERSubmitDate, ERStatusDate, ERStatus, SubmitUserNo, ApprUserNo)
VALUES (1, 'Sales Presentation',
TO_DATE('08/10/2002', 'MM/DD/YYYY'),
TO_DATE('08/26/2002', 'MM/DD/YYYY'),
'APPROVED', 3, 4 );
Or
INSERT INTO cteam_ExpenseReport
(ERNo, ERDesc, ERSubmitDate, ERStatusDate, ERStatus, SubmitUserNo, ApprUserNo)
VALUES (1, 'Sales Presentation',
DATE '2002-08-10',
DATE '2002-08-26',
'APPROVED', 3, 4 );
DATE
function accepts YYYY-MM-DD
format.
Cheers!!
Use TO_DATE()
to convert your string to a DATE
:
INSERT INTO cteam_ExpenseReport
(ERNo, ERDesc, ERSubmitDate, ERStatusDate, ERStatus, SubmitUserNo, ApprUserNo)
VALUES (
1,
'Sales Presentation',
TO_DATE('8/10/2002', 'MM/DD/YYYY'),
TO_DATE('8/26/2002', 'MM/DD/YYYY'),
'APPROVED',
3,
4
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.