I have a question, I am devloping a procedure but the problem appears in
this part. I am trying to get all the values for the table and then want to
process it one by one.

But I wana make a loop, which will read each row from the cursor untill the
next reocrd will come, which don't have the same resourceID. Before reading
the next group of ResourceID, I want to write into a temporary table.a

If anyone have idea, please help me.

I also wana know that how to declare Array in Stored Procedure.

My proc;s some part:
--
****************************************************************************
*****************************
-- Open the main View of this report
_Lante_WklyStaffingReportProjectWeekView
--
****************************************************************************
*****************************
DECLARE ProjectWeek_Cursor SCROLL CURSOR FOR
SELECT OID, ResourceName, poolID, PoolName, ProjectOID,
ProjectName,
ProjCommitStartdate, ProjCommitEnddate, billable,
InterValStartDate, InterValEndDate,
SystemWeekHrsString, AssingWeekHrsString, AssignWeekDayHrsString,
RegionID, CityID, RegionName, CityName
From _Lante_WklyStaffingReportProjWeekView order by OID, ProjectOID
-- Where OID="41339" and ProjectOID = "18667"
--
****************************************************************************
*****************************
-- Open the Cursor for Processing
--
****************************************************************************
*****************************
OPEN ProjectWeek_Cursor
FETCH NEXT FROM ProjectWeek_Cursor
INTO @ResourceID, @ResourceName, @CompetencyID,
@CompetencyName, @ProjectID,
@ProjectDesc, @ProjStartDate, @ProjEndDate, @Billable,
@IntervalStartDate, @IntervalEndDate, @DefaWrkHrsString,
@AssingWeekHrsString, @AssignWeekDayHrsString,
@RegionID, @CityID, @RegionName, @CityName

--
****************************************************************************
*****************************
-- Loop Processing
--
****************************************************************************
*****************************
Declare @WeekNum Int

WHILE (@@FETCH_Status<>-1)
-- Begin 01
BEGIN
-- Print @RegionID
-- Print @RegionName
-- Print @CityID
-- Print @CityName
-- Print @CompetencyID
-- Print @ResourceID
-- Print @ResourceName
-- Print @CompetencyName
-- Print @ProjectID
-- Print @ProjectDesc
-- Print @ProjStartDate
-- Print @ProjEndDate
-- Print @Billable
-- Print @IntervalStartDate
-- Print @IntervalEndDate
-- Print @DefaWrkHrsString
-- Print @AssingWeekHrsString
-- Print @AssignWeekDayHrsString
IF (@@FETCH_Status<>-2)
-------------- Begin 02
BEGIN
----------------- Set the Values for Each Day from the @DefaWrkHrsString
Phase I
Select @DefasysWrkHrForSUN = Convert(Int,Left(@DefaWrkHrsString,2))
Select @DefasysWrkHrForMON =
Convert(Int,SubString(@DefaWrkHrsString,4,2))
Select @DefasysWrkHrForTUE =
Convert(Int,SubString(@DefaWrkHrsString,7,2))
Select @DefasysWrkHrForWED =
Convert(Int,SubString(@DefaWrkHrsString,10,2))
Select @DefasysWrkHrForTHU =
Convert(Int,SubString(@DefaWrkHrsString,13,2))
Select @DefasysWrkHrForFRI =
Convert(Int,SubString(@DefaWrkHrsString,16,2))
Select @DefasysWrkHrForSAT =
Convert(Int,Right(@DefaWrkHrsString,2))
-- Print "---- System Default Hours --------- "
-- Print @DefasysWrkHrForSUN
-- Print @DefasysWrkHrForMON
-- Print @DefasysWrkHrForTUE
-- Print @DefasysWrkHrForWED
-- Print @DefasysWrkHrForTHU
-- Print @DefasysWrkHrForFRI
-- Print @DefasysWrkHrForSAT
-- Print "---- System Default Hours --------- "
-------------- End 02
END

