2017-06-28 5 views
0

Unten Prozedurcode läuft ohne Fehler. Zeile Wählen Sie FOUND_ROWS() aus. Reihen aber Cursor curs tat nicht Schleife alle ZeilenMysql Store-Prozedur stoppt Iteration nach einigen Zeilen

CREATE DEFINER=`root`@`%` PROCEDURE `middleLocationAutoUpdatePorc`() 
    BEGIN 
    declare vname varchar(45); 
    declare vmobile varchar(20); 
    declare vsapid varchar(6); 
    declare vuser varchar(45); 
    declare vday date; 
    declare vmintime time; 
    declare vmaxtime time; 
    declare vminLocation mediumtext; 
    declare vmaxLocation mediumtext; 
    declare vmiddlelocation mediumtext; 
    declare vdistance int(11); 
    declare vdrdid int(11); 
    declare vn_no_details int(11); 
    declare uatt   varchar(45) default 'X'; 
    declare adatta   varchar(45) default 'X'; 
    declare b_not_found  BOOL DEFAULT FALSE; 
    declare curs CURSOR FOR 
      SELECT user ,day, mintime,maxtime_mobile,minLocation,maxLocation,distance,n_no_details,drdid FROM mydb.statusreport where day >= '2017-06-26'; 

     DECLARE CONTINUE HANDLER FOR NOT FOUND SET b_not_found = true; 

     OPEN curs; 
     loop1: LOOP 
      FETCH curs INTO vuser,vday,vmintime,vmaxtime,vminLocation,vmaxLocation,vdistance,vn_no_details,vdrdid; 
      IF b_not_found THEN 
       LEAVE loop1; 
      END IF; 
    -- select FOUND_ROWS(); 
     case substring_index(vuser,"-",-1) 
     when 'RSM' then 

     select username,Name,mobile into vsapid,vname,vmobile from mydb.supervisor where idSu=CONVERT(substring_index(vuser,"-",1),UNSIGNED INTEGER); 
     when 'ASM' then 
      select userName,name,mobile into vsapid,vname,vmobile from mydb.executive where exeid=CONVERT(substring_index(vuser,"-",1),UNSIGNED INTEGER); 
     when 'F' then 
      select sapId,name,phone into vsapid,vname,vmobile from mydb.user where idUser=CONVERT(substring_index(vuser,"-",1),UNSIGNED INTEGER); 
     end case; 

     select userGiven , adminGiven into uatt ,adatta from userdaystatus st where st.date =vday and st.idUser=CONVERT(substring_index(vuser,"-",1),UNSIGNED INTEGER) and st.userType=substring_index(vuser,"-",-1); 
     set vmiddlelocation=(select location from mydb.dailyReportDetails as dtb where dtb.idDailyReport=vdrdid and dtb.counter>=(abs(vn_no_details/2)) order by dtb.idDailyReportDetails asc limit 1); 


     call mydb.addOMiddleLocation(day(vday), month(vday), 
              year(vday),vuser, vname, 
              vsapid, vmobile, vmintime, 
              vmaxtime, SUBTIME(vmaxtime,vmintime), 
              vminLocation, 
              vmiddlelocation, 
              vmaxLocation,Round(vdistance/1000,2), 
              uatt, adatta); 

       END LOOP; 
    CLOSE curs; 
    END 

mydb.addOMiddleLocation Der Prozeduraufruf() auf einem anderen table.There beliebigen Datentyp Validierung muss nicht nur das Einfügen Row. Was kann das Problem sein?

Antwort

0

Es kommt für die Log-Wartezeit für eine bestimmte Abfrageleitung

set vmiddlelocation=(select location from mydb.dailyReportDetails as dtb where dtb.idDailyReport=vdrdid and dtb.counter>=(abs(vn_no_details/2)) order by dtb.idDailyReportDetails asc limit 1); 
Verwandte Themen