2017-02-18 54 views
0

我有在我得到錯誤的ORA-01843:不是有效的一個月沒有得到解決

ORA-01843一個Oracle查詢:不是一個有效的一個月

我試着用to_date還但仍沒有工作對我來說

下面是查詢

INSERT INTO xxcus.xxacl_land_purc_invoice_view 
     (mkey, ref_purchase_id, ref_sr_no, ref_purhcase_type, org_id, 
     project_id, taluka_id, village_id, survey_area_7_12, doc_no, 
     invoice_id, invoice_num, vendor_id, vendor_name, invoice_amt, 
     batch_id, batch_name, exp_id, exp_type, remarks, created_by, 
     creation_date, last_update_date, last_updated_by 
     ) 
VALUES (139, 18, 1, 'E', 6089, 
     49292, 1, 14, '85/47', '693', 
     NULL, NULL, 2653609, 'K.A.JOSEPH', 1000, 
     572727, 'ICICI', 900077, 'Land Cost', 'TEST', 5681, 
     '18-02-2017 16:02:10', '18-02-2017 16:02:10', '5681' 
     ) 
+1

不要刪除'TO_DATE()'。正確使用它。 –

+0

@ÁlvaroGonzález:我用它,但它仍然沒有工作。像這樣'to_date('18 -02-2017 16:02:10','dd-MM-yyyy')' – BNN

+0

它怎麼會起作用?您的數據根本不符合格式。 –

回答

2

使用TO_DATE以適當的格式掩碼:

to_date('18-02-2017 16:02:10','dd-mm-yyyy hh24:mi:ss') 

試試這個:

INSERT INTO xxcus.xxacl_land_purc_invoice_view 
     (mkey, ref_purchase_id, ref_sr_no, ref_purhcase_type, org_id, 
     project_id, taluka_id, village_id, survey_area_7_12, doc_no, 
     invoice_id, invoice_num, vendor_id, vendor_name, invoice_amt, 
     batch_id, batch_name, exp_id, exp_type, remarks, created_by, 
     creation_date, last_update_date, last_updated_by 
     ) 
VALUES (139, 18, 1, 'E', 6089, 
     49292, 1, 14, '85/47', '693', 
     NULL, NULL, 2653609, 'K.A.JOSEPH', 1000, 
     572727, 'ICICI', 900077, 'Land Cost', 'TEST', 5681, 
     to_date('18-02-2017 16:02:10','dd-mm-yyyy hh24:mi:ss'), 
     to_date('18-02-2017 16:02:10','dd-mm-yyyy hh24:mi:ss'), 
     '5681' 
     ) 

按OP的提及有關插入當前日期時間,最好使用sysdate

INSERT INTO xxcus.xxacl_land_purc_invoice_view 
     (mkey, ref_purchase_id, ref_sr_no, ref_purhcase_type, org_id, 
     project_id, taluka_id, village_id, survey_area_7_12, doc_no, 
     invoice_id, invoice_num, vendor_id, vendor_name, invoice_amt, 
     batch_id, batch_name, exp_id, exp_type, remarks, created_by, 
     creation_date, last_update_date, last_updated_by 
     ) 
VALUES (139, 18, 1, 'E', 6089, 
     49292, 1, 14, '85/47', '693', 
     NULL, NULL, 2653609, 'K.A.JOSEPH', 1000, 
     572727, 'ICICI', 900077, 'Land Cost', 'TEST', 5681, 
     sysdate, 
     sysdate, 
     '5681' 
     ) 
+0

但我在服務器端發送這樣的信息,那麼我應該如何添加'to_date' ......這裏是'DateTime.Now.ToString(「dd/MM/yyyy HH:mm:ss」)' – BNN

+0

@ nad - 如果你想插入datetime作爲「now」,然後使用'sysdate'。我已經編輯了我的答案。請檢查第二個SQL。 – GurV

+0

但是'sysdate'需要分配一些東西..我應該像這樣添加'「SYSDATE」'? – BNN

相關問題