mysql存储过程中临时表的建立及游标遍历.doc
还剩
2页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,喜欢就下载吧,价低环保!
内容要点:
SELECT `returnCode` into RCode from `B` where `checkNO`=ScheckNO order by `operate` desc limit 0,1; INSERT INTO `tmp_paymentReport` set `id`=Sid,`phoneNumber`=SphoneNumber,`cutPaymentDate`=ScutPaymentDate,`money`=Smoney,`isCutPaymentSucceed`=SisCutPaymentSucceed,`checkNO`=ScheckNO,`ipAddress`=SipAddress,`returnCode`=RCode; FETCH NEXT FROM rs INTO Sid,SphoneNumber,ScutPaymentDate,Smoney,SisCutPaymentSucceed,ScheckNO,SipAddress; END IF; UNTIL Done END REPEAT; CLOSE rs; set @RunSQL = "select * from tmp_paymentReport"; prepare smtm from @RunSQL; execute smtm; END 调用方法是:call Jfind('2011-06-01 00:00:00','2011-07-01 00:00:00'); /*查询六月的记录*/CREATE DEFINER=`root`@`localhost` PROCEDURE `Jfind`(StartTime DateTime,EndTime DateTime) BEGIN DECLARE r int; DECLARE Done INT DEFAULT 0; DECLARE RCode int(3) DEFAULT 0; DECLARE Sid varchar(32); DECLARE SphoneNumber varchar(10); DECLARE ScutPaymentDate datetime; DECLARE Smoney double(10,2); DECLARE SisCutPaymentSucceed int(2); DECLARE ScheckNO varchar(32); DECLARE SipAddress varchar(20); /*建立游标*/ DECLARE rs CURSOR FOR SELECT * FROM A where cutPaymentDate> STR_TO_DATE(StartTime,'%Y-%m-%d %H:%i:%s') and cutPaymentDate
发表评论
暂无评论,赶快抢占沙发吧。