mysql 存储过程 compile_mysql 存储过程

CREATE PROCEDURE sample_report_page

(

in Nos VARCHAR(100)

,IN suffix VARCHAR(100)

,IN check_category VARCHAR(100)

,IN manufacturer VARCHAR(200)

,in client_name VARCHAR(200)

,in namestrVARCHAR(100)

,in processTINYINT #boolean 值

,in companyid INT

,in isauditorTINYINT #boolean 值

,INisapproverTINYINT #boolean 值

,in PageIndexINT

,in PageSizeINT

,OUT TotalRecords INT

)

begin

set @startRow = PageIndex * PageSize;

set @pageSize = PageSize;

set @Nos=Nos;

set @suffix=suffix;

set @check_category=check_category;

set @manufacturer=manufacturer;

set @client_name=client_name;

set @namestr=namestr;

set @process=process;

set @companyid=companyid;

set @isauditor=isauditor;

set @isapprover=isapprover;

set @strsql = concat(

'select sql_calc_found_rows * from sample_report_view '

,' where '

);

set @strsql=concat(@strsql,CASE IFNULL(@Nos, '') WHEN '' THEN ' Nos=Nos and ' ELSE CONCAT(' Nos=''', @Nos, ''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@suffix, '') WHEN '' THEN ' suffix=suffix and' ELSE CONCAT(' suffix=''', @suffix, ''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@check_category, '') WHEN '' THEN ' check_category=check_category and ' ELSE CONCAT(' check_category=''', @check_category, ''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@manufacturer, '') WHEN '' THEN ' manufacturer=manufacturer and' ELSE CONCAT(' manufacturer=''', @manufacturer, ''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@client_name, '') WHEN '' THEN ' client_name=client_name and ' ELSE CONCAT(' client_name=''', @client_name, ''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@namestr, '')WHEN '' THEN ' name=name and ' ELSE CONCAT(' name=''', @namestr,''' and ') END);

set @strsql=concat(@strsql,CASE IFNULL(@process, '')WHEN '' THEN ' process=process and ' ELSE CONCAT(' process=',@process,' and ') END);

set @strsql=concat(@strsql,CASE @companyidWHEN 0 THEN ' companyid=companyid ' ELSE CONCAT(' companyid=',@companyid,' ') END);

set @strsql=concat(@strsql,CASE IFNULL(@isauditor,'')WHEN '' THEN ' ' WHEN 1 THEN ' and auditor_date IS NOT NULL ' ELSE ' and auditor_date IS NULL ' END);#时间列 auditor_date=auditor_date 这样是查不到数据的

set @strsql=concat(@strsql,CASE IFNULL(@isapprover,'')WHEN '' THEN ' ' WHEN 1 THEN ' and approver_date IS NOT NULL ' ELSE CONCAT(' and approver_date IS NULL') END);

set @strsql=concat(@strsql,' order by id desc ');

set @strsql=concat(@strsql,' limit ?,?; ');

prepare PageSql from @strsql;

execute PageSql using @startRow, @pageSize;

deallocate prepare PageSql;

set TotalRecords = found_rows();

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值