Here's the readers digest version of what I want to do. I need to assign numbers to members (SampleNo) based on a set of criteria (this is not listed in the code below to keep things simple). Anyway, I'm selecting a some of the records in tblMemberlist. I then want to be able to set to SampleNo field based on the @Cnt variable. I did not include the looping logic in this code.
I've created this simplied version to test the assignment of the @Cnt variable to the SampleNo field and it isn't working. When I run the below code, I get the following error message:
Server: Msg 16930, Level 16, State 1, Line 0
The requested row is not in the fetch buffer.
Does anyone have any suggestions? Thanks in advance.
Declare @Cnt as smallint
Set @Cnt = 1
Declare FldVariables
Declare MemberList_Cursor cursor for
Select ml.clientid, ml.lob, ml.measure, ml.SampleNo
From dbo.tblMemberlist ml
inner join Spectrum.dbo.tblMemberMaster mm on ml.clientid=mm.clientid and ml.memberid=mm.memberid
Inner join
(
Select clientid, lob, measure, MRSS, round(MRSS*(1+OverSample)+.5,0,0) as FSS
From dbo.tblSampleSize
) ss on ml.clientid=ss.clientid and ml.lob=ss.lob and ml.measure=ss.measure
inner join
(
Select m.clientid, m.lob, m.measure, count(*) as EM
from dbo.tblMemberlist m
group by m.clientid, m.lob, m.measure
) m on ml.clientid=m.clientid and ml.lob=m.lob and ml.measure=m.measure
where em>MRSS
and em<=FSS
order by ml.clientid, ml.lob, ml.measure, mm.lastnm, mm.firstnm, mm.dob
For Update of SampleNo
Open Memberlist_Cursor
fetch next from Memberlist_cursor into FldVariables
Update dbo.tblmemberList
set SampleNo=@Cnt
where current of Memberlist_cursor
I've created this simplied version to test the assignment of the @Cnt variable to the SampleNo field and it isn't working. When I run the below code, I get the following error message:
Server: Msg 16930, Level 16, State 1, Line 0
The requested row is not in the fetch buffer.
Does anyone have any suggestions? Thanks in advance.
Declare @Cnt as smallint
Set @Cnt = 1
Declare FldVariables
Declare MemberList_Cursor cursor for
Select ml.clientid, ml.lob, ml.measure, ml.SampleNo
From dbo.tblMemberlist ml
inner join Spectrum.dbo.tblMemberMaster mm on ml.clientid=mm.clientid and ml.memberid=mm.memberid
Inner join
(
Select clientid, lob, measure, MRSS, round(MRSS*(1+OverSample)+.5,0,0) as FSS
From dbo.tblSampleSize
) ss on ml.clientid=ss.clientid and ml.lob=ss.lob and ml.measure=ss.measure
inner join
(
Select m.clientid, m.lob, m.measure, count(*) as EM
from dbo.tblMemberlist m
group by m.clientid, m.lob, m.measure
) m on ml.clientid=m.clientid and ml.lob=m.lob and ml.measure=m.measure
where em>MRSS
and em<=FSS
order by ml.clientid, ml.lob, ml.measure, mm.lastnm, mm.firstnm, mm.dob
For Update of SampleNo
Open Memberlist_Cursor
fetch next from Memberlist_cursor into FldVariables
Update dbo.tblmemberList
set SampleNo=@Cnt
where current of Memberlist_cursor