简体   繁体   中英

MySQL stored procedure ignores DELETE statement

I have this stored procedure which gets called from PHP Script. It has few select statement and a delete statement. Everything works fine apart from DELETE query does not get executed. It gets ignored !! Please help. Thanks

CREATE PROCEDURE `proc_name`(IN id INT, IN type CHAR(50))
DETERMINISTIC
COMMENT 'procedure'
BEGIN 
DECLARE LEGACY_EN_ID INT;
SET IN_ID = id;
SELECT  IF(e.legacy_id > 0, e.legacy_id, 0) INTO LEGACY_EN_ID FROM tablename e WHERE e.id = IN_ID LIMIT 1;

/* Delete record if it exists */
        DELETE
        FROM tablename
        WHERE entityID = LEGACY_EN_ID;
  1. Check user who executes stored procedure have permission to do that.
  2. This can be checked by directing connecting through mysql command line with same user and try to execute query which generated in stored procedure.
  3. Or create a simple PHP script and call directly delete sql using mysql_query. If this success then you have access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM