Hi all,I am getting the following error when I attempt to use the FOR UPDATE syntax with my cursor.FOR UPDATE cannot be specified on a READ ONLY cursor.The code for my cursor is as follows :Declare @LocalError integerdeclare @CURRENT_DATETIME datetimedeclare @LocalPackageName char(50)declare @LocalProcessName char(50)declare @LocalVersion integerDECLARE @Cost_Centre_Number integerDECLARE @Aggregation_Completed_Date integerDECLARE @Stopped_Flag integerDECLARE @Step_Start datetimeDECLARE @Step_End datetimedeclare @Process_From_date integerDECLARE @Target_date integerSELECT @Step_Start = getdate()select @LocalPackageName = 'AGGREGATION'Select @LocalProcessName = 'Process_Weekly_Aggregation_Queue'select @LocalVersion = 1select @Stopped_Flag = 0update [ETL_SERVER].ETlControl.dbo.TDL_TASKS set STOP = 0where PROCESSNAME = 'AGGREGATION_Q_PROCESSOR'EXECUTE DW_WRITE_LOG @Process = @LocalProcessName, @Package = @LocalPackageName, @Message = 'Process Started', @Start = @Step_Start, @VERSION = @LocalVersion, @Keep = N, @Error = @LocalErrordeclare cu_WEEKLY_Aggregation_Queue cursor FOR SELECT * FROM WEEKLY_AGGREGATION_PROCESS_QUEUE2where Aggregation_Completed_Date IS NULL ORDER BY Cost_Centre_NumberFOR UPDATEopen cu_WEEKLY_Aggregation_Queuefetch next from cu_WEEKLY_Aggregation_Queue INTO @Cost_Centre_Number, @Target_date , @Aggregation_Completed_Datewhile @@fetch_status = 0 and @Stopped_Flag = 0 BEGIN SELECT @Step_Start = getdate() EXECUTE DW_WRITE_LOG @Process = @LocalProcessName, @Package = @LocalPackageName, @Message = 'Start Loop', @Start = @Step_Start, @VERSION = @LocalVersion, @Keep = N, @Cost_Centre_Number = @Cost_Centre_Number, @Error = @LocalError EXEC @LocalError = AGG_WEEK_LOADER2 @Cost_Centre_Number, @Target_date if @LocalError = 0 BEGIN SELECT @Step_End = getdate() EXECUTE DW_WRITE_LOG @Process = @LocalProcessName, @Package = @LocalPackageName, @Message = 'Aggregated WEEK OK', @Start = @Step_Start, @end = @Step_End, @VERSION = @LocalVersion, @Keep = N, @Cost_Centre_Number = @Cost_Centre_Number, @Error = @LocalError UPDATE WEEKLY_AGGREGATION_PROCESS_QUEUE2 SET Aggregation_Completed_Date = convert( char(10), getdate(), 112) where CURRENT OF cu_WEEKLY_Aggregation_Queue END ELSE BEGIN SELECT @Step_End = getdate() EXECUTE DW_WRITE_LOG @Process = @LocalProcessName, @Package = @LocalPackageName, @Message = 'Aggregation ERROR', @Start = @Step_Start, @end = @Step_End, @VERSION = @LocalVersion, @Keep = Y, @Cost_Centre_Number = @Cost_Centre_Number, @Error = @LocalError END select @Stopped_Flag = STOP from [ETL_SERVER].ETlControl.dbo.TDL_TASKS where PROCESSNAME = 'AGGREGATION_Q_PROCESSOR' fetch next from cu_WEEKLY_Aggregation_Queue INTO @Cost_Centre_Number, @Target_Date, @Aggregation_Completed_Date ENDclose cu_WEEKLY_Aggregation_Queuedeallocate cu_WEEKLY_Aggregation_Queue
Your help would be much appreciated. Many thanks in advance.