MySQL Procedure Wait for loop to process before continuing -


i'm working on procedure need move stock items selected bin levelling bin , move items need in selected bin bin. empty container i'm using cursor. move instances selected container, i'm using procedure had created previously. i've noticed need sleep 1 second between these 2 part. if don't, error code: 1172. result consisted of more 1 row. can find procedure below. there better way this?

     create definer= current_user procedure container_emptyandupdatewithinstances (          out varresponse                    int unsigned,          in varidcontainer              int unsigned,          in vardelimitedidfainstances   text,          in variduser                   varchar(100)     )      begin      /*          procedure empty container varidcontainer putting items          in it's location stock leveling (idcontainer= 286)          move instances have been selected it's location          response number of instances remain in container     */          declare done                    int default false;         declare varidfainstance         int unsigned;         declare callquery               varchar(100);         declare containercontents cursor             select idfainstance              fj_fainstancecontainer_pta              idcontainer= varidcontainer                 , pta_validtimeend > now()                 , pta_assertiontimeend > now()              update;          declare continue handler not found set done = true;          -- upon error want roll changes made          declare exit handler sqlexception, sqlwarning          begin             rollback;             resignal;          end;           start transaction;              /*                 step 1                 empty container             */              open containercontents;               read_loop: loop                 fetch containercontents varidfainstance;                 if done                     leave read_loop;                 end if;                   call fainstancecontainer_update(286, varidfainstance, variduser);               end loop;               close containercontents;               sleep(1);              /*  step 2                 move selected instance container             */             -- number of instances gets returned              call fainstances_movetocontainer (varresponse, varidcontainer, vardelimitedidfainstances, variduser);           commit;       end 


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -