Home  >  Article  >  Database  >  mysql存储过程的参数名不要跟字段名一样_MySQL

mysql存储过程的参数名不要跟字段名一样_MySQL

WBOY
WBOYOriginal
2016-06-01 13:31:501088browse

bitsCN.com

mysql存储过程的参数名不要跟字段名一样

 

如题,将会导致的结果就是参数的值将不会是你传入的值,而是变成每条记录的那个字段的值。

这样的后果,是灰常严重的。比如执行删除操作,它能把整个表的记录全删了。

这个是我的血淋淋的代价啊。

 

死坑如下,勿跳:

[sql]DELIMITER $$    USE `b10k`$$    DROP PROCEDURE IF EXISTS `sp_delete_species`$$    CREATE DEFINER=`luth`@`%` PROCEDURE `sp_delete_species`(      IN  species_id  INT,        /*物种ID*/      OUT     out_rows        INT         /*受影响行数*/      )  BEGIN      DELETE FROM `sample` WHERE `species_ID` = species_id ;      DELETE FROM `filepath` WHERE `species_ID` = species_id ;      DELETE FROM `species` WHERE `species_ID` = species_id ;      SET out_rows = ROW_COUNT();      END$$    DELIMITER ;  

 

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn