I just asked a similar question to this, but that turned out to be because MySQL column names are case insenstive and I was creating an ambiguity. I took the advice given and prefixed all my params with p. The problem is that if I type the param value with a misspelling the SP still compiles, but then fails at run time. Is there something I can do about this?
Here is an example:
DELIMITER $$
USE `MobiFit_Dev` $$
DROP PROCEDURE IF EXISTS `User_Signup` $$
CREATE DEFINER = `root` @`localhost` PROCEDURE `User_Signup` (
pEmail VARCHAR (250),
pHashedPassword BINARY(60),
pFirstName VARCHAR (100),
pLastName VARCHAR (100),
pGender ENUM ('Male', 'Female'),
pDateOfBirth DATE,
pHeight DECIMAL (3, 2),
pCurrentWeight DECIMAL (4, 1)
-- CALL User_Signup('[email protected]', 'password', 'Lee', 'Brooks', NULL, NULL, NULL, NULL);
-- CALL User_Signup('[email protected]', 'password', 'Lee', 'Brooks', 'Male', CURRENT_DATE(), 1.85, 101.3);
)
BEGIN
DECLARE vRoleId INT;
SELECT
id INTO vRoleId
FROM
Role
WHERE `Code` = 'CUSTOMER' ;
INSERT INTO USER (
Email,
HashedPassword,
RoleId,
FirstName,
LastName,
Gender,
DateOfBirth,
Height,
CurrentWeight,
CreatedAt
)
VALUES
(
pEmail,
pHashedPassword,
vRoleId,
pFirstName,
pLastName,
pGender,
pDateOfBirth,
pHeight,
pCurrentWeigh, << Note the typo, this still compiles
UTC_TIMESTAMP()
) ;
END $$
DELIMITER ;