The following is my process. What I don't understand is that when I use any column in the cursor as a condition to judge the end of the cursor, it will be blank at any time, but it can actually be completed in a loop, think twice about it. For example, WHILE (TYPEISNOTNULL ). The type here is always null. If I use any column, event_value is also null as the while condition event_value. I beg you to answer this question. DELIMITER $ CREATEPROCEDUREtest (INevent_value_nameVARCHAR (20), IN... mysql proceduremysqlmysql serious problem mysql event 
 
 
 The following is my process. What I don't understand is that when I use any column in the cursor as a condition to judge the end of the cursor, it will be blank at any time, but it can actually be completed in a loop, think twice about it.
For example, WHILE (type is not null ). The type here is always null.
If I use any column, event_value is also null as the while condition event_value.
I beg you to answer this question.
DELIMITER $
Create procedure test (IN event_value_name VARCHAR (20), IN datestr VARCHAR (20), IN start_date DATETIME, IN end_date DATETIME)
BEGIN
DECLARE temp VARCHAR (10) DEFAULT "";
DECLARE temps VARCHAR (200) DEFAULT "";
DECLARE report_tim VARCHAR (100) DEFAULT "";
Declare type varchar (50 );
DECLARE event_value VARCHAR (50 );
DECLARE source VARCHAR (50 );
DECLARE event_name VARCHAR (50 );
Declare cot varchar (50 );
DECLARE allrow cursor for select tev. event_value, tev. source, tev. event_name, COUNT (*) as cot, tev. type, DATE_FORMAT (tev. report_time, '% Y-% m-% d') report_tim FROM ts_event_value tev
WHERE tev. name = event_value_name AND tev. report_time BETWEEN start_date AND end_date
Group by tev. event_value, tev. source, tev. event_name, tev. type, report_tim order by cot desc limit 15;
Declare continue handler for not found set type = NULL;
OPEN allrow;
/* Allrowloop: LOOP */
FETCH allrow INTO event_value, source, event_name, COT, TYPE, report_tim;
IF datestr = "all" THEN
 
         WHILE ( TYPE IS NOT NULL ) DO            SELECT s.name INTO temp FROM statistical s WHERE s.name = event_value_name AND s.source = source AND s.event_name = event_name AND s.event_value = event_value AND s.zt = "all";                IF temp = "" OR temp IS NULL THEN                    INSERT INTO statistical VALUES (source,event_name,event_value,COT,event_value_name,report_tim,"all");                ELSE                    UPDATE statistical s SET s.cot = s.cot + COT WHERE s.name = event_value_name AND s.source = source AND s.event_name = event_name AND s.event_value = event_value AND s.zt = "all";                END IF;            FETCH allrow INTO event_value,source,event_name,COT,TYPE,report_tim;        END WHILE;    END IF;     COMMIT;    SELECT event_value,source,event_name,COT,temp;    /*SELECT temps;*/    /*END LOOP allrowloop;*/CLOSE allrow;
 
 END;
$
DELIMITER;