Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2006, 09:55 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cursor

I have a stored procedure..something like this:

DECLARE @AuthorID char(11)

DECLARE c1 CURSOR FOR
SELECT au_id
FROM authors

OPEN c1

FETCH NEXT FROM c1
INTO @AuthorID

WHILE @@FETCH_STATUS = 0
BEGIN

PRINT @AuthorID

FETCH NEXT FROM c1
INTO @AuthorID
END

CLOSE c1
DEALLOCATE c1
SET CURSOR_CLOSE_ON_COMMIT ON

SET CURSOR_CLOSE_ON_COMMIT OFF
DECLARE @AuthorIDs char(11)

DECLARE c11 CURSOR FOR
SELECT au_id
FROM authors

OPEN c11

FETCH NEXT FROM c11
INTO @AuthorIDs

WHILE @@FETCH_STATUS = 0
BEGIN

PRINT @AuthorIDs

FETCH NEXT FROM c11
INTO @AuthorIDs
END

CLOSE c11
DEALLOCATE c11

SET CURSOR_CLOSE_ON_COMMIT ON
DECLARE @AuthorIDw char(11)
SET CURSOR_CLOSE_ON_COMMIT OFF

DECLARE c12 CURSOR FOR
SELECT au_id
FROM authors

OPEN c12

FETCH NEXT FROM c12
INTO @AuthorIDw

WHILE @@FETCH_STATUS = 0
BEGIN

PRINT @AuthorIDw

FETCH NEXT FROM c12
INTO @AuthorIDw
END

CLOSE c12
DEALLOCATE c12

GOTO DOWNLOAD_REPORT

DOWNLOAD_REPORT:
print 'End report'
RETURN


question: if my second cursor doesnt contains any values, do 3rd cursor and GOTO still be executing?








Similar Threads
Thread Thread Starter Forum Replies Last Post
Magnetic Cursor - Target Area Cursor? gcarcass .NET Framework 2.0 1 May 5th, 2008 07:20 AM
cursor parameters??? evaldesc SQL Server 2000 8 July 28th, 2007 02:53 PM
Regarding Cursor param99 SQL Server 2000 1 September 8th, 2006 10:03 AM
Regarding Cursor param99 SQL Language 0 September 8th, 2006 03:56 AM
concat 2 different cursor sreekesh ADO.NET 0 August 18th, 2006 07:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.