【发布时间】:2018-04-04 03:43:00
【问题描述】:
INSERT INTO ASSOCIATE_MERCHANT_INFO(start_date,end_date)
VALUES ('0002-05-05 00:00:00.0',NULL)
结果:
Caused by: org.postgresql.util.PSQLException:
ERROR: column "start_date" is of type timestamp without time zone but
expression is of type character varying
[junit] Hint: You will need to rewrite or cast the expression.
我可以在这里看到 '0002-05-05 00:00:00.0' 被 postgres 查询视为 char。
我尝试对选择查询进行类型化,但未能成功。
在提取数据时,我尝试在下面对该日期(start_date)字段进行类型转换,如下所示:
select cast(start_date as timestamp) as start_dateselect TO_TIMESTAMP(start_date) as start_dateselect TO_DATE(TO_CHAR(end_date, 'YYYY/MM/DD HH:MI:SS'), 'YYYY/MM/DD HH:MI:SS') as start_date
有什么提示吗?
【问题讨论】:
-
为什么你认为转换查询的列会影响插入语句?你明白错误信息吗?
标签: sql postgresql timestamp postgresql-9.4