I find a error for oracle in Direct Mode about nvarchar2
Hello
I executed the following code:
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.
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;
"Is equal"
Field X has the correct value.
Please try this sample on your computer and tell me about the result.
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)
'.
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)
'.
Hello
To reproduce your issue with UseUnicode=False, I need to know the charset of your server:
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'