Inserting arabic characters in oracle 11g

怎甘沉沦 提交于 2019-12-13 15:53:37

问题


I am trying to insert Arabic characters in Oracle 11g, however the data is being inserted as question marks. I searched around and it seems i have to change the character encoding... But i am not sure how, and whether will it affect my database. Any help please ?

UPDATE LAM_INVESTMENT
SET INVESTMENT='ل'
WHERE KEY=11;

I tried updating from within SQL developer, also same outcome.


回答1:


First of all check if your database is capable to store Arabic characters by

SELECT * 
from NLS_DATABASE_PARAMETERS
WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');

If you get values like AL32UTF8, AL16UTF16 or WE8ISO8859P6 you are fine and DB is able to store such characters.

In SQL Developer go to Tools / Preferences / Environment / Encoding and select UTF-8.

Set an Environment Variable to NLS_LANG=ARABIC_AMERICA.AL32UTF8 or similar, you can also do NLS_LANG=.AL32UTF8 in order to keep default/existing language and territory. Alternatively you can set is also in your Registry at HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANG (for 32 bit), resp. HKLM\SOFTWARE\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANG (for 64 bit).

Then it should work.

Changing your local character set (i.e. NLS_LANG) does never affect any existing data in database.




回答2:


You can try updating using the function UNISTR and the unicode 0644, to circumvent Oracle client configurations (in case they do not support Unicode):

UPDATE LAM_INVESTMENT
SET INVESTMENT=UNISTR('\0644')
WHERE KEY=11;

It may or may not work, depending on the data type of column investment and on your character set (or national character set).

Unicode table reference




回答3:


If you column type is nvarchar, have you tried to use the next query:

UPDATE LAM_INVESTMENT
SET INVESTMENT=N'ل'
WHERE KEY=11;

I had the same situation with korean language. Hope this approach helps you as well as it helped me.



来源:https://stackoverflow.com/questions/34188292/inserting-arabic-characters-in-oracle-11g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!