Jump to content
Larry Ullman's Book Forums

blackrooksix

Members
  • Posts

    1
  • Joined

  • Last visited

blackrooksix's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I am attempting to create a procedure based on add_to_cart(), but am getting a SQL Syntax error. DELIMITER $$ CREATE PROCEDURE add_to_cart(uid CHAR(32), item_type VARCHAR(7), item_id MEDIUMINT, opt1 VARCHAR(32), opt2 VARCHAR(32), qty TINYINT) BEGIN DECLARE cart_id INT; SELECT id INTO cart_id FROM carts WHERE user_session_id=uid AND item_type=item_type AND item_id=item_id AND option_1=opt1 AND option_2=opt2; IF cart_id > 0 THEN UPDATE carts SET quantity=quantity+qty, date_modified=NOW() WHERE id=cart_id; ELSE INSERT INTO carts (user_session_id, item_type, item_id, option_1, option_2, quantity) VALUES (uid, item_type, item_id, opt1, opt2, qty); END IF; END$$ DELIMITER ; Clearly, I have added a few columns, but believe I am accounting for them correctly. In reading the MySQL documentation, it recommends 'SELECT id INTO @cart_id...' and that, too, fails. So I am at a loss as to where I am munging the syntax here.
×
×
  • Create New...