문제

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('lee@gmail.com', 'password', 'Lee', 'Brooks', NULL, NULL, NULL, NULL);
    -- CALL User_Signup('lee@gmail.com', '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 ;

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top