I am trying to execute select query manually in database console then it gives me result.But when i am using same select query with in procedure then its not working.
ERROR :
ERROR 1329 (02000): No data - zero rows fetched, selected, or processed
Code :
DELIMITER $$
DROP PROCEDURE IF EXISTS abc_19;
CREATE PROCEDURE abc_19()
BEGIN
DECLARE lc_current_time DATETIME;
DECLARE lc_calc_value INT;
DECLARE auto_assign TINYINT;
DECLARE total_sum INT;
DECLARE check_count INT;
BEGIN
DECLARE select_cursor CURSOR FOR SELECT count(id) as count,A.auto_assign, B.sum, truncate(B.sum*100.00/100,0) as check_count FROM cli_group_number A INNER JOIN (Select auto_assign, count(id) sum from cli_group_number where cli_group_id = 5 Group by auto_assign) B on A.auto_assign = B.auto_assign WHERE cli_group_id = 5 and sip_from_uri ='' Group by sip_from_uri, A.auto_assign;
SET lc_current_time = CONVERT_TZ(NOW(), @@session.time_zone, '+0:00');
OPEN select_cursor;
LOOP
FETCH select_cursor INTO lc_calc_value,auto_assign,total_sum,check_count;
IF lc_calc_value <= check_count THEN
insert into report(current_date,alert_id,alert_name,type,status,email,trunk_cli_id,triggered_value,threshold_value) values (lc_current_time,19,'CLI',4,1,'[email protected]',5,check_count,lc_calc_value);
INSERT INTO mails (`userid`,`date`,`subject`,`body`,`from`,`to`,`status`,`parent_id`) VALUES (1,lc_current_time,'Alarm : CLI',concat('Hello Admin,
Name : abc,
Type : def,
Threshold : 100.00
Period : 60
Group : test
Value : ',lc_calc_value),'[email protected]','[email protected]',1,0);
END IF;
END LOOP;
CLOSE select_cursor;
END;
END$$
DELIMITER ;