2

我有一个SP:

DELIMITER $$
CREATE PROCEDURE test_ind(in StudentID varchar(4), in issueYear varchar(4))
BEGIN 
delete from Mark where StudentID = StudentID and issueYear = issueYear;
END $$
DELIMITER ;

当我调用这个 SP 时:call test_ind('8','2011')

它必须删除 studentID = 8 但它删除了表中的所有行。

这个查询有什么问题?
请问你能帮帮我吗!

4

1 回答 1

5

存储过程发生名称冲突,因为参数的名称与列的名称完全相同。

更改参数名称,它将起作用,

DELIMITER $$
CREATE PROCEDURE test_ind(IN _StudentID VARCHAR(4), IN _issueYear VARCHAR(4))
BEGIN 
    DELETE FROM Mark 
    WHERE  StudentID = _StudentID AND 
           issueYear = _issueYear;
END $$
DELIMITER ;
于 2013-05-07T07:14:47.380 回答