Devendra  Kumar

Devendra Kumar

  • NA
  • 517
  • 246.2k

update query in sql server with user session id

Apr 14 2016 5:04 AM
hi friends please solve this query:
 
 
i am add product in cart
it insert.
 and when update my quantity it update
but  i want when add repeat product then it return value=3;
in this procedure
insert and update proper work ;
but repeat return value =3 not working  
 
 
Set @count=(Select COUNT(1) from dbo.MyCart where SessionId=@SessionId and Product_Fkid=@Product_Fkid)
if(@count=0)
begin
Insert into dbo.MyCart(SessionId,Product_Fkid,Qty,size_Fkid) values (@SessionId,@Product_Fkid,@Qty,@size_Fkid)
Set @ReturnValue=1
end
 
 
 
 
Set @count=(Select COUNT(*) from dbo.Tbl_MyCart where Qty=@Qty and Product_Fkid=@Product_Fkid) and SessionId=@SessionId
 
if (@count=1)
begin 
Set @ReturnValue=3
end
 
else
begin
update dbo.Tbl_MyCart
Set Qty=@Qty
where SessionId=@SessionId and Product_Fkid=@Product_Fkid
Set @ReturnValue=2
end
return @ReturnValue
 

Answers (1)