当前位置:首页 > 开发 > 数据库 > 正文

mysql存储过程,有输入输出的

发表于: 2013-04-18   作者:商人shang   来源:转载   浏览:
摘要: DELIMITER //; CREATE PROCEDURE queryTotalNum(OUT totalNum INT , IN tableName varchar(40), IN conditions varchar(300)) begin declare stmt varchar(2000); declare num int; if L
DELIMITER //;

CREATE  PROCEDURE queryTotalNum(OUT totalNum INT , IN tableName varchar(40), IN conditions varchar(300))
begin    
    declare stmt varchar(2000);   
    declare num int;
    if LENGTH(conditions)>1 then  
	begin
		set @sqlstr=concat('SELECT COUNT(*) INTO @num from ',tableName,' where ',conditions);
	end;
	else
	begin
		 set @sqlstr=concat('SELECT COUNT(*) INTO @num from ',tableName);
	end;
    end if;  
    prepare stmt from @sqlstr;    
    execute stmt;  
    deallocate prepare stmt;
    set totalNum = @num;

    end;

 

mysql存储过程,有输入输出的

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号