Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread Refresh - question
Mon, Mar 23 2009 8:28 AMPermanent Link

Uli Becker
Hi,

I tried this query:

with MyQuery do
  begin
    ParamByName('FSearch').asString := '%' + edSearch.text + '%';
    if not active then
      open
    else
      refresh;
  end;

instead of this:

with MyQuery do
  begin
    close;
    ParamByName('FSearch').asString := '%' + edSearch.text + '%';
    open;
  end;

Only the 2nd one works if executed more than once. Is this the expected
behaviour?

Thanks Uli
Mon, Mar 23 2009 9:23 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli


If edSearch.text changes each time then I'd say yes. My understanding is that queries can be refreshed ie reapply the same WHERE clause but essentially you're asking for a different query.

Roy Lambert [Team Elevate]
Mon, Mar 23 2009 12:08 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Uli,

Also, for better performance, if you are repeatedly executing the same query
with different parameter values you should explicitly prepare the statement
before the first "open" call and explicitly unprepare it when it is no longer
needed. That will avoid the query to be repeatedly prepared and unprepared each
time it is opened and closed.

--
Fernando Dias
[Team Elevate]
Mon, Mar 23 2009 12:21 PMPermanent Link

Uli Becker
Fernando,

> Also, for better performance, if you are repeatedly executing the same
> query with different parameter values you should explicitly prepare the
> statement before the first "open"

I am doing so with all queries that are frequently used. Same in this case.
Nevertheless the refresh does not work.

Uli
Mon, Mar 23 2009 12:22 PMPermanent Link

Uli Becker
Roy,

> If edSearch.text changes each time then I'd say yes. My understanding is that queries can be refreshed ie reapply the same WHERE clause but essentially you're asking for a different query.

Sure edSearch.text changes each time.

Uli
Mon, Mar 23 2009 1:44 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Uli,

> Nevertheless the refresh does not work.

Well, it works - it just doesn't do what you was expecting it to do Smiley
The query isn't executed again with new parameter values when you call refresh;
only the rows that changed in the underlying table(s) are updated in the result
dataset after a call to Refresh.

--
Fernando Dias
[Team Elevate]
Mon, Mar 23 2009 2:55 PMPermanent Link

Ulrich Becker
Fernando,

> only the rows that changed in the underlying table(s) are updated in the
> result dataset after a call to Refresh.

Sorry, but I don't understand what you mean. The query produces a result
dataset. When changing a parameter and executing the query again, the
result dataset has changed.

The question now is whether or not a refresh is sufficient to show the
changed result dataset or a close/open action has to be done.

I remember the same problem with stored procedures some time ago. There
it was a bug.

Uli
Mon, Mar 23 2009 3:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< The question now is whether or not a refresh is sufficient to show the
changed result dataset or a close/open action has to be done. >>

You have to do a close/re-open.  Changing the parameter value and calling
Refresh does nothing but refresh the result set using the older parameter
values.  Parameter values are not re-assigned without re-executing the
query, which is what Open does, but Refresh does not.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Mar 23 2009 3:57 PMPermanent Link

Ulrich Becker
Tim,

> You have to do a close/re-open.  Changing the parameter value and calling
> Refresh does nothing but refresh the result set using the older parameter
> values.  Parameter values are not re-assigned without re-executing the
> query, which is what Open does, but Refresh does not.

Ok, clear answer. Thank you.

Uli
Mon, Mar 23 2009 4:00 PMPermanent Link

Ulrich Becker
Tim,
> You have to do a close/re-open.

Do I remember correctly that this is different with stored procedures?

Uli
Page 1 of 2Next Page »
Jump to Page:  1 2
Image