Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UDF - Cursor return -1 for rowcount
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
UDF - Cursor return -1 for rowcount
Divers
Thread ID:
00897180
Message ID:
00897180
Vues:
56
I'm wondering if anyone can spot a problem in my code. I'm trying to create a function that returns a string value that is based on one field from the query inside the udf. Running the the actual query by itself works, but in the UDF, the cursor is showing -1 for the @@cursor_rows value. The BOL say that if it returns a -1 the cursor is dynamic, but I don't know what would make this dynamic. Thanks for any help.

Kirk
CREATE FUNCTION Get_ProceduresOnCase  (@tiMeetID int)  
RETURNS varchar(1000) AS  
BEGIN 
     declare @tcProcDesc varchar(200)
     Declare @returnValue varchar(1000)
     declare @tiRows int
     declare @tiCtr int
     set @tiCtr=1
     declare CaseProcs cursor local for
	   select rtrim(Description)
		from meetings mx inner join
                     meetproc mp on mp.meetingnumber=mx.meetingnumber
	where mx.meetingNumber = @tiMeetID
	order by mp.sysorder
	-- Open our cursor and determine how many rows are in it
	Open CaseProcs
	set @tiRows=@@cursor_rows

	-- Loop Through the Cursor
	while (@tiCtr <= @tiRows)
	Begin
	   fetch CaseProcs into @tcProcDesc
           set @returnValue=@returnValue+rtrim(@tcProcDesc)+', '
	end 
     -- Close the Cursor
     Close CaseProcs
     DeAllocate CaseProcs
     return (@returnValue)
END
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform