Need to put select and update in a single stored procedure

  • hi all,

    Let me explain my requirement briefly. I have a table called compliant which stores compliant posted by users. When a new compliant is posted, then status of that compliant will be "Opened". Similarly once the compliant is resolved by the support team they will set the status of compliant to "User to Confirm". If user is satisfied then he/she can set the compliant status into "Closed". If user missed to change status as "Closed", once it has resolved then after 48 hours compliant status should set to "Closed" and also an automated mail should sent to user regarding status of that compliant.

    I have created an stored procedure which display all compliant along with user details, which are resolved before 48 hours whose status to be changed to "Closed". Now from c# application I will send mails to all those users. Then I am calling another stored procedure to update status of the compliant as "Closed", which takes compliant number as parameter.

    Can anyone help me to write both sql statements (selecting compliants and updating compliant status) inside a single stored procedure? Also I want to know is it required to use transaction in my case?

  • Hi

    The status must be updated to "Close" only if the mail has been sent successfully right ?

    If this is not the case then you can put both the select and update statements in a single procedure.

    Otherwise do it separately ... This will ensure that status is updated only when a mail is sent.

    "Keep Trying"

  • hi,

    thanks for your suggestion. Status should be updated to "close" only when mail is sent. Ok I will use 2 stored procedures, is it required to use transaction (client side)

  • Hi

    Better use a transaction (client side). Otherwise the mail may not be sent but the status will be updated.

    "Keep Trying"

  • Thank you very much:)

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

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