Results 1 to 3 of 3
Apr 11, 2013, 08:43 #1
- Join Date
- Sep 2011
- 0 Post(s)
- 0 Thread(s)
Procedure Transaction Code returns "Query OK, 0 rows affected"
My procedure is calling a simple transaction for updating two tables. It is successfully saved as a procedure, but when called, it doesn't execute the code. It simply returns "Query OK, 0 rows affected". Running in MySQL 5.6.10.
Am I missing something in my syntax? Perhaps it is error in how it is being executed?
CREATE PROCEDURE transact_account (amount DECIMAL(9,2), description VARCHAR(200), account_type VARCHAR(30), transaction_type VARCHAR(20)) BEGIN START TRANSACTION; INSERT INTO transactions SELECT null, now(), amount, description, account_id FROM accounts WHERE type = account_type; IF transaction_type = 'credit' THEN UPDATE accounts SET balance = balance + amount WHERE type = account_type; ELSEIF transaction_type = 'debit' THEN UPDATE accounts SET balance = balance - amount WHERE type = account_type; END IF; COMMIT; END CALL PROCEDURE transact_account (1000, 'freelance', 'checkings', 'credit');