I've got 2 tables:
`deal` (`value`, `when`, `AccountTo`, `AccountFrom`, `Name`)
`account` (`AccountNumber`, `Value`)
I set up a procedure:
CREATE PROCEDURE transfer
(IN Value_IN float,
IN When_IN int(4),
IN AccountTo_IN varchar(26),
IN AccountFrom_IN varchar(26),
IN Name_IN varchar(30))
NOT DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
INSERT INTO deal
(value, when, AccountTo, AccountFrom, Name)
VALUES (Value_IN, When_IN, AccountTo_IN, AccountFrom_IN, Name_IN);
UPDATE account SET Value=(Value+Value_IN) WHERE AccountNumber=AccountTo_IN;
UPDATE account SET Value=(Value-Value_IN) WHERE AccountNumber=AccountFrom_IN;
data is put into 'deal' but 'account' table is not updated
EDIT:
Thanks for answers. It works this way:
CREATE DEFINER=`root`@`localhost` PROCEDURE `transfer`(
Value_IN FLOAT,
When_IN DATE,
AccountTo_IN VARCHAR(26),
AccountFrom_IN VARCHAR(26),
Name_IN VARCHAR(30))
BEGIN
INSERT INTO deal
(value, when, AccountTo, AccountFrom, Name)
VALUES (value_IN, When_IN, AccountTo_IN, AccountFrom_IN, Name_IN);
UPDATE account SET Value = Value+Value_IN) WHERE AccountNumber = AccountTo_IN;
UPDATE account SET Value = Value-Value_IN) WHERE AccountNumber = AccountFrom_IN;
END;