Specifies the update object component used to post updates by dataset.
Use UpdateObject to specify the TADUpdateSQL component to use in an application that must be able to post updates in a non-standard way.
The AnyDAC has build in updates command generator, which using multiple information sources is able to generate SQL update commands for most of scenarios. In some cases, such as a query made against multiple tables, which may require multi-statement update, AnyDAC cannot generate SQL update commands. In these cases, UpdateObject can be used to specify a TADUpdateSQL component that allows to specify custom SQL commands for each update posting case, like a insert / update / delete.
As alternative to update object usage, you can consider to use OnUpdateRecord event. It gives more options, but requires manual coding of posting updates. Also, in OnUpdateRecord handler you can use multiple update objects. See demo AnyDAC\Samples\Comp Layer\TADUpdateSQL\Main.
ADUpdateSQL1.InsertSQL.Text := 'insert into mytab values (:new_id, :new_name)'; ADQuery1.UpdateObject := ADUpdateSQL1; ADQuery1.Append; ADQuery1['id'] := 100; ADQuery1['name'] := 'qwe'; ADQuery1.Post;
What do you think about this topic? Send feedback!