Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SQL Like sentence only works 1 time on ADS12

Hi all,

on ADS12 doesn't works the SQL "Like" sentence, well to be correct, only works the first time you invoke it.

From Delphi XE8,

I have an EditText, a DbGrid and a Button to search in the Country.ADT table from ADTDemoData in a Remote Server.

The button OnClick procedure is that:

procedure TForm5.Button1Click(Sender: TObject);

begin

  AdsQuery1.Close;

  AdsQuery1.SQL.Clear;

  AdsQuery1.SQL.Add('SELECT * FROM COUNTRY WHERE NAME LIKE :paramvalue');

  AdsQuery1.Params[0].Value  := '%'+Edit1.Text+'%';

  AdsQuery1.Open;

end;

When I press the button "Search", looking for countries with "en" in their name, the DbGrid shows "Argentina" and "Venezuela". CORRECT!!!!

But, if I repeat the search, looking for countries with "ol" in their name, the DbGrid shows again "Argentina" and "Venezuela".

In fact the search won't works anymore.

I test it in my old server with ADS7 and works fine.

I test it with .DBF files and doesn't works.

Why the SELECT LIKE sentence only works 1 time?

Does it changed something in the way I have to invoke the SELECT LIKE sentence?

I need help.

Thanks a lot

Cheers from Barcelona

Eugeni.

Tags:
Former Member
Former Member replied

Hi Eugeni,

The issue seems to be in a way we handle parameters with LIKE clause in SQL query in ADS 12. It works fine till ADS 11.1.


We will fix this in an upcoming SP, as soon as possible.

Meanwhile, can you please consider using a workaround?

begin

  AdsQuery1.Close;

  AdsQuery1.SQL.Clear;

  AdsQuery1.SQL.Add('SELECT * FROM COUNTRY WHERE NAME LIKE :paramvalue');

AdsQuery1.SQL.Text := 'SELECT * FROM COUNTRY WHERE NAME LIKE  ''%' + Edit1.Text + '%'' ';

  AdsQuery1.Params[0].Value  := '%'+Edit1.Text+'%';

  AdsQuery1.Open;

end;

Let me know if this works.

Thanks,

Parag

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question