Mysql 命令行下建立存储过程
CREATE PROCEDURE proc_variable ()BEGINDECLARE dec_var_ VARCHAR(100);DECLARE rep_num INT;DECLARE dec_var CURSOR for SELECT ID_ FROM ACT_RU_VARIABLE WHERE NAME_ = ‘yjdqsj‘ GROUP BY EXECUTION_ID_ HAVING COUNT(NAME_) >1;OPEN dec_var;REPEATFETCH dec_var INTO dec_var_;DELETE FROM ACT_RU_VARIABLE WHERE ID_ = dec_var_;UNTIL rep_num END REPEAT;CLOSE dec_var;end;
mysql(root@localhost:jjsworkflow)>delimiter // #修改命令终止符为//(random)mysql(root@localhost:jjsworkflow)>CREATE PROCEDURE proc_variable ()-> BEGIN-> DECLARE dec_var_ VARCHAR(100);-> DECLARE rep_num INT;-> DECLARE dec_var CURSOR for SELECT ID_ FROM ACT_RU_VARIABLE WHERE NAME_ = ‘yjdqsj‘ GROUP BY EXECUTION_ID_ HAVING COUNT(NAME_) >1;-> OPEN dec_var;-> REPEAT-> FETCH dec_var INTO dec_var_;-> DELETE FROM ACT_RU_VARIABLE WHERE ID_ = dec_var_;-> UNTIL rep_num END REPEAT;-> CLOSE dec_var;-> end;-> // ##语句最后需要已上面声明的//结尾enter才能被执行
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。