SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 not regonizing -2
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mike13
Posting Yak Master

Netherlands
215 Posts

Posted - 02/05/2013 :  11:12:42  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
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

India
52325 Posts

Posted - 02/05/2013 :  11:27:22  Show Profile  Reply with Quote
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/

Go to Top of Page

mike13
Posting Yak Master

Netherlands
215 Posts

Posted - 02/05/2013 :  11:40:42  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
i know @tempstock is -2
because T_Product_Option.stock - @Quant)
stock=3 and Quant=5
=-2
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/05/2013 :  12:00:08  Show Profile  Reply with Quote
put a select after assignment to check value of @tempstock and check if its -2

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mike13
Posting Yak Master

Netherlands
215 Posts

Posted - 02/05/2013 :  13:06:31  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
yep you where right!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/05/2013 :  13:12:51  Show Profile  Reply with Quote
i know I'm
Has happened to me in lots of cases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000