Mysql Procudure

DELIMITER $$
DROP PROCEDURE IF EXISTS `auo`.`TTT` $$CREATE DEFINER=`root`@`localhost` PROCEDURE `TTT`(OUT RESULT INT,IN CC VARCHAR(20))BEGINDECLARE l_last_row_fetched int;DECLARE COUNTRYT VARCHAR(20);DECLARE GUIDT INT;#DECLARE RESULT INT;#set RESULT = 0;#SELECT INTO RESULT = 0;
#OPEN TT;DECLARE TT CURSOR FOR SELECT GUID,COUNTRY FROM helloworld;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET l_last_row_fetched=1;SET l_last_row_fetched=0;set RESULT = 0;OPEN TT;
cursor_loop:while l_last_row_fetched = 0 do  FETCH TT INTO GUIDT,COUNTRYT;  IF l_last_row_fetched=1 THEN     #IF l_last_row_fetched=1 THEN    set RESULT = GUIDT;    LEAVE cursor_loop;  END IF;  UPDATE helloworld SET city=CC WHERE GUID = GUIDT;  set RESULT = GUIDT;END while cursor_loop;CLOSE TT;SET l_last_row_fetched=0;#commit;END $$
DELIMITER ;

你可能感兴趣的:(mysql)