将时间戳插入Oracle数据库(Inserting timestamp into Oracle database)

编程入门 行业动态 更新时间:2024-10-25 22:31:29
将时间戳插入Oracle数据库(Inserting timestamp into Oracle database)

我正在尝试将一些时间戳插入Oracle数据库表但获取ORA-01843: not a valid month错误。 字符串的格式是如何拉取数据,所以如果有任何问题,我必须在拉取数据后纠正它。

INSERT INTO SCHEMA.TABLE_NAME (START_TIME, END_TIME ) VALUES ( TO_TIMESTAMP('2016-12-19 13:30:00, YYYY-MM-DD HH24:MI:SS'), TO_TIMESTAMP('2016-12-19 14:33:00, YYYY-MM-DD HH24:MI:SS') );

I'm trying to insert some timestamps into an Oracle DB table but getting an ORA-01843: not a valid month error. The format of the string is how the data is pulled so if there's any issue with that, I'll have to correct that after the data is pulled.

INSERT INTO SCHEMA.TABLE_NAME (START_TIME, END_TIME ) VALUES ( TO_TIMESTAMP('2016-12-19 13:30:00, YYYY-MM-DD HH24:MI:SS'), TO_TIMESTAMP('2016-12-19 14:33:00, YYYY-MM-DD HH24:MI:SS') );

最满意答案

您错过了在日期之后关闭单引号并在格式掩码之前开始:

INSERT INTO SCHEMA.TABLE_NAME (START_TIME, END_TIME ) VALUES ( TO_TIMESTAMP('2016-12-19 13:30:00', 'YYYY-MM-DD HH24:MI:SS'), TO_TIMESTAMP('2016-12-19 14:33:00', 'YYYY-MM-DD HH24:MI:SS') );

You missed to close the single quote after the date and start before the format mask:

INSERT INTO SCHEMA.TABLE_NAME (START_TIME, END_TIME ) VALUES ( TO_TIMESTAMP('2016-12-19 13:30:00', 'YYYY-MM-DD HH24:MI:SS'), TO_TIMESTAMP('2016-12-19 14:33:00', 'YYYY-MM-DD HH24:MI:SS') );

更多推荐

本文发布于:2023-08-05 10:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1431238.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   时间   Oracle   database   Inserting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!