- 论坛徽章:
- 0
|
mysql版本:mysql-5.1.28-rc
txtInfo传入的是一个像'update `tmp` set `user`="xxx",`url`="url" where `id`=1'的SQL
过程创建成功后发现更新不成功
后来改为传入`user`="xxx",`url`="url"并将sp_update作相应的修改后仍然不能正确执行
SHELL下执行
CALL sp_update( 23, 'update `data` set `user`="xxx",`url`="url" where `id`=3' )
返回
#1312 - PROCEDURE test.sp_update can't return a result set in the given context
想问问这种方式可行不?如果不行有没有可行的替换方法呢?
DROP PROCEDURE IF EXISTS sp_update;
DELIMITER $$
CREATE PROCEDURE sp_update (IN id MEDIUMINT UNSIGNED, IN txtInfo VARCHAR(255))
BEGIN
SET @x = txtInfo;
PREPARE s FROM @x;
EXECUTE s;
DEALLOCATE PREPARE s;
SET @x = null;
INSERT INTO `data` (`user`,`pass`,`url`,`swurl`) SELECT `user`,`pass`,`url`,`swurl` FROM `tmp` WHERE `id`=id;
DELETE FROM `tmp` WHERE `id`=id;
END;
$$
DELIMITER ; |
|