I have a stored procedure that creates a temporary table (with a call to GetGroupNames).
I then want to create and open a cursor to call [CheckMandatoryField] for each row in the table.
It appears to me that the code below never loops through the table, and appears to set @GroupFieldName to the first row in the table each time.
I tested by adding the select statement: select @GroupFieldName.
Can anyone see what i am doing wrong?
-- Now validate all the other groups.
select * into #Groups
from dbo.GetGroupnames( @doc_id )
order by ag_Name
declare @GroupFieldName nvarchar(100);
declare Group_Cursor cursor for
select ag_Name from #Groups ;
open Group_Cursor ;
fetch next from Group_Cursor into @GroupFieldName
while (@@fetch_status = 0)
select @GroupFieldName ;
-- Validate the group
-- exec @return_value = [CheckMandatoryField] @doc_id = @doc_id, @ddt_FieldName = @GroupFieldName
-- if (@return_value = 0) set @Valid = 0 ;
close Group_Cursor ;
deallocate Group_Cursor ;
drop table #Groups ;