Select a fixed string, is adding whitespace

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
edsonluispletsch
Posts: 1
Joined: Thu 24 Jul 2014 17:00

Select a fixed string, is adding whitespace

Post by edsonluispletsch » Thu 24 Jul 2014 17:38

I'm using driver version 4.8 dbexpoda40 until recently. Just decided to renew the license and update to version 6.4.7 (latest available).
However, with this update, which began to occur in selects fixed string, is returning a space at the end. Here's an example:
ClientDataSetAuxiliar.Close;
ClientDataSetAuxiliar.CommadText: = 'select ''A'' field1 from dual';
ClientDataSetAuxiliar.Open;
if ClientDataSetAuxiliar.FieldByName ('field1'). AsString = 'A' then
   ShowMessage('There goes here');
if ClientDataSetAuxiliar.FieldByName ('field1'). AsString = 'A ' then
   ShowMessage('Come here');

Does anyone know why this is happening?

The parameter SQLConnection "TrimFixedChar = True" to solve this problem, but it can bring other problems.

Grateful for the assistance.

Edson Luis Pletsch

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

Re: Select a fixed string, is adding whitespace

Post by AlexP » Mon 28 Jul 2014 08:40

Hello,

If you are using Delphi 2006 or higher, you should set the UseUnicode option to True. Otherwise, set the CharLength option to 1. However, if in the field multi-byte symbols are used, they will be displayed incorrectly.

synnet
Posts: 1
Joined: Tue 28 Jun 2016 08:34

Re: Select a fixed string, is adding whitespace

Post by synnet » Tue 28 Jun 2016 08:40

Hi,
we have this problem with Delhi 7 and Oracle 12c. Is There also a workaround for Delphi 7?
The solutions above dont't work with our version:
SQLConnection.Params.Clear;
SQLConnection.Params.Add('BlobSize=-1');
SQLConnection.Params.Add('DriverName=DevartOracle');
SQLConnection.Params.Add('ErrorResourceFile=');
SQLConnection.Params.Add('LocaleCode=0000');
SQLConnection.Params.Add('Oracle TransIsolation=ReadCommited');
SQLConnection.Params.Add('Multiple Transaction=True');
SQLConnection.Params.Add('DataBase=' + SettingsHandler.GetSetting('database'));
SQLConnection.Params.Add('User_Name=' + SettingsHandler.GetSetting('username'));
SQLConnection.Params.Add('Password=' + SettingsHandler.GetSetting('password'));

SQLConnection.Params.Add('UseUnicode=True');
SQLConnection.Params.Add('TrimFixedChar=True');
SQLConnection.Params.Add('CharLength=1');

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

Re: Select a fixed string, is adding whitespace

Post by AlexP » Fri 01 Jul 2016 07:13

To display a correct string in Delphi 7, you should set the TrimFixedChar property to True as shown below:

Code: Select all

procedure TForm1.SQLConnection1AfterConnect(DataSet: TDataSet);
const
  coTrimFixedChar = TSQLConnectionOption(103); // boolean
begin
  SQLConnection1.SQLConnection.SetOption(coTrimFixedChar, Integer(True));
end;

Post Reply