DROP PROCEDURE testproc;
DELIMITER //
CREATE PROCEDURE testproc (IN pid INT, IN pamount INT)
BEGIN
DECLARE bal INT;
START TRANSACTION;
SELECT balance INTO bal FROM test1 where id = pid;
UPDATE test1 SET balance = (bal + pamount) WHERE id = pid;
COMMIT;
END;
//
DELIMITER ;
Statement DELIMITER sangat penting, kalau tidak MySQL akan memberikan pesan ERROR.
No comments:
Post a Comment