Use of Cursors

Source: Internet
Author: User

DECLARE my_cursor1 Cursor--Define cursor
for (SELECT RowGuid, projectrowguid from [bimpm_base].[ DBO]. [Projectpermission_role] where subsystemrowguid = ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')--finds the desired set to be placed in the cursor
OPEN my_ Cursor1; --OPEN cursor
declare @RoleRowGuid varchar (@ProjectRowGuid varchar)
fetch NEXT from My_cursor1 to @RoleRowGuid , @ProjectRowGuid
while (@ @FETCH_STATUS =0)
Begin
---Inner loop
declare Cursor22 CURSOR for (select RowGuid from [ Bimpm_base]. [dbo]. [Projectpermissionitem] where subsystemrowguid = ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')
OPEN Cursor22
DECLARE @ItemRowGuid varchar
FETCH NEXT from Cursor22 to @ItemRowGuid
while (@ @FETCH_STATUS =0)
Begin
Insert into [bimpm_base]. [dbo]. [Projectpermission_menurole] (PROJECTROWGUID,PERMISSIONITEMROWGUID,ROLEROWGUID,SUBSYSTEMROWGUID)
Values (@ProjectRowGuid, @ItemRowGuid, @RoleRowGuid, ' a9318399-66fe-423e-93f5-ccd7c0a471c4 ')
fetch NEXT from Cursor22 into @ItemRowGuid
End
Close Cursor22

FETCH NEXT from My_cursor1 to @RoleRowGuid, @ProjectRowGuid---move cursor
End
Close My_cursor1

Use of Cursors

Related Article

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.