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 |
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-07-23 : 18:55:49
|
Hello,I have a stored procedure that bills clients based on usage.However, I have a question about high volume transactions.PROBLEMWhen a user has 1 unit/credit and he is to be billed for 1 or 2 credits. I use the following script. NOTE THE CREDITS Column is numeric (18,2)if (@credit_b4 >= @sms_cost)beginUpdate user_credits set credits = credits - 1#end However, I noticed. 1. That if goes to negative billing if it exceeds the users credits2. NOVICE QUESTIONif two transactions are queued simultaneously. To bill the user for 1 credit each and the user has 1 credit left. What happens ? Does this also go into the negative in MS SQLAnd how do build an effective billing system that does not go into the negative ???Thanks in advnaceMIYes O ! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 04:01:39
|
| Are you askimg a way to avoid negative values? didnt get what yoou're asking for? also please note that this is MS SQL forum. you may get accurate solution if you post your question in some MySQL forum. |
 |
|
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-24 : 08:18:50
|
| before the updation check credits,will it go negative by subtracting with some amount(1#)AND THEN CONTINUE THE UPDATION. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 08:24:49
|
quote: Originally posted by VGuyz before the updation check credits,will it go negative by subtracting with some amount(1#)AND THEN CONTINUE THE UPDATION.
nope. it will first take the existing value of credits then subtract the other quantity and then updates the result back to credit field |
 |
|
|
|
|
|