Cusor - Sending Email - Updating table

  • Morning,

       When a table is updated I have a trigger to insert data into a reporting table. Every 15 minutes I run a Job which fires a cursor to select new entries, send an Email and then update the reporting table attribute "Email_Sent" with a Y to ensure that duplicate Emails are not sent.

       Works well in most cases. However, it occassionaly fails to send the Emails, but still updates the reporting table attribute "Email_Sent" with a Y. Can I insert the cursor into a Transaction to ensure that the table is only updated if the Emails are sent?

       For those that are interested the Job fails with the following error.

    SqlDumpExceptionHandler: Process 64 generated fatal exception c0000005

    EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process. [SQLSTATE HY000] (Error 0) 

    Associated statement is not prepared [SQLSTATE HY007] (Error 0).

     The step failed.

      All thoughts welcome and thank you in advance for any advice.

    Colin

  • You can have error handling and update status only if after sending email @@Error remains = 0.

    _____________
    Code for TallyGenerator

  • Thank you very much. I suppose that I now have to wait for a failure to test the code. 😉

    Colin

  • you could test it by raising an error or change the smtp server in the code to an invalid mail server to force an error to occur.


Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply