Select unicode string in Query

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
androschuk
Posts: 2
Joined: Thu 25 Sep 2014 08:16

Select unicode string in Query

Post by androschuk » Thu 25 Sep 2014 11:34

I trying to use unicode string in query, but when I opened query I saw only question marks.

In database I'm using next parameters:
NLS_CHARACTERSET CL8MSWIN1251
NLS_NCHAR_CHARACTERSET AL16UTF16
For saving unicode text I'm using NVARCHAR2 type. All unicode strings saved perfect, and displayed in dbGrid when I'm set UseUnicode option

Structure of table In database looks like:

Code: Select all

CREATE TABLE TEST1 (
  COMMENTS       VARCHAR2(255),
  NAME           NVARCHAR2(255),
)
For select data from table I'm using next sql query:

Code: Select all

  SELECT 
  COMMENTS, NAME
  FROM TEST1
I want add some static text in sql query, to show as result I try using next sql text:

Code: Select all

  SELECT 
  COMMENTS, NAME, 
  '百度百' as StrJapanese,
  'სდიფჰსდ ფიჰს' as StrGeorgian,
  'Тестовая строка' as StrRussian
  FROM TEST1
When query executed instead of the unicode string I got question marks. What settings i have got to set to show correct data? :?:

I set some settings, but my result is incorrect

Code: Select all

...
  UniConnection1.SpecificOptions.Values['UseUnicode'] := 'true';
  UniConnection1.SpecificOptions.Values['UnicodeEnvironment'] := 'true';
...
initialization
  OCIUnicode := True;
PS:
TUniConnection options:
  • Direct := True
  • UseUnicode := True
Delphi XE
UniDAC 5.5.11
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit

Code: Select all

select * from nls_database_parameters;
NLS_CALENDAR GREGORIAN
NLS_CHARACTERSET CL8MSWIN1251
NLS_COMP BINARY
NLS_CURRENCY $
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_DUAL_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_LANGUAGE AMERICAN
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_NCHAR_CONV_EXCP FALSE
NLS_NUMERIC_CHARACTERS .,
NLS_RDBMS_VERSION 11.2.0.3.0
NLS_SORT BINARY
NLS_TERRITORY AMERICA
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Select unicode string in Query

Post by AlexP » Fri 26 Sep 2014 09:53

Hello,

Different UniCode characters will be supported in queries only if NLS_CHARACTERSET = AL32UTF8 is used (UniCode support). In your case, as a workaround, you can sue parameters instead of constants:

Code: Select all

  UniQuery1.SQL.Text := 'SELECT :p1 as StrJapanese, :p2 as StrGeorgian, :p3 as StrRussian FROM dual';
  UniQuery1.ParamByName('p1').National := true;
  UniQuery1.ParamByName('p1').AsString := '百度百';
  UniQuery1.ParamByName('p2').National := true;
  UniQuery1.ParamByName('p2').AsString := 'სდიფჰსდ ფიჰს';
  UniQuery1.ParamByName('p3').National := true;
  UniQuery1.ParamByName('p3').AsString := 'Тестовая строка';
  UniQuery1.Open;

androschuk
Posts: 2
Joined: Thu 25 Sep 2014 08:16

Re: Select unicode string in Query

Post by androschuk » Fri 26 Sep 2014 10:12

Hello, Thanks for the answer.
This is for me the perfect solution. :)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Select unicode string in Query

Post by AlexP » Fri 26 Sep 2014 10:39

You are welcome. Feel free to contact us if you have any further questions.

Post Reply