On Wed, 12 Dec 2007, Joost van der Sluis wrote:
> Op woensdag 12-12-2007 om 15:11 uur [tijdzone +0200], schreef Graeme
> Geldenhuys:
> >
> > Step 1:
> > ======
> > TIBConnection <- TSQLTransaction via 'Database' property. No problem
> > here.
> >
> > Step 2:
> > ======
> > TIBConnection -> TSQLTransaction via 'Transaction' property.
> > Why??? Why must you link components in both directions?
>
> You don't need to do this. It is used when the TIBConnection tries to
> execute some sql-statements itself. If has to know which transaction it
> should use. You have to see this as the 'default transaction'. If you do
> TIBConnection.ExecuteDirect, this transaction is used. This transaction
> is also used when you use ApplyUpdates.
1. It should be set to the first transaction that is hooked up to it.
That's what IBX does, and it makes sense. So you don't need to set it.
2. ApplyUpdates should use the transaction of TSQLQuery ?
>
> > Step 3:
> > ======
> > TSQLTransaction <- TSQLQuery via 'Transaction' property. No problems
> > here.
> >
> > Step 4:
> > ======
> > TIBConnection <- TSQLQuery via 'Database' property. Why??? Can't
> > it figure it out from the TSQLTransaction it's hooked up to already
> > (step 3)? What happens if the Transaction component is hooked up to
> > DB1 and then I specify DB2 in the Database property?
>
> Hm.. I never thought about that, really. It could be usefull, though.
> For example Oracle supports transactions which are working on several
> groups of databases.... Not that this is supported by sqldb...
>
> Michael, would it be an idea to remove this link?
No, because Firebird and Oracle support cross-database transactions, and you
must point out the correct database.
But, setting TSQLQuery.Transaction should set Database if it is not yet set,
and vice versa, setting TSQLQuery.Database should set TRansaction to
Database.Defaulttransaction.
This is on my TODO list before 2.2.2, because I consider this a bug.
>
> > Step 5a:
> > ======
> > TSQLQuery <- TDatasource via the 'Dataset' property. No problems here.
> >
> > Step 5b: (optional)
> > ======
> > TSQLQuery -> TDatasource via the 'DataSource' property. It can be
> > done, but wasn't needed to get my example project to work. Not sure
> > what's the rules about this one.
>
> I've been mistaken about this one more then once. Also my collegues had
> problems with this.
> iirc it's renamed to something else in recent versions. What it does is
> handling the master-detail relationships.
It is not renamed, and it should not be. In Delphi it is also called DataSource.
As Joost says, it is needed to handle Master-Detail relations:
Query1:
Select ID, * from Invoice
DS1.Dataset=Query1;
Query2:
Select * from InvoiceDetails Where InvoiceID=:ID;
Query2.DataSource:=DS1;
As the user scrolls through Query1, Query2 is updated automatically with the
new ID value.
Michael.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives