1
Answer

update query in sql server with user session id

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)

1
Photo of Manish Dwivedi
NA 8.3k 1.2m 14y

Hi will,
for str, single character is converted to its relevant ASCII value.
Same is happen for str2 , taking ASCII value for characters(Here fix string is AMEND, you have to make it large like AMENDING)
and str3 we are taking the difference of ASCII value.

and making the format like that 1245/2543/475812
and in last line the value you got is converted to datetime.
This is the working og this code, but still i didn't get the purpose of code.
 
 
 


 
Anybody wish to share with me how this code actually works?
 
Accepted
0
Photo of Will
NA 3 1.8k 14y

Thank You very much for your answer.
I had worked out that it was subtracting from the ASCII value of each character in the str2 "string" moments before you post, and have since made the code work how I required :)
Regards :)