APvFd> Certainly you can repeat search for master record in trigger but IMHO
APvFd> that's not beautiful solution.

Not sure if I understand what you mean with "repeat search for master
record".

The only workaround that I can think of, to not break the business
logic, would be checking rows_affected after the update and if it
zero, raise an exception. This would need to be done in all triggers
with such logic, and I see it as an ugly workaround, not a real
solution.

[]s
Carlos
http://www.firebirdnews.org
FireBase - http://www.FireBase.com.br

APvFd> On 06.09.2019 14:14, Carlos H. Cantu wrote:
>> Re: [Firebird-devel] Inserts and FKs
>>
>>       Hi
>>
>> "tx2 inserts a detail record in TableB
>>     Trigger on TableB tries to update master record,
>>     since the record is still not visible for this snapshot,
>>     update has null effect"
>>
>> I do not understand this point. If table B i detail it can only insert 
>> record for visible to it record in master. Or do you in your trigger 
>> you update whole table master not only master record of this detail?
>>
>>
>> Trigger updates only the master record. The problem is exactly the 
>> fact that the insert of the detail record doesn't fail, because FK is 
>> out of transaction control so it can see the master record (but the 
>> update can't see it).

APvFd> Certainly you can repeat search for master record in trigger but IMHO 
APvFd> that's not beautiful solution.



APvFd> Firebird-Devel mailing list, web interface at
APvFd> https://lists.sourceforge.net/lists/listinfo/firebird-devel



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to