Subject Re: [IBO] Two editable and indexed columns from two tables
Author Raymond Kennington
Raymond Kennington 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.
>

Now I have it working with:

> > The following is required for allowing ordering by a looked-up field that is
> > computed.
> >
> > SELECT
> > A.ID,
> > A.NAME,
> > (SELECT B.NAME from B WHERE B.ID = A.BID) AS B_Name
> > FROM A
> > ORDER BY B_Name
> >
> > It doesn't work, so how should one do this?
>
> Try: ORDER BY 3

with

> CaptainName=3; 3 DESC
> and
> CaptainName=Item=1
>


--
Raymond Kennington
Programming Solutions
W2W Team B
--
Raymond Kennington
Programming Solutions
W2W Team B