The use of MySQL midstream target

Source: Internet
Author: User

BEGIN#遍历占领野地表还原军队 #UpdateArmforceSet  Number=NumwhereTroopsid=(SelectId fromTroopswhereIsfrist=1  andCityid=Cityid)DECLARETIdDECIMAL( +,0)default -1; #occupyWild表的TroopsIdDECLARECidDECIMAL( +,0)default -1; #occupyWild表的CityIdDECLARETemp_tidDECIMAL( +,0)default -1; #occupyWild表的TroopsIdDECLARETemp_cidDECIMAL( +,0)default -1; #occupyWild表的CityIdDECLARETId2DECIMAL( +,0)default -1; #troops表的TroopsIdDECLARENum0int default 0; DECLARENum1int default 0; DECLARENum2int default 0; DECLARENum3int default 0; DECLARECurlCURSOR  for SELECTTroopsid,cityid fromOccupywildOrder  byTroopsidASC; DECLARE CONTINUEHANDLER forSQLSTATE'02000' SETTId= -1; OPENCurl; FETCHCurl intoTid,cid;  while(tId<>-1do #说明: The cursor variable is used once and then is cleared #************************Logic START************************                SetTId2=-1, Temp_tid=-1, Temp_cid=-1, NUM0=0, NUM1=0, num2=0, num3=0; SetTemp_tid=tId; SetTemp_cid=CID; SelectId intoTId2 fromTroopswhereIsfrist=1  andCityid=Temp_cid limit1; #正常情况下只有一条数据Select  Number  intoNum0 fromArmforcewhereTroopsid=Temp_tid andArmtype=0; Select  Number  intoNum1 fromArmforcewhereTroopsid=Temp_tid andArmtype=1; Select  Number  intoNum2 fromArmforcewhereTroopsid=Temp_tid andArmtype=2; Select  Number  intoNum3 fromArmforcewhereTroopsid=Temp_tid andArmtype=3; UpdateArmforceSet  Number= Number+Num0whereTroopsid=TId2 andArmtype=0; #退回军队Delete  fromArmforcewhereTroopsid=Temp_tid andArmtype=0; #删除军队UpdateArmforceSet  Number= Number+Num1whereTroopsid=TId2 andArmtype=1; Delete  fromArmforcewhereTroopsid=Temp_tid andArmtype=1; UpdateArmforceSet  Number= Number+Num2whereTroopsid=TId2 andArmtype=2; Delete  fromArmforcewhereTroopsid=Temp_tid andArmtype=2; UpdateArmforceSet  Number= Number+Num3whereTroopsid=TId2 andArmtype=3; Delete  fromArmforcewhereTroopsid=Temp_tid andArmtype=3; #************************LogicEND ************************      FETCHCurl intoTid,cid; END  while; CLOSECurl; END

Use of the MySQL midstream target

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.