I\'m trying to do some simple manipulations with variables in MySQL 5.0 but I can\'t quite get it to work. I\'ve seen many (very!) different syntaxen for DECLARE/SET, I\'m not
This works fine for me using MySQL 5.1.35:
DELIMITER $$
DROP PROCEDURE IF EXISTS `example`.`test` $$
CREATE PROCEDURE `example`.`test` ()
BEGIN
DECLARE FOO varchar(7);
DECLARE oldFOO varchar(7);
SET FOO = '138';
SET oldFOO = CONCAT('0', FOO);
update mypermits
set person = FOO
where person = oldFOO;
END $$
DELIMITER ;
Table:
DROP TABLE IF EXISTS `example`.`mypermits`;
CREATE TABLE `example`.`mypermits` (
`person` varchar(7) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO mypermits VALUES ('0138');
CALL test()