RE: [DUG]: Master/Detail/Master/Detail
Hi Phil. Everything is fine down to here: >So, I replaced the TTable for the Transaction table with a TQuery and used >a simple SQL that was updated every time the Client's TTable was scrolled. >Worked great! Except that I the resul was read only because the SQL >involved more than one table (even though all the retrieved columns were >from the transaction table). I needed it to be live. Firstly, you don't need to change the SQL every time - you can use the TQuery's DataSource property. This is basically the same as the MasterSource property of a TTable. Secondly, if you need a read only query to be live, it can be done effectively in one of two ways. The best way is probably to use a TClientDataSet - Inprise encourage you to go down this path by preference (granted, they want you to get introduced to MIDAS, and TClientDataSet is a precursor to that :). Have a look at the demos, especially MIDAS\Aggregate for a good introduction to TClientDataSets. The other way is to turn TQuery.CachedUpdates true and stick an TUpdateSQL object on your form, setting the TQuery.UpdateObject to that, and use ApplyUpdates, CommitUpdates, and CancelUpdates appropriately (like every time you post). Both methods are pretty straightforward. >So, I still used the TQuery, I put back the TTable for the Transactions >table, and I created a new filter for the Transactions TTable each time the >Client's TTable was scrolled, based upon the results of the TQuery. Well, hey, if it works don't fix it! :) The only problems might be speed, or if you decide you need all TQuerys at a later date. Cheers, Carl Reynolds Ph: +64-9-4154790 CJN Technologies Ltd. Fax: +64-9-4154791 [EMAIL PROTECTED]DDI: +64-9-4154795 PO Box 302-278, North Harbour, Auckland, New Zealand 12 Piermark Drive, North Harbour Estate, Auckland, NZ Visit our website at http://www.cjntech.co.nz/ --- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz
RE: [DUG]: Master/Detail/Master/Detail
AFAIK there is no potted solution to this. Your query would be fine with a TUpdateSQL to make it "Live". Your filter will likewise work fine but it's a two step process. I'd go for the TUpdateSQL if you're in a C/S environment. Otherwise as long as the speed's OK... Remember, even on the back end of a SQL database, someone had to write some code to make it work in the first place anyway. Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, 23 March 1999 18:01 To: Multiple recipients of list delphi Subject: [DUG]: Master/Detail/Master/Detail Hi, I have a three table relationship that I figure must be so common that someone must have come up with a better solution for this than I have. If so, please expound your solution (if willing): Here's the scenario: I have a client table, a transactino table, and a junction table. A client can have more than one transaction, and a transaction can have more than one client - hence the junction table which links client ID's with transaction ID's. Placing three TTables, and three TDataSources on the form gives me access to all three (obviously). The main part of the form deals with the client details. As the user scrolls through each client using a DBNavigator the main part of the form fills in with the client's details and a grid at the bottom of the form updates with all the transactions that the user has against them. Initially I had the MasterFields property of the Junction's TTable set to the Client's TTable, and the MasterFields property of the Transaction's TTable set to the Junction TTable. But (you guessed it) the transaction grid at the bottom of the form only ever shows one transaction (even when there are more) because it is linked to just the active record in the Junction's TTable, not the whole range. So, I replaced the TTable for the Transaction table with a TQuery and used a simple SQL that was updated every time the Client's TTable was scrolled. Worked great! Except that I the resul was read only because the SQL involved more than one table (even though all the retrieved columns were from the transaction table). I needed it to be live. So, I still used the TQuery, I put back the TTable for the Transactions table, and I created a new filter for the Transactions TTable each time the Client's TTable was scrolled, based upon the results of the TQuery. This works fine. But, as I said at the start, I'm sure there must be a better way? Any comments? cheers, Phil Middlemiss [EMAIL PROTECTED] --- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz --- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz