Board index » delphi » Updating several tables from a query using UpdateSQL Components
Ed Malloy
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Ed Malloy
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Updating several tables from a query using UpdateSQL Components
Hi All,
How does one update several tables from one query? In design time, Am I supposed to set the Query's update object to "upd1" AND THEN create an OnUpdateRecord event handler that calls both of the Any help appreciated ed |
Philip Cai
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsQuoteEd Malloy <edmal...@stargate.net> wrote: You can do it by using the unpublished TUpdateSQL.Dataset property. If you main query is named MyQuery and if MyQuery returns data from a when you create the form: Do this instead of setting the MyQuery.UpdateObject, which you must use each UpdateSQL for one of the tables you need to update. Then when closing or destroying the form: Good luck. Phil Cain -- |
Ed Mallo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsThanks Philip, But this means that I still have to perform my little subtrefuge to get ed QuotePhilip Cain wrote: |
Philip Cai
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsQuoteEd Malloy <edmal...@stargate.net> wrote: I don't know what version of Delphi you are using (D3 has the cached The truth is that TUpdateSQL is tied at the hip to the dataset. That Another limitation is that an instance of TUpdateSQL is meant for But I do use a trick at design time to help things along. One by one, Then, of course, after I've done that, I set the TQuery.UpdateObject You have to fuss with the SQL anyway. TUpdateSQL was not designed to BTW, OnUpdateRecord is not a required process. If you leave it blank Phil Cain -- |
Ed Mallo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsPhillip see below. QuotePhilip Cain wrote: Quote
at least) are generated at design time, but I have never thought trough where the parameters come from.. hmmm From the documentation it seems that they come from the dataset in a different manner. The "un-dataset-bound" UpdSQL component is called from the OnUpdateRecord event I haven't had time to try this, but it is what the documentation implies. (in both D4 and D5 this section is titled "Creating an OnUpdate event handler." Quote>So, for Quote
handler. It is NOT clear on how to get the SQL code into the update component.. Quote> But I do use a trick at design time to help things along. One by one, this ... AND I suggest that a comma or semi-colon list in the Dataset's update component property would help. Quote
Quote> You have to fuss with the SQL anyway. TUpdateSQL was not designed to Edward V. Malloy |
Philip Cai
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsEd, Quote>> The truth is that TUpdateSQL is tied at the hip to the dataset. That TUpdateSQL is just text. TUpdateSQL uses this when it creates the TQuery. Quote
"un-dataset-bound" but the queries activated there are handled by ApplyUpdates. OnUpdateRecord is called only if there is code in it. If OnUpdateRecord and OnUpdateError are empty (not assigned), TUpdateSQL defaults to an automatic handling mode. It's easy enough to demonstrate this to yourself. Make a one table application with one query and one TUpdateSQL. Make a change and do ApplyUpdates, CommitUpdates. You'll get the change without OnUpdateRecord. Quote
time, do this: MyTUpdateSQL.ModifySQL.Add('put SQL here'); There are also properties for InsertSQL and DeleteSQL. Quote
list" Quote
TUpdateSQL.Dataset object, but not both. The VCL can become confused at that. Concerning your angst over the documentation, I can say only that I've You should also know that since D3, cached updates has undergone only Phil Cain |
Ed Mallo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsQuotePhilip Cain wrote: handler. It works! Quote> Normally, you do this at design time. If you want to do it at run the code when the framework is generated for you, and this is only done when the UpdateSQl is linked to a dataset.. Quote
standard way of entering multiple values, (e.g. creating a lookup variable and linking to a table with a segmented primary ket). Quote
Quote
several tables from a single query though ... it smacks of poor design. Quote>The whole construct is deprecated by Borland and will ed |
Philip Cai
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsQuoteEd Malloy <e...@bblfleet.com> wrote: mean that you can't use the automatic features of the UpdateSQL property editor. If I have several UpdateSQLs for one query then, at run time, I set the Query.UpdateObject property to the UpdateSQLs one at a time. Then I use the design time features of the UpdateSQL to lay in the default SQL. When I am finished with that, I blank out the Query.UpdateObject property and let the code handle the connections during run time. Good luck. Phil Cain |
Ed Mallo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Updating several tables from a query using UpdateSQL ComponentsThanks Philip, that is what I originally asked: was there any way OTHER than the way Take care, ed QuotePhilip Cain wrote: |
1. Cached updates - one query but several tables to update
2. Update Failed with UpdateSQL component and PARADOX tables
3. How to do an Update query or a Delete Query or an Insert Query using D3
4. Using UpdateSQL for updating cached records
5. Differences between UpdateSQL component and Query.ExecSQL
6. Differences between UpdateSQL component and Query.ExecSQL
7. Cached updates & updateSQL component
8. updating record in a join query using ADO and Midas Component