Subject Re: TIB_Query & join selects
Author yartax1
When I said a "master query class", I tried to explain a class with
all the queries performed to bbdd. This class is like:

class bbdd
AnsiString get_parte ( int usuario );
AnsiString get_revision ( int usuario );

This class returns AnsiStrings ( queries ) to pass to the TIB_Query.
This is good to separate form code from database code.

In my case I want make the next query:

Select a.*
from incidencia_parte a
inner join usuario_centro b
on a.centro = b.centro
where fbaja is null and idusuario=1
order by a.centro,fregistro

Primary keys:

My question is; this query is only possible in a procedure?


--- In, Helen Borrie <helebor@t...> wrote:
> At 01:52 PM 22/10/2004 +0000, you wrote:
> >Hi,
> >
> >Why a TIB_Query like "select a.* from tablex a inner join tablex b on
> >a.x = b.x where b.x=1" can't be editable?.
> According to the rules of logic, joined, grouped and unioned queries
> not output naturally "editable" datasets. In the case of joined
sets, it
> is not possible to request an UPDATE of more than a single row. In the
> case of grouped and unioned sets, the sets are derived and cannot be
> related back to the tables from which they were extracted.
> >The query only return
> >master table fields with its own primary keys.
> You need at least the primary keys of all of the joined tables as your
> KeyLinks for a joined set.
> >I made a class "bbdd"
> >with all ddbb queries within. And I do next:
> >
> >TIB_query->SQL->Clear();
> >TIB_query->SQL->Insert(0,bbdd->Get_tablex());
> >TIB_query->Open();
> >
> >How can make this recordset editable? I must use joinlinks
> No, JoinLinks are used only when the old SQL-89 syntax is used for
> joins. In this older syntax, join criteria are mixed with search
> and JoinLinks are used to tell IBO which are the join criteria.
> >and other
> >parameters in each form and TIB_query, instead of a master queries
> You've lost me on the "master queries class" so I'll leave you to
work out
> what you want to do with it.
> The Master-Detail model doesn't use joins. It has the "1" side of a
> relationship as "master" and the "Many" side as detail. There are
> "masterlinks" from the detail side to the master side, usually a
> key on the detail that points to the primary key of the master.
> In IBO, you can make one table in a joined set updatable by setting the
> KeyRelation property to the name of that table. The Keylinks must
> the primary key of that table. Set RequestLive true.
> If you want to be able to edit, insert into or delete from a joined
> write executable stored procedures that do this, with input parameters
> defined sufficient to find all of the underlying records. In the
> properties of the dataset, write parameterised EXECUTE PROCEDURE
> statements, using input parameter names that match the fieldnames of
> dataset.
> Helen