Create procedure update_pointer () <br/> begin <br/>/* define variable 1 */<br/> declare total float; <br/> declare uid int; <br/> declare _ DONE int default 0; <br/> declare currentp int default 0; <br/> declare firstid int; <br/> declare secondid int; <br/> declare parentid varchar (16); <br/> declare first_jj_yy int default 0; # first-stage infrastructure fuel fee <br/> declare second_jj_ry int default 0; # basic fuel fee for the second Process <br/>/* define the cursor */<br/> declar E _ cur cursor for <br/> select alitotal, orduid, flightid, backfliid from fightorder where ordstate = 4; # Primary Order query <br/> declare _ currex cursor for <br/> select oeacttotal, ordid from flight_orderex where oestate = 4; </P> <p> declare continue handler for sqlstate '000000' SET _ DONE = 1; # error definition, mark the end of the loop </P> <p>/* Open the cursor */<br/> Open _ cur; <br/>/* cyclic execution */<br/> repeat <br/> fetch _ cur into total, uid, firstid, secondi D; <br/> if not _ done then <br/> If total> 0 and uid> 0 then <br/> select FCN + fyq into first_jj_yy from flightlist where flightid = firstid limit 1; <br/> If secondid> 0 then <br/> select FCN + fyq into second_jj_ry from flightlist where flightid = firstid limit 1; <br/> end if; <br/> Update sysusers set integral = (integral + total)-(second_jj_ry + first_jj_yy) Where sysusers. uid = uid; <br/> end if; <br/> Until _ done end repeat; # exit when _ DONE = 1 <br/>/* close the cursor */<br/> close _ cur; <br/> SET _ DONE = 0; # The New loop can continue only when it is defined as 0. <Br/> Open _ currex; <br/> repeat <br/> fetch _ currex into total, parentid; <br/> if not _ done then <br/> # If total> 0 then <br/> select orduid into uid from fightorder where fightorder. alipayno = parentid limit 1; # query user uid <br/> # insert into test values (total, UID); <br/> Update sysusers set integral = integral + total where sysusers. uid = uid; # Add Points <br/> # end if; <br/> until _ done end repeat; <br/> close _ currex; <br/> end