Subject Re: [IBO] Two editable and indexed columns from two tables
Author Marco Menardi <mmenaz@lycosmail.com>
--- In IBObjects@yahoogroups.com, Raymond Kennington <progsol@c...> wrote:
> "Gerard J.M.Houtenbos" wrote:
> >
> > Does the fact that knowbody has followed this thread, mean that
> > it is not possible?
> >
> > Gerard
> >
> > On Wed, 18 Dec 2002 20:14:48 +0100, you wrote:
> >
> > >I do have two tables in an Interbase 6 database accessed by
> > >IB-Objects:
> > >
> > >Players
> > >P_Key: Integer;
> > >Name: String;
> > >CaptainKey: Integer;
> > >
> > >Captains
> > >P_Key: Integer;
> > >Name: String;
> > >
> > >I use a TwwDbGrid in which I need two columns:
> > >Players.Name
> > >Captains.Name
> > >
> > >There are three necessities:
> > >1. The Players.Name must be editable.
> > >2. The Captains.Name must be selectable from a LookUpCombo
> > >3. The grid must be indexed on either column by means of the
> > >TitleButtonClick-method.
> > >
> > >I tried a join-TIBOquery, but then the Captains.Name isn't
> > >editable.
> > >
> > >I tried to use a TIBOquery with a lookupfield for the
> > >Captains.Name, but then I can't index on the Captains.Name using
> > >OrderingItems.
>
> It's taken me 5 hours to work out how to do this.
>
> There are 2 major problems here, one with the GSG and the other with
IBObjects.
>
> 1. This is because IBObjects Gettging Started Guide indicates that
one should
> use a singleton select for the looked-up item rather than a join, so
to start
> with, use a JOIN to get the looked-up item.
>
> Let the SELECT statement be
>
> SELECT A.ID, A.Name, B.Name as CaptainName
> FROM A JOIN B on (B.ID = A.BID)
>
> 2. The Create button on the OrderingLinks page incorrectly produces:
>
> CaptainName=CaptainName; CaptainName DESC
> and
> CaptainName=Item=1
>
> whereas it should have produced
>
> CaptainName=B.Name; B.Name DESC
> and
> CaptainName=Item=1
>
> The documentation and tool are letting us down here and that makes
it very,
> very, very difficult and frustrating.
>

I don't understand the underlying logic... where do you want the
Captain.Name be written? You produce a join between two tables, and
want both be editable? But you seem to being missing a 3° relation
table, Players_u_Captains, wich will contain the many-to-many
relation. That table could be editable and produce a lookup field for
captain name, if you want.
In the question, the lookup control on captain.name, where is supposed
to write it's value? In what field of what table?
btw, for complex editing, you can use Stored Procedure in the
insert/delete/update clause of SQL property, but I've never used...
regards
Marco Menardi