Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need to put select and update in a single stored procedure Expand / Collapse
Author
Message
Posted Thursday, October 4, 2007 11:10 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, January 13, 2014 1:31 AM
Points: 606, Visits: 335
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?




Post #407177
Posted Friday, October 5, 2007 12:08 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 6:55 AM
Points: 2,366, Visits: 1,845
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"
Post #407181
Posted Friday, October 5, 2007 12:20 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, January 13, 2014 1:31 AM
Points: 606, Visits: 335
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)
Post #407183
Posted Friday, October 5, 2007 4:59 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 6:55 AM
Points: 2,366, Visits: 1,845
Hi

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



"Keep Trying"
Post #407267
Posted Friday, October 5, 2007 6:27 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, January 13, 2014 1:31 AM
Points: 606, Visits: 335
Thank you very much:)
Post #407308
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse