I find a error for oracle in Direct Mode about nvarchar2

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 18 Aug 2010 00:09

i think ,there are some errors in
Ansistring,widestring,string .

i try to fix it too.
but there has two .pas files has no code for direct mode .

i hope it will been fixed soon;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 18 Aug 2010 00:09

i think ,there are some errors in
Ansistring,widestring,string .

i try to fix it too.
but there has two .pas files has no code for direct mode .

i hope it will been fixed soon;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 18 Aug 2010 00:09

i think ,there are some errors in
Ansistring,widestring,string .

i try to fix it too.
but there has two .pas files has no code for direct mode .

i hope it will been fixed soon;

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 19 Aug 2010 12:50

Hello

I executed the following code:

Code: Select all

var
  wstr: WideString;
  MyConnection: TUniConnection;
  MyQuery: TUniQuery;
begin
  wstr := '漢語金聖歎';

  MyConnection := TUniConnection.Create(self);
  MyQuery := TUniQuery.Create(self);

  MyConnection.ProviderName := 'Oracle';
  MyConnection.Server := '...'; // replace
  MyConnection.Username := '...'; // replace
  MyConnection.Password := '...'; // replace
  MyConnection.SpecificOptions.Values['UseUnicode'] := 'True';
  MyConnection.Open;

  try
    MyConnection.ExecSQL('drop table test_table', []);
  except
  end;

  MyConnection.ExecSQL('create table test_table ' + #13 +
                         '( ' + #13 +
                         ' x nvarchar2(5), ' + #13 +
                         ' y varchar(5 char), ' + #13 +
                         ' z varchar(5)' + #13 +
                         ')', []);

  MyQuery.Connection := MyConnection;
  MyQuery.SQL.Text := 'select * from test_table';
  MyQuery.Open;

  MyQuery.Append;
  MyQuery.FieldByName('x').AsWideString := wstr;
  MyQuery.FieldByName('y').AsWideString := wstr;
  MyQuery.FieldByName('z').AsWideString := wstr;
  MyQuery.Post;

  MyQuery.Close;
  MyQuery.Open;

  if MyQuery.FieldByName('x').AsWideString = wstr then
    ShowMessage('Is equal')
  else
    ShowMessage('Is different');
end;
And I got the following result:
"Is equal"

Field X has the correct value.

Please try this sample on your computer and tell me about the result.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 13:49

i will try it just now.

but ,i like use :
MyConnection.SpecificOptions.Values['UseUnicode'] := 'False';

because , UseUnicode=false can let the fileid has limited length when we write char in DbGrid or DbEdit;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 13:49

i will try it just now.

but ,i like use :
MyConnection.SpecificOptions.Values['UseUnicode'] := 'False';

because , UseUnicode=false can let the fileid has limited length when we write char in DbGrid or DbEdit;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 13:50

i will try it just now.

but ,i like use :
MyConnection.SpecificOptions.Values['UseUnicode'] := 'False';

because , UseUnicode=false can let the fileid has limited length when we write char in DbGrid or DbEdit;


And I use win7

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:07

my test code:

procedure TfrmSql.dxBarButton9Click(Sender: TObject);
var
wstr: WideString;

MyQuery: TUniQuery;
begin
wstr := '漢語金聖歎';


MyQuery := TUniQuery.Create(self);



try
frmDmconn.oraSession.ExecSQL('drop table test_table purge', []);
except
end;

frmDmconn.oraSession.ExecSQL('create table test_table ' + #13 +
'( ' + #13 +
' x nvarchar2(5), ' + #13 +
' y varchar(5 char), ' + #13 +
' z varchar(5)' + #13 +
')', []);

MyQuery.Connection := frmDmconn.oraSession;
MyQuery.SQL.Text := 'select * from test_table';
MyQuery.Open;

MyQuery.Append;
MyQuery.FieldByName('x').AsWideString := wstr;
MyQuery.FieldByName('y').AsWideString := wstr;
MyQuery.FieldByName('z').AsWideString := wstr;
MyQuery.Post;

MyQuery.Close;
MyQuery.Open;

memo1.Lines.Add(MyQuery.FieldByName('x').AsString);
memo1.Lines.Add(MyQuery.FieldByName('y').AsString);
memo1.Lines.Add(MyQuery.FieldByName('z').AsString);
end;


i give my test results:


1.oci mode ,UseUnicode=False;
漢語?
漢語金聖歎
漢語?

2.direct mode ,UseUnicode=False;
漢語金聖歎
漢語金聖歎
漢語?



3.oci mode ,UseUnicode=True;
Project ProDbTools.exe raised exception class EOraError with message 'ORA-12899: 列 "FSDQ"."TEST_TABLE"."Z" 的值太大 (实际值: 10, 最大值: 5)
'.

4.direct mode ,UseUniCode=True;
Project ProDbTools.exe raised exception class EOraError with message 'ORA-12899: value too large for column "FSDQ"."TEST_TABLE"."Z" (actual: 10, maximum: 5)
'.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:11

perhaps it is OK at winXP;

But now I test it at Win7;

so you have to test it in all windows version:winXP,win2003server,win7,
win2008server,etc.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:12

perhaps it is OK at winXP;

But now I test it at Win7;

so you have to test it in all windows version:winXP,win2003server,win7,
win2008server,etc.

And i find that :
use: Oracle.UseUniCode=True perhaps solve some bugs;
but perhaps it gives other bugs;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:15

Please test at : delphi2010(update 5) + uniDAC3.00.0.10+win7

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:29

sorry ,the result i gived is opposite;


the fact result is :
1.oci mode ,UseUnicode=False;
漢語金聖歎
漢語金聖歎
漢語?

2.direct mode ,UseUnicode=False;
漢語?
漢語金聖歎
漢語?

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 19 Aug 2010 14:36

in fact :

at delphi2010

wideString=String;

so please test it not at d7 or d2007;

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Fri 20 Aug 2010 10:23

Hello

To reproduce your issue with UseUnicode=False, I need to know the charset of your server:

Code: Select all

select * from sys.nls_database_parameters where parameter = 'NLS_CHARACTERSET'

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Fri 20 Aug 2010 12:08

EXECUTE:

select * from sys.nls_database_parameters where parameter = 'NLS_CHARACTERSET'


GET :

PARAMETER VALUE
--------------------------------------
NLS_CHARACTERSET ZHS16GBK


I USE the defult CHARACTERSET when install oracle at chinese windows ;

And you must test it at :win7+delphi2010;

Post Reply