Subject Re: [IBO] TIB_Query & join selects
Author Helen Borrie
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 can
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 criteria
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 class?

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 1:Many
relationship as "master" and the "Many" side as detail. There are
"masterlinks" from the detail side to the master side, usually a foreign
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 include
the primary key of that table. Set RequestLive true.

If you want to be able to edit, insert into or delete from a joined set,
write executable stored procedures that do this, with input parameters
defined sufficient to find all of the underlying records. In the XxxxSQL
properties of the dataset, write parameterised EXECUTE PROCEDURE
statements, using input parameter names that match the fieldnames of the
dataset.

Helen