首页 > 解决方案 > Greenplum 日期/时间字段超出范围:“2020 年 10 月 10 日”

问题描述

我正在使用这种形式的表格测试 Greenplum(基于 Postegres):

CREATE TABLE whiteglove (bigint BIGINT,varbinary bytea,boolean BOOLEAN,date DATE,decimal DECIMAL,double float,real REAL,integer INTEGER,smallint SMALLINT,timestamp TIMESTAMP,tinyint smallint,varchar VARCHAR)

然后我尝试使用 Postegres JDBC 驱动程序插入这一行

INSERT INTO whiteglove VALUES (100000,'68656c6c6f',TRUE,'10/10/2020',0.5,1.234567,1.234,10,2,'4/14/2015 7:32:33PM',2,'hello')

失败并出现以下错误

org.postgresql.util.PSQLException: ERROR: date/time field value out of range: "10/10/2020"
  Hint: Perhaps you need a different "datestyle" setting.
  Position: 57
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)

如果我采用相同的查询并使用 psql 从终端执行它,它会毫无问题地通过

dev=# select * from whiteglove ;
 bigint | varbinary | boolean | date | decimal | double | real | integer | smallint | timestamp | tinyint | varchar 
--------+-----------+---------+------+---------+--------+------+---------+----------+-----------+---------+---------
(0 rows)

dev=# INSERT INTO whiteglove VALUES (100000,'68656c6c6f',TRUE,'10/10/2020',0.5,1.234567,1.234,10,2,'4/14/2015 7:32:33PM',2,'hello');
INSERT 0 1
dev=# select * from whiteglove ;
 bigint | varbinary  | boolean |    date    | decimal |  double  | real  | integer | smallint |      timestamp      | tinyint | varchar 
--------+------------+---------+------------+---------+----------+-------+---------+----------+---------------------+---------+---------
 100000 | 68656c6c6f | t       | 2020-10-10 |     0.5 | 1.234567 | 1.234 |      10 |        2 | 2015-04-14 19:32:33 |       2 | hello
(1 row)

关于我为什么会出现超出范围错误的任何指示?

标签: insertdatejdbcgreenplum

解决方案


推荐阅读