What is wrong with the code for this MySQL stored procedure?

DELIMITER $$

DROP PROCEDURE IF EXISTS `departments`.`emp_raise2` $$

CREATE PROCEDURE `departments`.`emp_raise2` (input_number INT(4))

BEGIN

DECLARE p_new_sal decimal(7,2);

DECLARE p_empno int(4);

SET p_empno = input_number;

DECLARE p_sal decimal(7.2);

DECLARE p_ename varchar(10);

/*SELECT from the database into the variables*/

SELECT sal, sal*1.1, ename

INTO p_sal, p_new_sal, p_ename

FROM emp

WHERE empno = p_empno;

/*Show results to screen*/

select p_empno ‘Emp Number’,p_ename ‘Emp Name’, p_sal ‘Old Salary’,

p_new_sal ‘New Salary’;

END $$

DELIMITER ;

Update:

that is formatting not a number 7 places, 2 behind the decimal. (7,2) did I do that wrong?

1 Answer

? Favorite Answer

  • I believe the problem exists because of a typo.

    Look at this:

    DECLARE p_new_sal decimal(7,2);

    Do decimals usually contain commas?

    =]

    Good Luck!

    If you need further assistance/advice, feel free to contact me.

  • Leave a Comment