Cursor usage-loop statement

Source: Internet
Author: User

-- Model declare @ memberid int declare cstemp cursor
Select memberid from XXX open cstemp fetch next from cstemp into @ memberidwhile @ fetch_status = 0 begin
Xxx ......
Fetch next from cstemp into @ memberid
End close cstempdeallocate cstemp
-- Example: declare @ memberid int, @ betcoin money, @ awardcoin money, @ issystem bit -- winning Member, cast by member, number of currently rewarded golden beans declare cstemp cursor for select distinct memberid, betcoin, issystem from repository where wincoin = 0 and [email protected] And betnumber = @ result and (issystem = 0 or issystemgamegoldexchange = 1) Open cstemp fetch next from cstemp into @ memberid, @ betcoin, @ issystem while @ fetch_status = 0 -- if the cursor has a in
-- Processing statement .....
Set @ awardcoin = round (@ betcoin * @ PV, 0, 1)
Exec p_member_changegold_value 'game', @ awardcoin, @ memberid, 1
Fetch next from cstemp into @ memberid, @ betcoin, @ issystem -- jump to the next cursor end close cstemp -- close the cursor deallocate cstemp -- release the cursor

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.