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 SPdeclare @tempstock2 as INTUPDATE 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 = @OptionIDIF @tempstock<0UPDATE T_Product_Option SET stock = 1 WHERE ID = @OptionID @tempstock is -2but it does go into the ifIF @tempstock<0so 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 WHEREID = @OptionID------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
mike13
Posting Yak Master
219 Posts |
Posted - 2013-02-05 : 11:40:42
|
i know @tempstock is -2because 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 MVPhttp://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 MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|