-------------- Begin 03
Begin
---------------------- Cases for Getting Assignmnent Hours
Set @DefaAssWrkHrForSUN =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,(Left(@AssingWeekHrsString,2)))
WHEN @AssignWeekDayHrsString is Not Null THEN 0
ELSE Convert(Int,Left(@DefaWrkHrsString,2))
END
Set @DefaAssWrkHrForMON =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,SubString(@AssingWeekHrsString,4,2))
WHEN @AssignWeekDayHrsString is Not Null THEN
Convert(Int,Left(@AssignWeekDayHrsString,2))
ELSE Convert(Int,SubString(@DefaWrkHrsString,4,2))
END
Set @DefaAssWrkHrForTUE =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,SubString(@AssingWeekHrsString,7,2))
WHEN @AssignWeekDayHrsString is Not Null THEN
Convert(Int,Left(@AssignWeekDayHrsString,2))
ELSE Convert(Int,SubString(@DefaWrkHrsString,7,2))
END
Set @DefaAssWrkHrForWED =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,SubString(@AssingWeekHrsString,10,2))
WHEN @AssignWeekDayHrsString is Not Null THEN
Convert(Int,Left(@AssignWeekDayHrsString,2))
ELSE Convert(Int,SubString(@DefaWrkHrsString,10,2))
END
Set @DefaAssWrkHrForTHU =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,SubString(@AssingWeekHrsString,13,2))
WHEN @AssignWeekDayHrsString is Not Null THEN
Convert(Int,Left(@AssignWeekDayHrsString,2))
ELSE Convert(Int,SubString(@DefaWrkHrsString,13,2))
END
Set @DefaAssWrkHrForFRI =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,SubString(@AssingWeekHrsString,16,2))
WHEN @AssignWeekDayHrsString is Not Null THEN
Convert(Int,Left(@AssignWeekDayHrsString,2))
ELSE Convert(Int,SubString(@DefaWrkHrsString,16,2))
END
Set @DefaAssWrkHrForSAT =
CASE
WHEN @AssingWeekHrsString is Not Null THEN
Convert(Int,RIGHT(@AssingWeekHrsString,2))
WHEN @AssignWeekDayHrsString is Not Null THEN 0
ELSE Convert(Int,RIGHT(@DefaWrkHrsString,2))
END
Begin
Insert Into Lante_WklyStaffingReport (RegionPoolID, RegionName,
CityPoolID, CityName, CompetencyPoolID, CompetencyName,
ResourceOID,
ResourceName, ProjectOID, ProjectDesc,
DefaWrkHrsWeek1, DefaWrkHrsWeek2, DefaWrkHrsWeek3, DefaWrkHrsWeek4,
DefaWrkHrsWeek5, DefaWrkHrsWeek6, DefaWrkHrsWeek7,
DefaWrkHrsWeek8,
AssignWrkHrsWeek1, AssignWrkHrsWeek2, AssignWrkHrsWeek3,
AssignWrkHrsWeek4,
AssignWrkHrsWeek5, AssignWrkHrsWeek6, AssignWrkHrsWeek7,
AssignWrkHrsWeek8,
BillableWrkHrsWeek1, BillableWrkHrsWeek2, BillableWrkHrsWeek3,
BillableWrkHrsWeek4,
BillableWrkHrsWeek5, BillableWrkHrsWeek6, BillableWrkHrsWeek7,
BillableWrkHrsWeek8,
WeekEndDate1, Billable)
Values
(@RegionID, @RegionName, @CityID, @CityName, @CompetencyID,
@CompetencyName,
@ResourceID, @ResourceName, @ProjectID, @ProjectDesc,

@SysWrkHr01,@SysWrkHr02,@SysWrkHr03,@SysWrkHr04,@SysWrkHr05,@SysWrkHr06,@Sys
WrkHr07,@SysWrkHr08,

@AssWrkHr01,@AssWrkHr02,@AssWrkHr03,@AssWrkHr04,@AssWrkHr05,@AssWrkHr06,@***
WrkHr07,@AssWrkHr08,

@BilWrkHr01,@BilWrkHr02,@BilWrkHr03,@BilWrkHr04,@BilWrkHr05,@BilWrkHr06,@Bil
WrkHr07,@BilWrkHr08,
@WeekEnd1, @Billable)
----------------------------- End 09A
End
-- Else
-- Begin
-- UPDATE Lante_WklyStaffingReport Set
AssignWrkHrsWeek1 = @AssWrkHr01,
-- AssignWrkHrsWeek2 =
@AssWrkHr02,
-- AssignWrkHrsWeek3 =
@AssWrkHr03,
-- AssignWrkHrsWeek4 =
@AssWrkHr04,
-- AssignWrkHrsWeek5 =
@AssWrkHr05,
-- AssignWrkHrsWeek6 =
@AssWrkHr06,
-- AssignWrkHrsWeek7 = @AssWrkHr07,
-- AssignWrkHrsWeek8 = @AssWrkHr08,

-- BillableWrkHrsWeek1 = @BilWrkHr01,
-- BillableWrkHrsWeek2 = @BilWrkHr02,
-- BillableWrkHrsWeek3 = @BilWrkHr03,
-- BillableWrkHrsWeek4 = @BilWrkHr04,
-- BillableWrkHrsWeek5 = @BilWrkHr05,
-- BillableWrkHrsWeek6 = @BilWrkHr06,
-- BillableWrkHrsWeek7 = @BilWrkHr07,
-- BillableWrkHrsWeek8 = @BilWrkHr08
-- End

--------------------- End 09A-A1
-- End
-------------- End 09
End

-------------- Data Processing Main Logic End

FETCH NEXT FROM ProjectWeek_Cursor
INTO @ResourceID, @ResourceName, @CompetencyID,
@CompetencyName, @ProjectID,
@ProjectDesc, @ProjStartDate, @ProjEndDate, @Billable,
@IntervalStartDate, @IntervalEndDate, @DefaWrkHrsString,
@AssingWeekHrsString, @AssignWeekDayHrsString ,
@RegionID, @CityID, @RegionName, @CityName

------------------------ Re-Initialize
Select @SysWrkHr01 = 0
Select @SysWrkHr02 = 0
Select @SysWrkHr03 = 0
Select @SysWrkHr04 = 0
Select @SysWrkHr05 = 0
Select @SysWrkHr06 = 0
Select @SysWrkHr07 = 0
Select @SysWrkHr08 = 0

Select @AssWrkHr01 = 0
Select @AssWrkHr02 = 0
Select @AssWrkHr03 = 0
Select @AssWrkHr04 = 0
Select @AssWrkHr05 = 0
Select @AssWrkHr06 = 0
Select @AssWrkHr07 = 0
Select @AssWrkHr08 = 0

Select @BilWrkHr01 = 0
Select @BilWrkHr02 = 0
Select @BilWrkHr03 = 0
Select @BilWrkHr04 = 0
Select @BilWrkHr05 = 0
Select @BilWrkHr06 = 0
Select @BilWrkHr07 = 0
Select @BilWrkHr08 = 0

-- End 01
End