Page 1 of 1

SCOPE_IDENTITY() trick in OnAfterUpdateRecord not working

Posted: Tue 14 Jul 2009 12:00
by dmajkic
Hi.

I was using SCOPE_IDENTITY() trick in OnAfterUpdateRecord of TProvider, but it is not working any more since SELECT SCOPE_IDENTITY() called from event is executed in another scope.

Using DBMonitor, I can see that INSERT INTO (...) is executed via one Cursor and SELECT SCOPE_IDENTITY() via another cursor which is other scope, and i allways get NULL as result.

SELECT @@IDENTITY retreives a value, but it is wrong one if table has triggers which update another table (and that is the main reason why SCOPE_IDENTITY use is advised over @@IDENTITY).

Any help on how to retreive correct IDs after inserting into table?

Posted: Mon 20 Jul 2009 12:06
by Dimon
Please. try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.