Troubleshooting of garbled characters when OCI operates ORACLE databases on Linux

Source: Internet
Author: User

I have just studied Linux and are still studying OCI.

After calling OCI to connect to the database a few days ago, I tested it with the example provided by Oracle. I can read data normally (in English), so I can rest assured that I can switch to other modules. During the past few days, the database module needs to insert Chinese data to find that all data inserted is "???? ". Make sure that the data is in GB2312 format and remains invalid after being converted to a UTF-8. It is always ineffective after many times.

Google found an article about setting the character set NLS_LANG on the client. Remember that oracle was installed in English and only the LANG variable was set. This is not set. SELECT * FROM sys. props $ on the ORACLE server to obtain

NLS_LANGUAGE = AMERICAN
NLS_TERRITORY = AMERICA
NLS_ISO_CURRENCY = AMERICA
NLS_CHARACTERSET = ZHS16GBK

Set NLS_LANG = AMERICAN_AMERICA.ZHS16GBK based on these parameters (in the GOOGLE article, set NLS_LANG = "SIMPLIFIED CHINESE_CHINA.ZHS16GBK" because the character set of the installed server is different ).

Then, in/etc/profile, export NLS_LANG = AMERICAN_AMERICA.ZHS16GBK, then source/etc/profile, and then run the program. Haha, Chinese is coming!

Related Article

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.