我正在尝试根据选择查询结果将记录插入到一个表中。
当我执行查询时,我明显能够看到该记录需要按预期插入到表中。
但不知怎的,它没有插入记录所以想知道,我想念的内容
代码段:
NetworkCredential aCredentials = new NetworkCredential();
aCredentials.Domain = "";
aCredentials.UserName = "";
aCredentials.Password = "";
WebProxy aProxy = new WebProxy();
aProxy.Address = new Uri("http://proxyserver.com:8080");
aProxy.Credentials = aCredentials;
client.Proxy = aProxy;
选择查询的输出:
CREATE EVENT event_1 ON SCHEDULE EVERY 60 SECOND DO
BEGIN
DECLARE lc_current_time DATETIME;
DECLARE unuse_count INT;
DECLARE assign TINYINT;
DECLARE total_sum INT;
DECLARE check_count INT;
DECLARE select_cursor CURSOR FOR SELECT count(id) as count,A.assign, B.sum, truncate(B.sum*100.00/100,0) as check_count FROM table1 A INNER JOIN (Select assign, count(id) sum from table1 where cli_group_id = 5 Group by assign) B on A.assign = B.assign WHERE cli_group_id = 5 and field1 ='' Group by field1, A.assign;
SET lc_current_time = CONVERT_TZ(NOW(), @@session.time_zone, '+0:00');
OPEN select_cursor;
LOOP
FETCH select_cursor INTO unuse_count,assign,total_sum,check_count;
IF unuse_count <= check_count THEN
insert into report(triggered_date,alert_id,alert_name,type,status,email,trunk_cli_id,triggered_value,threshold_value) values (lc_current_time,19,'CLI',4,1,'abc@test.com',5,check_count,unuse_count);
END IF;
END LOOP;
CLOSE select_cursor;
END
问题:
从输出中我们可以清楚地看到+-------+-------------+-----+-------------+
| count | assign | sum | check_count |
+-------+-------------+-----+-------------+
| 8 | 0 | 11 | 11 |
| 2 | 1 | 3 | 3 |
+-------+-------------+-----+-------------+
2 rows in set (0.00 sec)
所以记录必须在报告表中插入一个条目。