2015-02-24 85 views
-4

夥計們我試圖從java中的另一個表中從java中檢索日期,並試圖將其插入到其他表中,但它一直顯示 ---->java.sql.SQLDataException: ORA-01861: literal does not match format stringSQL錯誤---文字不匹配格式

rs = stmt.executeQuery("select * from a_seq_mtx"); 
    while(rs.next()) { 
     //Checking range of ----range_base to range_base+2--- for each rows 
     date_start = rs.getString(1); 
     //Storing date for each row which is to be checked 
     date_end = rs.getString(2); 
     stmt1.executeQuery("insert into a_pattern values('"+date_start+"','"+date_end+"' 
+2

請發佈您的代碼請 – jean 2015-02-24 12:39:38

+0

也有問題的表的DDL,以及哪些數據從哪裏傳輸到哪裏。 – 2015-02-24 12:45:13

+0

沒有其他信息:http://www.techonthenet.com/oracle/errors/ora01861.php – Albert 2015-02-24 12:51:50

回答

0

如果您嘗試插入字符串文字DATE列,你最有可能得到一個錯誤相關日期格式的不匹配。

,當你可能只是幸運的是,你的NLS_DATE_FORMAT日期文字格式相匹配,以及Oracle被迫做一個內部數據類型轉換唯一的實例。

你總是必須明確地轉換字符串文字到使用TO_DATE和適當業態模式日期。

例如,

'24-FEB-2015'是單引號括一個字符串。這不是約會。但是,to_date('24-FEB-2015','DD-MON-YYY')是日期。