事件调度程序:无数据 - 获取,选择或处理零行?

时间:2012-10-04 05:29:05

标签: mysql stored-procedures

  • MySQL 5.5.28

错误日志不断出现此错误:

121004 12:08:59 [ERROR] Event Scheduler: [user@ip][reportingdb.tvc_bookingonline_update_status] No data - zero r
ows fetched, selected, or processed 
121004 12:13:59 [ERROR] Event Scheduler: [user@ip][reportingdb.tvc_bookingonline_update_status] No data - zero r
ows fetched, selected, or processed 
121004 12:18:59 [ERROR] Event Scheduler: [user@ip][reportingdb.tvc_bookingonline_update_status] No data - zero r
ows fetched, selected, or processed 

定义:

mysql> show create event reportingdb.tvc_bookingonline_update_status\G
*************************** 1. row ***************************
               Event: tvc_bookingonline_update_status
            sql_mode: NO_AUTO_CREATE_USER
           time_zone: SYSTEM
        Create Event: CREATE DEFINER=`user`@`ip` EVENT `tvc_bookingonline_update_status` ON SCHEDULE EVERY 5 MINUTE STARTS '2012-07-27 10:08:59' ON COMPLETION NOT PRESERVE ENABLE DO CALL `bo_tvc_booking_supdate_status_booking`( @plstbookingid_destroy)
character_set_client: latin1
collation_connection: latin1_swedish_ci
  Database Collation: utf8_general_ci

mysql> show create procedure reportingdb.bo_tvc_booking_supdate_status_booking\G
*************************** 1. row ***************************
           Procedure: bo_tvc_booking_supdate_status_booking
            sql_mode: 
    Create Procedure: CREATE DEFINER=`user`@`ip` PROCEDURE `bo_tvc_booking_supdate_status_booking`(
        OUT plstbookingid_destroy VARCHAR(1500)
    )
    DETERMINISTIC
