ORA-01830:日期格式图片在转换整个输入字符串站点之前结束:community.oracle.com

时间:2016-03-12 07:50:26

标签: java oracle11g prepared-statement

从Java调用时,能帮助您解决此查询的错误吗?当我在PL / SQL开发人员中运行相同的查询时,它运行得很完美,但是当我从java调用时,却没有。

CRE_DTTM是DATE数据类型

String query4="SELECT NVL(SUM(cur_amt),0) FIRST_PAY" +
                        "   FROM ci_ft ft " +
                        "WHERE sa_id IN "+
 " (SELECT sA_id FROM ci_Sa WHERE acct_id='"+acctid.getIdValue()+"'  )" +
 "AND TRUNC(crE_dttm)>=  (SELECT MAX(crE_Dttm)  FROM ci_bill" +
 "  WHERE accT_id='"+acctid.getIdValue()+"'  AND crE_dttm<=    (SELECT add_months(To_Date('2016-03-10','YYYY-MM-DD'), -1)    FROM dual )  )" +
 "AND fT_type_flg IN ('PS','PX')AND ft.cRE_dttm <= (" +
 "  CASE" +
 "    WHEN ( to_Date(" +
 "      (SELECT MAX(crE_Dttm)" +
 "      FROM ci_bill" +
 "      WHERE accT_id    ='"+acctid.getIdValue()+"'" +
 "      AND crE_dttm     < To_Date('2016-03-10','YYYY-MM-DD')" +
 "      ) , 'YYYY-MM-DD') = to_Date (" +
 "      (SELECT MAX(crE_Dttm)" +
 "      FROM ci_bill" +
 "      WHERE accT_id='"+acctid.getIdValue()+"'" +
 "      AND crE_dttm<=" +
 "        (SELECT add_months(To_Date('2016-03-10','YYYY-MM-DD'), -1) FROM dual" +
 "        )      ) ,'YYYY-MM-DD'))" +
 "    THEN To_Date('2016-03-10','YYYY-MM-DD')" +
 "    ELSE" +
 "    ( SELECT MAX(crE_Dttm)" +
 "      FROM ci_bill" +
 "      WHERE accT_id='"+acctid.getIdValue()+"'" +
 "      AND crE_dttm < To_Date('2016-03-10','YYYY-MM-DD')) " +
 "  END)";


                com.splwg.base.api.sql.PreparedStatement ps4 = createPreparedStatement(query4);
                logger.info(ps4);
                ps4.execute();

                if(!ps4.list().isEmpty())
                {
                    first_pay=new BigDecimal(ps4.list().get(0).get("FIRST_PAY").toString());
                    logger.info("first_pay=="+first_pay);
                }
            }

错误是:

ORA-01830: date format picture ends before converting entire input string site:community.oracle.com

请注意,PreparedStatement来自com.splwg.base.api.sql.PreparedStatement

1 个答案:

答案 0 :(得分:0)

我认为你在where子句中传递了不同的日期格式。请尝试将crE_dttm的日期格式与To_Date('2016-03-10','YYYY-MM-DD')匹配

e.g。 to_date(crE_dttm,'YYYY-MM-DD')&lt; TO_DATE( '2016年3月10日', 'YYYY-MM-DD')

由于 萨比哈