Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72250
  • 博文数量: 42
  • 博客积分: 2025
  • 博客等级: 大尉
  • 技术积分: 437
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-03 12:17
文章分类

全部博文(42)

文章存档

2010年(12)

2009年(30)

我的朋友

分类:

2009-11-26 15:39:17

kind_pro

DELIMITER $$

 

DROP PROCEDURE IF EXISTS `studb`.`kind_pro` $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `kind_pro`(in kindtype varchar(10))

BEGIN

  select kind_id,kind_name from kind where kind_type = kindtype;

END $$

 

DELIMITER ;

 

GetRecordCount

DELIMITER $$

 

DROP PROCEDURE IF EXISTS `studb`.`GetRecordCount` $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `GetRecordCount`(in tbName varchar(800),in strWhere varchar(500))

BEGIN

  set @strSQL=concat('select count(*) as countStr from ',tbName,strWhere);

 

  prepare sqlstmt from @strSQL;

 

  execute sqlstmt;

 

  deallocate prepare sqlstmt;

 

END $$

 

DELIMITER ;

 

GetRecordAsPage

DELIMITER $$

 

DROP PROCEDURE IF EXISTS `studb`.`GetRecordAsPage` $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `GetRecordAsPage`(in tbName varchar(800),in fldName varchar(1000),

in strWhere varchar(500),in pageIndex int,in pageSize int,in orderType int,in sortName varchar(50))

BEGIN

     declare startRow int;

 

     declare sqlStr varchar(1000);

 

     declare limitTemp varchar(1000);

 

     declare orderTemp varchar(1000);

 

     set startRow = (pageIndex-1)*pageSize;

 

     set sqlStr = CONCAT('SELECT ',fldName,' from ',tbName);

 

     set limitTemp = CONCAT(' limit ',startRow,',',pageSize);

 

     set orderTemp = CONCAT(' order by ',sortName);

 

     if orderType = 0 then

 

         set orderTemp = CONCAT(orderTemp,' ASC ');

 

     else

 

         set orderTemp = CONCAT(orderTemp,' DESC ');

 

     end if;

 

     set @sqlString = CONCAT(sqlStr,' ',strWhere,orderTemp,limitTemp);

 

     prepare sqlstmt from @sqlString;

 

     execute sqlstmt;

 

     deallocate prepare sqlstmt;

 

END $$

 

DELIMITER ;

 

阅读(299) | 评论(0) | 转发(0) |
0

上一篇:页面返回

下一篇:树TreeView

给主人留下些什么吧!~~