Hi,
I am unable to insert and retrieve arabic data into Oracle 10g database. I have used both SQL Plus and PL/SQL Developer IDE and also tried to insert using Java client. But data is not showing correctly either in PL SQL Developer or SQL Plus or Java client. Can some one please help me where I m getting wrong.
Please check these parameters if they are correct. How can I insert arabic data in Nvarchar2 or Nchar datatype ?? I also tried inserting using \XXXX format??? And using unistr(\XXXX ) format.. But it only show garbage data or some other characters?? Can someone please post me some code and parameter settings?? Any help would be really grateful.
Following are my NLS parameters at database and client end.
NLS_CHARACTERSET=WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_LANGUAGE = AMERICAN
I updated Windows Client Registry NLS_LANG parameter as follow
NLS_LANG=AMERICAN_AMERICA.UTF8
Insert and select from PL/SQL Devleoper
insert into fms_save.amc
(amc_id,element_type_id, amc_short_name, transaction_id, transaction_year, name, last_accessed_date, post_action)
values
('client4','A','clinet3',11,2007,UNISTR('\0641'),sysdate,'NSAVE')
select
amc_id,element_type_id, amc_short_name, transaction_id, transaction_year, name, last_accessed_date, post_action
from amc t
===========================================================RESULT unicode nvarchar2 field NAME shows value ¿
9 client4 A clinet3 11 2007 ¿ 10/31/2007 3:40:33 PM NSAVE
===========================================================
Insert from Java Client
Connection c=null;
try {
String uniname = "\u0641";
c = getConnection();
String qry=
"insert into fms_save.amc " +
"(amc_id,element_type_id, amc_short_name, transaction_id, transaction_year, name, last_accessed_date, post_action) " +
" values (?,?,?,?,?,?,?,?)" ;
PreparedStatement pstmt =
c.prepareStatement(qry);
pstmt.setString(1, "client11");
pstmt.setString(2, "A");
pstmt.setString(3, "AMCSHORT");
pstmt.setString(4, "22");
pstmt.setString(5, "2007");
pstmt.setString(6, uniname);
pstmt.setDate(7, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(8, "NSAVE");
pstmt.executeUpdate();
c.commit();
pstmt.close();
c.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try {
c.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
===========================================================Retrieve from PL/SQL Developer
select
amc_id,element_type_id, amc_short_name, transaction_id, transaction_year, name, last_accessed_date, post_action
from amc t
RESULT unicode nvarchar2 field NAME shows value 41
17 client10 A AMCSHORT 22 2007 41 10/31/2007 NSAVE
===========================================================