简体   繁体   中英

Oracle Application Express - 'ORA-01843: not a valid month error' in one table only

I am creating a database in Oracle Application Express and am having a problem inserting a date into one of the tables.

INSERT INTO VIEWING( VIEWING_ID, VIEWING_DATE, TIME, PROPERTY_ID, AGENT_ID)
VALUES('3', '12-07-2015' ,'10:00','1', '101');

I've tried every combination of date format, and trying to force the date to my correct format

to_date('12-07-2015','MM-DD-YYYY')

But nothing is working

CREATE TABLE Viewing (
        Viewing_ID   number(10) NOT NULL, 
        Viewing_Date date NOT NULL, 
        Time         timestamp(7) NOT NULL, 
        Property_ID  number(10) NOT NULL, 
        Agent_ID     number(10) NOT NULL, 
        PRIMARY KEY (Viewing_ID));

ALTER TABLE Viewing ADD CONSTRAINT FK_Viewing_Agent_ID FOREIGN KEY (Agent_ID) REFERENCES Agent (Agent_ID);
ALTER TABLE Viewing ADD CONSTRAINT FK_Viewing_Property_ID FOREIGN KEY (Property_ID) REFERENCES Property (Property_ID);

Every Resource I have found suggests it is most likely a parsing or syntax error but so far nothing has helped.

I have a second table in the schema that I can insert dates into without a problem, the only difference on this table is that the date is required (I have tried making it nullable to test and I still get the same error)

I should point out that Im am completely new to Oracle and this is part of a study project. If I had I choice I would be using SQL Server! But Ive been at this for hours and think its time to admit defeat!

Thanks

It is due to TIME column, not VIEWING_DATE . This worked:

INSERT INTO VIEWING( VIEWING_ID, VIEWING_DATE, TIME, PROPERTY_ID, AGENT_ID)
  VALUES(4, date '2015-12-07' , timestamp '2015-12-07 10:00:00',1, 101);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM