ORA-01843 error insert date data error

Source: Internet
Author: User

When I execute: INSERT INTO MERs (
Customer_id, first_name, last_name, dob, phone
) VALUES (
5, 'doreen', 'Blue ', '20-MAY-1970', NULL
);
The error "ORA-01843: Invalid month" occurred. After Google, find the following article, which says to executeAlter session set nls_date_language = 'American'Then execute the preceding SQL statement, and the problem is fixed. However, when the connection is closed, an error will still be reported if a similar statement is executed in the next session. Some of the reasons for the month that caused the ORA-01843 to be invalid 1) when we use the following SQL statement in a Chinese environment Client
Insert into "temptable" (DELIVER_DATE) VALUES (TO_DATE ('27-Jun-2007 15:57:30 ', 'dd-MON-YYYY HH24: MI: ss '))
Runtime error occurred: 1843 (ORA-01843: Invalid month)
The database will report a ORA-01843 error, this is because the client is a Chinese environment, the format of mon can not be written in English month, must use the Chinese "June"
If you do not want to modify the SQL statement to run, you need to use the alter session command to change nls_date_language to american before executing the statement, as shown below:
Alter session set nls_date_language = 'American '-- display date in English
2)
A ORA-01843 error occurs today. This error indicates that invalid months are generally prompted during date conversion.
Solution
Alter session set NLS_DATE_FORMAT = 'dd-MON-YY ';

But today I still don't need to use it. In fact, the problem lies here:

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
O: \> sqlplus greatfinish/finish
SQL * Plus: Release 9.2.0.1.0-Production on Wednesday June 21 19:18:00 2006
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.

Connect:
Oracle9i Enterprise Edition Release 9.2.0.1.0-Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0-Production
Greatfinish @ ORA920> select to_date ('Jan 01 100', 'mon dd yyyy ') from dual;
Select to_date ('Jan 01 1988 ', 'mon DD yyyy') from dual
*
ERROR is located in row 1st:
ORA-01843: Invalid month

Greatfinish @ ORA920> alter session set NLS_DATE_FORMAT = 'mon DD yyyy ';
The session has been changed.
-- Modified NLS_DATE_FORMAT. the problem persists.
Greatfinish @ ORA920> select to_date ('Jan 01 100', 'mon dd yyyy ') from dual;
Select to_date ('Jan 01 1988 ', 'mon DD yyyy') from dual
*
ERROR is located in row 1st:
ORA-01843: Invalid month
-- Check sysdate and find that the cause is a client Character Set Problem.
Greatfinish @ ORA920> select sysdate from dual;
SYSDATE
------------
2006
Greatfinish @ ORA920> exit
From Oracle9i Enterprise Edition Release 9.2.0.1.0-Production
With the Partitioning, OLAP and Oracle Data Mining options
Disconnects from JServer Release 9.2.0.1.0-Production
O: \> set NLS_LANG = AMERICAN_AMERICA.ZHS16GBK
O: \> sqlplus greatfinish/finish
SQL * Plus: Release 9.2.0.1.0-Production on Wed Jun 21 19:20:22 2006
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.

Connected:
Oracle9i Enterprise Edition Release 9.2.0.1.0-Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0-Production
-- Select successfully modified
Greatfinish @ ORA920> select to_date ('Jan 01 100', 'mon dd yyyy ') from dual;
TO_DATE ('
---------
01-JAN-88
Greatfinish @ ORA920>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.