本文共 1526 字,大约阅读时间需要 5 分钟。
BEGIN
DECLARE Done INT DEFAULT 0;
DECLARE exdate datetime;
DECLARE textdata text;
DECLARE m_time datetime;
DECLARE b_num varchar(20);
DECLARE telwq varchar(20);
DECLARE telhb varchar(20);
DECLARE telsj varchar(20);
DECLARE cc int;
DECLARE rs CURSOR FOR SELECT
a.F25 AS b_num,
b.F11 AS m_time
FROM S62.T6230 AS a,S62.T6231 as b
WHERE a.F01=b.F01 AND b.F11 BETWEEN DATE_SUB(NOW(),INTERVAL 30 minute) AND NOW();
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1;
SET telwq=13760836670;
SET telhb=15920149039;
SET telsj=13808870034;
SET exdate = (SELECT DATE_ADD(NOW(),INTERVAL 30 minute));
IF (SELECT COUNT(a.F01) FROM S62.T6230 AS a,S62.T6231 as b WHERE a.F01=b.F01 AND b.F11 BETWEEN DATE_SUB(NOW(),INTERVAL 30 minute) AND NOW()) > 0
THEN
OPEN rs;
FETCH NEXT FROM rs INTO b_num,m_time;
REPEAT
SET textdata = (SELECT CONCAT('标编号为"',b_num,'"的标已于"',m_time,'"满标,请登录后台进行放款操作。'));
-- WQ
INSERT INTO
S10._1040 (F02,F03,F04,F05,F06)
VALUES (0,textdata,NOW(),'W',exdate);
SET cc =(SELECT @@IDENTITY);
INSERT INTO
S10._1041 (F01,F02)
VALUES (cc,telwq);
-- HB
INSERT INTO
S10._1040 (F02,F03,F04,F05,F06)
VALUES (0,textdata,NOW(),'W',exdate);
SET cc =(SELECT @@IDENTITY);
INSERT INTO
S10._1041 (F01,F02)
VALUES (cc,telhb);
-- SJ
INSERT INTO
S10._1040 (F02,F03,F04,F05,F06)
VALUES (0,textdata,NOW(),'W',exdate);
SET cc =(SELECT @@IDENTITY);
INSERT INTO
S10._1041 (F01,F02)
VALUES (cc,telsj);
FETCH NEXT FROM rs INTO b_num,m_time;
UNTIL Done END REPEAT;
CLOSE rs;
END IF;
END
转载于:https://www.cnblogs.com/tangbinghaochi/p/6292962.html