Subject Re: [IBO] RefinedSQL and assigning problem
Author Steve Fields
--- In, Helen Borrie <helebor@t...> wrote:
> At 04:22 PM 8/09/2005 +0000, you wrote:
> >Hi all,
> >
> >I am trying to execute the statement(s):
> >(TIB_Query's, IB 4.5B, D5 Ent)
> >
> >SecMasterQuery.SQL.Text := MasterQuery.RefinedSQL;
> >SecDetailQuery.SQL.Text := DetailQuery.RefinedSQL;
> >
> >but right after assigning this value the My_Query
> >SQL text does not show any change. Could there be
> >any settings that would prevent setting this text?
> You should never try to "assign" a statement by setting the SQL.Text
> property. This doesn't just go for the TStrings classes that IBO uses,
> it's a general rule for TStrings. Although the Text property of a
> is writable, it is almost never used for writing. The class is
designed to
> *deliver* a string based on the content of the indexed strings within.
> To pass the current SQL from one statement object to another, use
> AssignSQLWithSearch

I notice that this requires passing a dataset as a parameter. Do
you know of any other _proper_ way to pass a string? I am using the
bookmark to stringlist routine (SelectedBookmarks) and the actual
values of key fields to send to a second procedure to be ablt to
get a report of only selected records from a grid. Would passing
a stringlist and then stepping through the list and adding to the
second stringlist (SQL) of the destination query work?

> >I am trying to work a basic invoice type system where
> >there is one master and many detail records. After
> >selecting one master record and linking the details,
> >using masterlink/mastersource, I then also try to filter
> >out some of the detail records using a TIB_SearchPanel and
> >the resulting RefinedSQL text.
> >After performing the filtering I then carry the master's
> >SQL statement over to a second pair of TIB_Query components
> >linked in the same way as the main two.
> >After I carry the DetailQuery's SQL over, though, it refuses
> >to make any changes to the second SQL statement, SecDetailQuery.
> >Any ideas?
> See above.
> Make sure that both datasets are in a condition where reassignment
of the
> SQL property is logically possible. For example, if you are
> the SQL of two dependent statements, then don't try to prepare or
open one
> before you have attended to the other.
> The right place to do these changes is in the OnPrepareSQL event. That
> means that the decision to change, e.g. a button-click event, must not
> occur at a point where something else is going on, like part-way
through an
> edit or search operation. Ensure that the statement is actually
going to
> be prepared as a result of what your button-click does; otherwise
there is
> no OnPrepareSQL event and there will be no certainty about the state
of the
> objects.

I am using the refined SQL string to actuallu define how the second
TIB_Query acts in the second procedure. After assigning the string
I prepare and open the query for access.

Steve Fields