Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cusor problem

Status
Not open for further replies.

EPNICO

MIS
Jun 14, 2001
45
US
I created this cursor routine and I can only run it once after that my fetch status = -1 all the time here is the routine. Any ideas are welcome. Thanks. epnico.

DECLARE RP1 CURSOR
FOR
SELECT POL_NBR FROM #RPTEST
OPEN RP1
DECLARE @WSPOLNO CHAR(10)

PRINT CONVERT(CHAR,@@FETCH_STATUS)

WHILE @@FETCH_STATUS <> -1
BEGIN
PRINT 'in loop'
FETCH RP1 INTO @WSPOLNO
PRINT @WSPOLNO
END

CLOSE RP1
DEALLOCATE RP1



 
copy/paste the code in other connection and run it. Sometimes SQLServer does such things. Also you can declare it as a scroll cursor and first step do a fetch_first. It run many than once. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top