Subject Re: [IBO] IBO, updatable views and DataSnap
Author Helen Borrie
At 09:00 PM 9/09/2007, you wrote:
>I use a view formed by 2 tables. By default, it is read/only but I
>added the corresponding triggers for insert, delete and update.
>Then, in my project, I use TClientDataSet + IBO to access to view, I
>can insert a register without problems, but when I delete it, IBO
>returns "Record not found or changed by another user".
>Studying the IBO source, I see that the problem is when IBO get
>RowsAffected variable and arises the above exception because the
>values is 0.

Actually, the real problem (for your architecture) is that IBO has no
way to know the RowsAffected, since it is reading a derived data that
is many steps away from user DML. IBO has no way to get information
back about operations that were performed by triggers.


>Firebird return 0 in the delete member of isc_info_sql_records call,
>and then IBO interpret that the record has not been deleted. In
>reality, the record has been deleted in the trigger because the view
>is formed by 2 tables and I need to delete the record in both tables.
>
>Is there a way to avoid this problem?

Yes. Don't rely on RowsAffected when working with anything that is
not updated directly by your application, i.e. pure DSQL from the
client. You will need to coordinate the client-side and server-side
elements of your design if you need success/failure information back
to the client.

Write exception handling into your trigger code so that, if the
operation fails, your application will know about it. Clearly you
need to handle any exceptions returned at the client side, as well.

You don't need "success" information. If the operation returns no
exceptions from the server side, you don't need anything to prove
that it succeeded: just swallow that "record not found" exception
(that is thrown by the client, not the server) and refresh the dataset.

Helen