Updating Unicode through TOraQuery

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jp
Posts: 15
Joined: Tue 29 May 2007 11:28

Updating Unicode through TOraQuery

Post by jp » Fri 09 Apr 2010 19:17

Hi,

I am trying unicode enable an old Delphi 5 app and am having trouble writing unicode to the database. The database is 11g and the characterset is AL32UTF8. I have downloaded the latest version of ODAC for d5 - 6.90. If i use ADO it works fine, but i need to use ODAC with direct connect so there is no need for drivers on the client machines.

The following is a sample of the query i am running...

OraSession.Options.UseUnicode := True;
OraSession.Options.Charset := 'AL32UTF8';

with qryUpdate do
begin
close;
sql.clear;
sql.add('update TEST_TABLE set name = :nme where id = :myid');
ParamByName('nme').value := edELName.text;
ParamByName('myid').value := edELID.text;
execsql;
end;

I have tried using ParamByName('nme').aswidestring and that doesn't help - database is showing ? for the unicode characters. The datatype in the table for the unicode string is NVARCHAR2. Please can you help with this as i am stuck.

thanks,

jp

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

Post by bork » Mon 12 Apr 2010 14:13

Hello

You have tried setting params as non-unicode string. And if you set OraSession.Options.Charset differ from server charset then you save text in the invalid charset to database and get one or more "?" instead of your string.

I can propose two ways to solve your issue:

1. Set OraSession.Options.Charset equal to database charset or try setting OraSession.Options.Charset to empty value.

2. Set params as unicode string:

ParamByName('nme').DataType := ftWideString;
ParamByName('nme').Value := edELName.Text;

jp
Posts: 15
Joined: Tue 29 May 2007 11:28

Post by jp » Wed 14 Apr 2010 12:22

Hi,

Thanks for the suggestions. I tried various options without success. I then created a quick test app in Delphi 2010 with the trial ODAC and it worked fine with the following code:

oraSession.Options.UseUnicode := True;

with qryUpdate do
begin
close;
sql.clear;
sql.add('update TEST set name = :nme where id = :myid');
ParamByName('nme').value := edName.text;
ParamByName('myid').value := edID.text;
execsql;
end;

I will therefore move my project to the latest Delphi, but looks like there is an issue with D5.

thanks,

jp

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

Post by bork » Thu 15 Apr 2010 08:16

Hello

If you want to set parameter as Unicode then you should:

For Delhpi 5 - 2007 do:
ParamByName('nme').DataType := ftWideString;
ParamByName('nme').AsWideString := edELName.Text;

For Delhpi 2009, 2010 do:
ParamByName('nme').AsWideString := edELName.Text;

Post Reply