存储过程有执行,但是其中的一个更新语句没有执行,所以想打更新语句输出
DELIMITER $$DROP PROCEDURE IF EXISTS `test`.`UpdateOldrec` $$
CREATE DEFINER=`test`@`%` PROCEDURE `UpdateOldrec`(IN 1_cid int,IN 1_url char(250),IN 1_keywords char(250),IN 1_Title char(250),IN1_Contents char(250),IN 1_Other char(250),IN 1_Image char(250),IN 1_Category int)
BEGIN
DECLARE pid INT DEFAULT (select `Pid` From data_index where `Url`=1_url and `Cid`=1_cid);
DECLARE Str1 varchar(300) DEFAULT '';
IF pid>0 then
IF LENGTH(1_Title)> 0 THEN
UPDATE `data_contents` SET `Title` = 1_Title,`Contents` = 1_Contents ,`Other` = 1_Other ,`images` = 1_Image WHERE `Pid`= pid LIMIT 1 ;
END IF; SET @SqlCmd ="update data_index SET Edit_date = UNIX_TIMESTAMP()";
IF LENGTH(1_keywords) > 0 THEN SET @SqlCmd = CONCAT(@SqlCmd , ',Keywords = ?');
SET @a = 1_keywords;
SET @SqlCmd = CONCAT(@SqlCmd , ' WHERE Pid=?');
SET @b = pid;
PREPARE stmt from @SqlCmd;
EXECUTE stmt USING @a,@b;
ELSE
SET @SqlCmd = CONCAT(@SqlCmd , ' WHERE Pid=?');
SET @b = pid;
PREPARE stmt from @SqlCmd;
EXECUTE stmt USING @b;
END IF; END IF;END $$DELIMITER ;
DELIMITER $$DROP PROCEDURE IF EXISTS `test`.`UpdateOldrec` $$
CREATE DEFINER=`test`@`%` PROCEDURE `UpdateOldrec`(IN 1_cid int,IN 1_url char(250),IN 1_keywords char(250),IN 1_Title char(250),IN1_Contents char(250),IN 1_Other char(250),IN 1_Image char(250),IN 1_Category int)
BEGIN
DECLARE pid INT DEFAULT (select `Pid` From data_index where `Url`=1_url and `Cid`=1_cid);
DECLARE Str1 varchar(300) DEFAULT '';
IF pid>0 then
IF LENGTH(1_Title)> 0 THEN
UPDATE `data_contents` SET `Title` = 1_Title,`Contents` = 1_Contents ,`Other` = 1_Other ,`images` = 1_Image WHERE `Pid`= pid LIMIT 1 ;
END IF; SET @SqlCmd ="update data_index SET Edit_date = UNIX_TIMESTAMP()";
IF LENGTH(1_keywords) > 0 THEN SET @SqlCmd = CONCAT(@SqlCmd , ',Keywords = ?');
SET @a = 1_keywords;
SET @SqlCmd = CONCAT(@SqlCmd , ' WHERE Pid=?');
SET @b = pid;
PREPARE stmt from @SqlCmd;
EXECUTE stmt USING @a,@b;
ELSE
SET @SqlCmd = CONCAT(@SqlCmd , ' WHERE Pid=?');
SET @b = pid;
PREPARE stmt from @SqlCmd;
EXECUTE stmt USING @b;
END IF; END IF;END $$DELIMITER ;
解决方案 »
- 哪位大侠 给我个 mysql 里实现查询汉字的拼音首字母 能用的
- 我的MYSQL数据库查询很慢,不知道怎么优化,环境是 LIUUX 企业版 5。0 + 没有宋庆龄5。1。23 下面是我是我show的结果,谢谢高手指点
- 如何在触发器中更新同一个表中的其它记录?
- 存储过程问题
- 为什么在 .class 的执行文件里可用, 在 jsp 里却不能用?????????
- 请问怎样在 mysql -u root -p 命令行直接写password,而不要等提示输入密码再输入
- Mysql和Postgre哪个好些?
- 如何优化mysql win32/win2000?
- MYSQL安装最后一不execution后就没反应了
- 删除1.7W条数据要30S-60S如何优化?
- 问个SQL语句..
- 关于mysql Connector的问题
Query OK, 0 rows affected (0.00 sec)mysql> select @sql;
+--------------------+
| @sql |
+--------------------+
| select * from tbl1 |
+--------------------+
1 row in set (0.00 sec)mysql>
mysql> CREATE PROCEDURE `UpdateOldrec`(
-> BEGIN
-> declare pid int;
-> set pid=100;
-> select pid;
-> set pid=pid+10;
->
-> end;
-> //
Query OK, 0 rows affected (0.22 sec)mysql> delimiter ;
mysql> call UpdateOldrec();
+------+
| pid |
+------+
| 100 |
+------+
1 row in set (0.00 sec)Query OK, 0 rows affected (0.00 sec)mysql>