oracle ORA-01843:无效月份:TO_DATE('12-JUN-02','DD-MON-YY')

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22009554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:15:19  来源:igfitidea点击:

ORA-01843: not a valid month : TO_DATE('12-JUN-02','DD-MON-YY')

sqloracle

提问by tahasozgen2

I've faced a problem during insert. Here is the problem:

我在插入过程中遇到了问题。这是问题所在:

INSERT INTO SALES_ORDER_A4 (ORDERNO , CLIENTNO , ORDERDATE , DELYADDR , SALESMANNO , DELYTYPE , BILLYN , DELYDATE, ORDERSTATUS)
SELECT 'O19008' ,
       'C00005' ,
       to_date('24-MAY-02','DD-MON-YY'),
       'Delhi' ,
       'S00004' ,
       'F' ,
       'N' ,
       to_date('26-MAY-02','DD-MON-YY') ,
       'In Process'
FROM DUAL
UNION ALL
SELECT 'O19001' ,
       'C00001' ,
       to_date('12-JUN-02','DD-MON-YY') ,
       'Delhi' ,
       'S00001' ,
       'F' ,
       'N' ,
       to_date('20-JUN-02','DD-MON-YY') ,
       'In Process'
FROM DUAL
UNION ALL
SELECT 'O19002' ,
       'C00002' ,
       to_date('25-JUN-02','DD-MON-YY'),
       'Delhi' ,
       'S00002' ,
       'P' ,
       'N' ,
       to_date('27-JUL-02','DD-MON-YY') ,
       'Cancelled'
FROM DUAL


I have faced an exception at phrase *to_date('12-JUN-02','DD-MON-YY' )* that:

我在短语 *to_date('12-JUN-02','DD-MON-YY' )* 中遇到了一个例外:

ORA-01843: not a valid month

ORA-01843: 不是有效月份

My instructor can not find the problem, what is the problem here?

我的导师找不到问题,这里有什么问题?

回答by xdazz

This is mostly because NLS_DATE_LANGUAGEis not set correctly.

这主要是因为NLS_DATE_LANGUAGE设置不正确。

First check the value by:

首先通过以下方式检查值:

select * from v$nls_parameters where parameter like '%DATE%'

If the value of NLS_DATE_LANGUAGEis not Americanthen change it by:

如果的值NLS_DATE_LANGUAGE不是,American则通过以下方式更改它:

alter session set nls_date_language='American';

And try again.

然后再试一次。