Hi,
I'm trying to write a stored procedure that checks whether there is a row in the table for a product added to a shopping associated with that user, if so ammend quantity otherwise create a new row.
I am passing in 4 parameters as integers which are inUID, inPID, inQty, inPrice
When trying to run a query to create it I get the error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS"
My stored procedure is below:
CREATE PROCEDURE sp_insert_basket_dev
(IN inUID int,IN inPID int,IN inQty int,IN inPrice int)
AS
BEGIN
IF EXISTS(SELECT PID AS selPID, Qty AS selQty FROM basket WHERE UID = inUID AND PID = inPID)
BEGIN
UPDATE basket SET Qty = selQty+inQty WHERE UID = inUID AND PID = inPID
END
ELSE
BEGIN
INSERT INTO basket (UID,PID,Qty,Price)
VALUES (inUID,inPID,inQty,inPrice
)
END
END
GO
I hope someone can help shed some light onto a solution
Start Free Trial