Page 1 of 1

Select a fixed string, is adding whitespace

Posted: Thu 24 Jul 2014 17:38
by edsonluispletsch
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

Re: Select a fixed string, is adding whitespace

Posted: Mon 28 Jul 2014 08:40
by AlexP
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.

Re: Select a fixed string, is adding whitespace

Posted: Tue 28 Jun 2016 08:40
by synnet
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');

Re: Select a fixed string, is adding whitespace

Posted: Fri 01 Jul 2016 07:13
by AlexP
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;