Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-04-16 : 11:53:45
|
| There are two functions in my app: fnOrder and fnEmail.fnOrder will insert an order into SQL server and fnEmail will send an email to customer if fnOrder return true. Below is my code:if fnOrder then if fnEmail then ...send an confirmation email to customer... end if end if The problem is: if fnOrder = true but fnEmail = false, email will not send to customer but order already insert into SQL db. This is not I want.What I need is only if both of functions are true the order will be inserted into db otherwise do nothing. How to complete it? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-16 : 13:54:46
|
| wrap both of them in a transaction and rollback if not truebegin tran testtranif fnOrder then if fnEmail then ...send an confirmation email to customer...commit tran elserollback tran end if end if |
 |
|
|
|
|
|