• GilaMonster (10/20/2010)


    What do you mean by 'call a cursor'? A cursor isn't an object that you call, it's an object that you declare, use and then deallocate.

    Why do you want a cursor in the first place?

    Hi..

    within a procedure i m using following cursor... from a table i m taking every row and updating it to some other table..

    DECLARECURSOR_UPDATE_LIVECURSOR FOR SELECT ACTUAL_LINE_ID,TEMP_LINE_ID,ATTRIBUTE1,ATTRIBUTE2,CONVERT(VARCHAR(11),LTRIM(RTRIM(ATTRIBUTE3)), 106),CONVERT(VARCHAR(11),LTRIM(RTRIM(ATTRIBUTE4)), 106),ATTRIBUTE5,ATTRIBUTE6,ATTRIBUTE7 FROM TEMP_table WHERE ACTION_FLAG='U' AND SESSION_ID=@PBI_SESSION_ID AND TRN=@PBI_TRN

    OPEN CURSOR_UPDATE_LIVE

    FETCH NEXT FROM CURSOR_UPDATE_LIVE INTO @li_actual_line_id,@li_temp_line_id,@li_calendar_header_id,@lvc_period_name,@ld_from_date_1,@ld_to_date_1,@li_quarter_num ,@lvc_f_year ,@li_adjusting_period

    WHILE @@FETCH_STATUS = 0

    BEGIN

    UPDATE GL_CALENDAR_LINES SETCAL_HEADER_ID=@PVC_CALENDAR_HEADER_ID,

    PERIOD_NAME=@lvc_period_name,

    FROM_DATE=@ld_from_date_1,

    TO_DATE=@ld_to_date_1,

    QUARTER_NUM=@li_quarter_num,

    F_YEAR=@lvc_f_year,

    ADJUSTING_PERIOD=@li_adjusting_period,

    TRN=@PBI_TRN,

    STATUS=1,

    SESSION_ID=@PBI_SESSION_ID

    WHERE CAL_LINE_ID=@li_actual_line_id

    FETCH NEXT FROM CURSOR_UPDATE_LIVE INTO @li_actual_line_id,@li_temp_line_id,@li_calendar_header_id,@lvc_period_name,@ld_from_date_1,@ld_to_date_1,@li_quarter_num ,@lvc_f_year ,@li_adjusting_period

    END

    CLOSE CURSOR_UPDATE_LIVE

    DEALLOCATE CURSOR_UPDATE_LIVE