Let me preface this request for help with the disclaimer that @@error is somewhat of a mystery to me. I understand somewhat what it does, but using this function has proven to be tricky.
When an error occurs, I don't get the expected email nor does the update to the row checkpoint occur.
Can anyone tell me what I did wrong?
Thanks!
Margaret
Code:
BEGIN TRANSACTION
insert into request_event select
externalrefid,
sequence,
security_code,
request_line,
req_line_sequence,
event_type,
event_type_reason,
event_dt,
event_tm,
customer_event_dt,
customer_event_tm,
person_id_from,
person_id_to,
description,
dur_minutes,
value_from,
value_to,
value_type,
promised_begin_dt,
promised_begin_tm
from
newevent2
where
chk=0
IF @@ERROR <>0
BEGIN
update econupdate set chk=2
from econupdate join newwork on econupdate.externalrefid=newwork.externalrefid
and econupdate.econupdate_identity=newwork.updateindex
exec master..xp_sendmail
@recipients='margaretn@ttc-inc.com',
@subject='Event insert step failed',
@query='select * from econupdate where chk=2',
@attach_results='true',
@width=250
ROLLBACK TRANSACTION
RETURN
END
COMMIT TRANSACTION
end
When an error occurs, I don't get the expected email nor does the update to the row checkpoint occur.
Can anyone tell me what I did wrong?
Thanks!
Margaret