Search code examples
error-handlingtriggerssybasesap-ase

@@ERROR <> 0 in trigger


I'm involved in new project right now and I faced with below logic in Sybase ASE trigger:

CREATE TRIGGER TR_TEST2
   ON TBL_TEMP2
FOR INSERT
 AS  
 insert into TBL_TEMP select * from inserted
if @@error != 0
begin
print 'ERROR!!!'
rollback trigger
end

I've checked this trigger with different cases and I can't understand when if @@error != 0 will be treated. If there are some errors in INSERT, the trigger just fails with error and rolled back. And trigger execution will be aborted on the statement which raised error Can someone explain me for what purposes if @@error != 0 is used in triggers and when it can trigger?


Solution

  • I've used for testing Sybase Central v.6.0 And it does't show any PRINT results if error occurs When I've used QTODBC tool for connecting to Sybase ASE server, it threw me exception and printed 'ERROR!!!' message

    So, this is the feature of Sybase Central environment Actually, trigger resumes working when any error occurred