简体   繁体   English

Oracle Application Express-仅在一个表中出现“ ORA-01843:无效的月份错误”

[英]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. 我在Oracle Application Express中创建数据库,将日期插入表之一时遇到问题。

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) 我在架构中有第二个表,可以毫无问题地插入日期,该表上的唯一区别是日期是必需的(我尝试使其可为null以进行测试,但仍然出现相同的错误)

I should point out that Im am completely new to Oracle and this is part of a study project. 我应该指出,Im对Oracle来说是全新的,这是一个研究项目的一部分。 If I had I choice I would be using SQL Server! 如果可以的话,我将使用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 . 这是由于TIME列,而不是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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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