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 |
mike13
Posting Yak Master
219 Posts |
Posted - 2013-02-05 : 11:12:42
|
Hi all,
I got this store SP declare @tempstock2 as INT UPDATE T_Product_Option SET stock = (T_Product_Option.stock - @Quant) WHERE ID = @OptionID /****** dont let stock be 0 for now *****/
select @tempstock2=stock from T_Product_Option WHERE ID = @OptionID IF @tempstock<0 UPDATE T_Product_Option SET stock = 1 WHERE ID = @OptionID
@tempstock is -2
but it does go into the if IF @tempstock<0 so it considers -2>0 ??
or i'm doing something wrong? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-05 : 11:27:22
|
how do you know @tempstock is -2?
what does this return?
select stock from T_Product_Option WHERE ID = @OptionID
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
mike13
Posting Yak Master
219 Posts |
Posted - 2013-02-05 : 11:40:42
|
i know @tempstock is -2 because T_Product_Option.stock - @Quant) stock=3 and Quant=5 =-2 |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-05 : 12:00:08
|
put a select after assignment to check value of @tempstock and check if its -2
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
mike13
Posting Yak Master
219 Posts |
Posted - 2013-02-05 : 13:06:31
|
yep you where right! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-05 : 13:12:51
|
i know I'm  Has happened to me in lots of cases.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
|
|