Recent

Author Topic: TSQLQuery.ServerFilter problem  (Read 3601 times)

Yannis

  • Newbie
  • Posts: 1
TSQLQuery.ServerFilter problem
« on: June 24, 2014, 09:27:19 pm »
Hi everyone,

I am new to Lazarus, but with many years of Delphi experience.

All I am trying to do is to assign a ServerFilter at run time and the following code generates a segment violation error in ubuntu 14.04 / 64bit with Lazarus 1.2.2 and fpc 2.6.4
Code: [Select]
  SQLQueryInstruments.ServerFiltered := False;
  SQLQueryInstruments.ServerFilter := Filter;
  SQLQueryInstruments.ServerFiltered := True;
but it works when the DataSet is closed, i.e. when I change it to:
Code: [Select]
  SQLQueryInstruments.Close;
  SQLQueryInstruments.ServerFiltered := False;
  SQLQueryInstruments.ServerFilter := Filter;
  SQLQueryInstruments.ServerFiltered := True;
  SQLQueryInstruments.Open;
I don't think that is necessary the DataSet to be closed, the code in sqldb "SetServerFilter" checks if it is active to re fetch the data as it should, so what am i doing wrong ?

Any help / advice will be highly appreciated

TIA

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: TSQLQuery.ServerFilter problem
« Reply #1 on: June 25, 2014, 07:30:26 am »
Can you please post small compilable application, which will show error?

goodname

  • Sr. Member
  • ****
  • Posts: 297
Re: TSQLQuery.ServerFilter problem
« Reply #2 on: July 04, 2014, 02:01:23 pm »
I can confirm this behaviour change. It seams to have appeared in the current 1.2.4 Lazarus release. It was not there in the 1.2.2 release. I had just assumed until now that it was intentional so was adjusting my code to handle it.

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: TSQLQuery.ServerFilter problem
« Reply #3 on: July 11, 2014, 02:37:38 pm »
Do you happen to have data-aware components connected to your dataset?

I noticed that if you have a TDBImage connected to it you get an error if the resulting dataset changes from having a resultset to an empty one.

Internally the ServerFilter uses an InternalClose and InternalOpen.
I've noticed the buffer is not cleared properly because if the resultset is empty after applying ServerFilter then the field-data is still filled.
(You can check this with an TDBEdit for example, after applying a Filter which would result in an empty set the TDBEdit will still be filled with old data).

(BTW. as far as i can tel there is no need to do a .ServerFiltered := False; before changing the .ServerFilter.)

 

TinyPortal © 2005-2018