Useally I am catching error like this
EXECUTE (@STATEMENT)
SELECT @ERR_CODE = @@ERROR
its working on simple errors , like below query .. @@ERROR return value
insert into tab1 values(1) -- error attempt to insert unique constraint
however the below query also give unique constraint error however the @ERROR dont catch it it return null value
insert into tab1 select id from tab2
so the above statement give unique constraint but @ERROR doesnt catch it
another example I have the below error
sybase could not acquire a lock within the specified wait period
@ERROR didnt catch either
My question is there a way where I can catch any error where executing statement ?