Subject Re: [IBO] DMLCache Receive/Announce mechanism
Author Helen Borrie
At 07:48 PM 21/02/2004 +0000, you wrote:
>Hi folks,
>
>I have a functional problem using DML cache mechanism. Let me try to
>explain.
>
>I use DML cache to notify datasets on forms across application.
>Within one form I have two datasets connected as master-detail.
>
>MasterQuery receives DML notifications. DetailQuery sends DML
>notifications.
>
>When MasterQuery receives notification, it calls its own RefreshKeys
>method (I use a stored procedure to populate MasterQuery). Everything
>looks good except of when I try to delete a record from DetailQuery.
>What happens (as per my understanding) is MasterQuery receives DML
>notification and refreshes data before DetailQuery completes deletion
>process. As I result of this I get an error message "Invalid reference
>to Delete" (IB_NodeList, procedure TIB_NodeList.CurrentDelete, 1203).
>
>Is there any way to deal with this situation and make it so
>notification sent after deletion process is complete?
>
>The only workaround I found is to put:
>
>- DetailQuery.DataSource := nil in OnBeforeDelete event for DetailQuery
>- DetailQuery.DataSource := MasterDatasource in OnAfterDelete event
>for DetailQuery

DMLCache events are supposed to respond to committed changes in tables.

If I understand the setup correctly (you have no table underlying the
Master) then DMLCache notification is the wrong method to use for notifying
the master of a change in its detail. In a dataset that uses a SP, there
is no underlying data structure in the database from which to "Refresh"
: the only way to get an updated view is to call the SP again *after* the
detail data have been committed.

The AfterCommit method of the transaction seems to be the earliest event
where it makes sense to tell the master to "refresh" itself.

For example, you could use the Master's OnReceiveDMLCacheItem to set a flag
to cause the SP to run afresh after the Commit. Have the transaction's
AfterCommit handler read this flag and call a method if it is set.

Helen