Break, Cancel BlockExecutor
dUros
Posts: 21 Bronze 1
In rare cases the execution of SQL script is stopped. I figured out, that this happens if the object (that is suppossed to be upgraded) is used by some user (locking).
The problem is easily fixed by using KILL connections in SSMSA.
I wonder if there is any way that you can catch this error or if it is possible to simply stop the script from executing (by pressing a button?).
I found a BlockExecutor.CancelOperation method in the manual, but I can't find any examples on how to use the method.
Regards
The problem is easily fixed by using KILL connections in SSMSA.
I wonder if there is any way that you can catch this error or if it is possible to simply stop the script from executing (by pressing a button?).
I found a BlockExecutor.CancelOperation method in the manual, but I can't find any examples on how to use the method.
Regards
Comments
I'm not sure how you detect the locking automatically - the SDK doesn't do that. I always thought the SET TRANSACTION ISOLATION LEVEL SERIALIZABLE was specified by SQL Compare to prevent that sort of thing.
If you want to cancel a synchronization, you can use CancelOperation but I assume this would only work in a multithreaded environment, otherwise you would not get a chance to run the CancelOperation method until the synchronization actually finishes and returns control to the calling method. It should work like this:
In youre code, I see what I want to see . In other way, one thread is better or program wil end and user will think that is all Ok.
Now I run SP with "kill connections" for upgrading DB, before upgrading. No more problems with locking and user looking hourglass till the end of upgrade.
Regards
Thank for advise, but I think is better killing connections with KILL, becouse if come to error, DB will stay in single user mode.
My proc for killing connections: