ORA-01843:没有得到解决的有效月份

时间:2017-02-18 10:49:22

标签: oracle date

我有一个Oracle查询,其中我收到错误

  

ORA-01843:不是有效月份

我也尝试使用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 个答案:

答案 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'
        )