BEGIN
    DECLARE  no_found_row INT DEFAULT 0;
    DECLARE _idbooking INT;
    DECLARE _status INT;
    DECLARE _no_contract VARCHAR(25);
    DECLARE _fromdate DATE;
    DECLARE _todate DATE;
    DECLARE _flagsync SMALLINT DEFAULT 0;
    DECLARE _ROWSCOUNT INT DEFAULT 0;
    DECLARE _lstBookDestroy VARCHAR(500);
    DECLARE _lstBookRunning VARCHAR(500);
    DECLARE _lstBookFinish VARCHAR(500);
    #LAY DU LIEU BOOKING
    DECLARE  cur_row CURSOR FOR
        SELECT B.`idbooking`, B.`status`, B.`no_contract`, B.`fromdate`, B.`todate` 
        FROM `tvc_bookings` B       
        WHERE B.`status` IN (1, 2, 3);

    DECLARE EXIT HANDLER FOR SQLEXCEPTION  SET @error=1;
    DECLARE  CONTINUE HANDLER FOR NOT FOUND SET  no_found_row = 1;
    SELECT COUNT(*) INTO _ROWSCOUNT 
    FROM `tvc_bookings` B       
    WHERE B.`status` IN (1, 2, 3);
    IF(_ROWSCOUNT > 0) THEN
            SET AUTOCOMMIT=0;
        #BAT DAU DUYET TUNG BOOKING
        SET plstbookingid_destroy = '';
        SET _lstBookDestroy = 'List bookid destroy: ';
        SET _lstBookRunning = 'List bookid running: ';
        SET _lstBookFinish = 'List bookid finish: ';
        OPEN cur_row;
        FETCH cur_row INTO _idbooking, _status, _no_contract, _fromdate, _todate;
        WHILE no_found_row = 0 DO 
            #KIEM TRA RULE
            IF(_status = 1) THEN
                #IF((_no_contract IS NULL OR _no_contract = '') AND DATEDIFF(_fromdate, CURDATE()) <= 3) THEN
                #MODIFY DEN HET NGAY MOI HUY BOOKING
                #IF((_no_contract IS NULL OR _no_contract = '') AND DATEDIFF(CURDATE(), _fromdate) = 1) THEN#YEU CAU NEW NGAY CHAY = NOW
                IF((_no_contract IS NULL OR _no_contract = '') AND DATEDIFF(CURDATE(), _fromdate) > 0) THEN#YEU CAU NEW NGAY CHAY = NOW
                    CALL `bo_tvc_create_version_booking`( _idbooking, 'Services store huy booking den ngay chay ma chua co HD', 'Services');
                    UPDATE `tvc_bookings`  
                    SET `status` = 4,  
                        `modifiedby` = 'SERVICES',
                        `modifieddate` = CURRENT_TIMESTAMP()
                    WHERE `idbooking` = _idbooking;             
                    #OUT INFO
                    SET _lstBookDestroy = CONCAT(_lstBookDestroy, _idbooking, ',');
                END IF;       
            END IF;#IF(_status = 1)

            IF(_status = 2 AND _no_contract != '') THEN
                IF(_fromdate <= CURDATE()) THEN
                    #CHECK TABLE
                    /*
                    SELECT COUNT(*) INTO _flagsync
                    FROM `bo_tvc_sync_hdcn_thucchay` A
                    WHERE A.`booking_id` = _idbooking AND A.`updated` = 1;
                    */
                    SET _flagsync = 1;#FIX CODE CONNECT HDCN SOON

                    IF(_flagsync > 0) THEN
                        CALL `bo_tvc_create_version_booking`( _idbooking, 'Services store chuyen trang thai hop dong thanh running', 'Services');
                        UPDATE `tvc_bookings`  
                        SET `status` = 3,  
                            `modifiedby` = 'SERVICES',
                            `modifieddate` = CURRENT_TIMESTAMP()
                        WHERE `idbooking` = _idbooking;                             

                        #UPDATE FLAG DA CHUYEN                            
                        UPDATE `bo_tvc_sync_hdcn_thucchay`  
                        SET `updated` = 2
                        WHERE `booking_id` = _idbooking AND `updated` = 1;

                        SET _lstBookRunning = CONCAT(_lstBookRunning, _idbooking, ',');
                    END IF;    
                END IF;

                IF(DATE_ADD(_todate, INTERVAL 1 DAY) <= CURDATE()) THEN
                    CALL `bo_tvc_create_version_booking`( _idbooking, 'Huy book vi het ngay chay ma ko co thuc chay ben hdcn', 'Services');
                    UPDATE `tvc_bookings`  
                    SET `status` = 4,  
                        `modifiedby` = 'SERVICES',
                        `modifieddate` = CURRENT_TIMESTAMP()
                    WHERE `idbooking` = _idbooking;                             

                    #OUT INFO
                    SET _lstBookFinish = CONCAT(_lstBookFinish, _idbooking, ',');
                END IF;
            END IF;#IF(_status = 2 AND _no_contract != '') THEN

            #UPDATE CAC BOOKING DA CHAY XONG
            IF(_status = 3 AND DATE_ADD(_todate, INTERVAL 1 DAY) <= CURDATE()) THEN
                CALL `bo_tvc_create_version_booking`( _idbooking, 'Services store chuyen chuyen booking thanh chay ket thuc', 'Services');
                UPDATE `tvc_bookings`  
                SET `status` = 5,  
                    `modifiedby` = 'SERVICES',
                    `modifieddate` = CURRENT_TIMESTAMP()
                WHERE `idbooking` = _idbooking;                        
                SET _lstBookFinish = CONCAT(_lstBookFinish, _idbooking, ',');
            END IF;#IF(_status = 3 AND DATE_ADD(_todate, INTERVAL 1 DAY) <= CURDATE())
        FETCH cur_row INTO _idbooking, _status, _no_contract, _fromdate, _todate;
        END WHILE;
        CLOSE cur_row;

        #OUT INFO TO SERVICES
        SET plstbookingid_destroy = CONCAT(_lstBookDestroy, '\r\n', _lstBookRunning, '\r\n', _lstBookFinish);
    END IF;
    COMMIT;
END
character_set_client: latin1
collation_connection: latin1_swedish_ci
  Database Collation: utf8_general_ci

我该怎么做才能摆脱这个错误?

1 个答案:

答案 0 :(得分:1)

对此here进行了不错的讨论,包括有关其他调试和解决方法的信息。