Oracle到Postgres,插入时,日期字段出错


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(字段,如下:

  1. select cast(start_date as timestamp) as start_date
  2. select TO_TIMESTAMP(start_date) as start_date
  3. select TO_DATE(TO_CHAR(end_date, 'YYYY/MM/DD HH:MI:SS'), 'YYYY/MM/DD HH:MI:SS') as start_date

有任何提示?

您是否尝试在插入时将其施放给TIMESTAMP

INSERT INTO associate_merchant_info
            (start_date,
             end_date)
VALUES  ('0002-05-05 00:00:00.0' :: TIMESTAMP,
             NULL);  
INSERT INTO ASSOCIATE_MERCHANT_INFO(start_date,end_date) 
VALUES (to_timestamp('0002-05-05 00:00:00.0', 'YYYY-MM-DD HH24:MI:SS.MS'),NULL);

最新更新