Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Help in Stored Procedure sqlserver

Help in Stored Procedure sqlserver

Scheduled Pinned Locked Moved Database
helpsharepointdatabasesysadminannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aaraaayen
    wrote on last edited by
    #1

    Hi all, I am executing the following SP. But when i execute it, I get the error Server: Msg 16929, Level 16, State 1, Procedure BicRank, Line 34. The cursor is readonly. The Statement has been terminated. Please help me to come out from this problem. Its very urgent for me. This is the SP. SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO /****** Object: Stored Procedure dbo.BicRank / CREATE PROCEDURE BicRank AS -- determine mo3 bic and m03 ranking for mtc dmoq's ('TTR_1', 'TTR_2', 'TTR_3', 'PROGRS') -- ADDED ('TTR_6', 'TTR_12', 'TTR_24') By Nirmala 02/09/2007 --rankings are completed per dmoq, service, bicuniverse combination --100% is considered best Declare BicRank_DESC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where (Mo3_Percent < 101) and dmoq in ('TTR_1','TTR_2','TTR_3','TTR_6','TTR_12','TTR_24','PROGRS') order by compare, Mo3_percent desc declare @3mo as float, @rank as int, @heldcompare as varchar(60), @bic as float, @firstbic as float, @compare as varchar(60) declare @dmoq as varchar(20), @service as varchar(20), @bicuniverse as varchar(6), @RCD_CNT INTEGER OPEN BicRank_DESC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_DESC into @compare, @3mo while (@@fetch_status <> -1) begin IF (@heldcompare <> @compare) begin set @rank = 1 set @bic = @3mo set @firstbic = @3mo set @heldcompare = @compare end ELSE IF (@3mo <> @bic) begin set @rank = @rank + 1 set @bic = @3mo end SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION Update MTce_toExcel set Mo3_bic = @firstbic, Mo3_rank = @rank where current of BicRank_DESC FETCH NEXT FROM bicrank_DESC into @compare, @3mo END commit transaction CLOSE BicRank_DESC DEALLOCATE BicRank_DESC --determine mo3 bic and m03 ranking for mtc dmoq's ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3') --rankings are completed per dmoq, service, bicuniverse combination --0% is considered best Declare BicRank_ASC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where ( Mo3_Percent < 101 AND MO3_PERCENT IS NOT NULL) and dmoq in ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3','MTTR_F') order by compare, Mo3_percent asc OPEN BicRank_ASC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_ASC into @compare, @3mo while (@@fetch_status <> -1) begin IF @heldcompare <> @compare begin set @rank =

    P K A 3 Replies Last reply
    0
    • A aaraaayen

      Hi all, I am executing the following SP. But when i execute it, I get the error Server: Msg 16929, Level 16, State 1, Procedure BicRank, Line 34. The cursor is readonly. The Statement has been terminated. Please help me to come out from this problem. Its very urgent for me. This is the SP. SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO /****** Object: Stored Procedure dbo.BicRank / CREATE PROCEDURE BicRank AS -- determine mo3 bic and m03 ranking for mtc dmoq's ('TTR_1', 'TTR_2', 'TTR_3', 'PROGRS') -- ADDED ('TTR_6', 'TTR_12', 'TTR_24') By Nirmala 02/09/2007 --rankings are completed per dmoq, service, bicuniverse combination --100% is considered best Declare BicRank_DESC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where (Mo3_Percent < 101) and dmoq in ('TTR_1','TTR_2','TTR_3','TTR_6','TTR_12','TTR_24','PROGRS') order by compare, Mo3_percent desc declare @3mo as float, @rank as int, @heldcompare as varchar(60), @bic as float, @firstbic as float, @compare as varchar(60) declare @dmoq as varchar(20), @service as varchar(20), @bicuniverse as varchar(6), @RCD_CNT INTEGER OPEN BicRank_DESC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_DESC into @compare, @3mo while (@@fetch_status <> -1) begin IF (@heldcompare <> @compare) begin set @rank = 1 set @bic = @3mo set @firstbic = @3mo set @heldcompare = @compare end ELSE IF (@3mo <> @bic) begin set @rank = @rank + 1 set @bic = @3mo end SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION Update MTce_toExcel set Mo3_bic = @firstbic, Mo3_rank = @rank where current of BicRank_DESC FETCH NEXT FROM bicrank_DESC into @compare, @3mo END commit transaction CLOSE BicRank_DESC DEALLOCATE BicRank_DESC --determine mo3 bic and m03 ranking for mtc dmoq's ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3') --rankings are completed per dmoq, service, bicuniverse combination --0% is considered best Declare BicRank_ASC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where ( Mo3_Percent < 101 AND MO3_PERCENT IS NOT NULL) and dmoq in ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3','MTTR_F') order by compare, Mo3_percent asc OPEN BicRank_ASC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_ASC into @compare, @3mo while (@@fetch_status <> -1) begin IF @heldcompare <> @compare begin set @rank =

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      This is probably a permissions issue. Check that you have the appropriate permissions to execute the updates. BTW, you could probably rewrite your code without using cursors.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      1 Reply Last reply
      0
      • A aaraaayen

        Hi all, I am executing the following SP. But when i execute it, I get the error Server: Msg 16929, Level 16, State 1, Procedure BicRank, Line 34. The cursor is readonly. The Statement has been terminated. Please help me to come out from this problem. Its very urgent for me. This is the SP. SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO /****** Object: Stored Procedure dbo.BicRank / CREATE PROCEDURE BicRank AS -- determine mo3 bic and m03 ranking for mtc dmoq's ('TTR_1', 'TTR_2', 'TTR_3', 'PROGRS') -- ADDED ('TTR_6', 'TTR_12', 'TTR_24') By Nirmala 02/09/2007 --rankings are completed per dmoq, service, bicuniverse combination --100% is considered best Declare BicRank_DESC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where (Mo3_Percent < 101) and dmoq in ('TTR_1','TTR_2','TTR_3','TTR_6','TTR_12','TTR_24','PROGRS') order by compare, Mo3_percent desc declare @3mo as float, @rank as int, @heldcompare as varchar(60), @bic as float, @firstbic as float, @compare as varchar(60) declare @dmoq as varchar(20), @service as varchar(20), @bicuniverse as varchar(6), @RCD_CNT INTEGER OPEN BicRank_DESC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_DESC into @compare, @3mo while (@@fetch_status <> -1) begin IF (@heldcompare <> @compare) begin set @rank = 1 set @bic = @3mo set @firstbic = @3mo set @heldcompare = @compare end ELSE IF (@3mo <> @bic) begin set @rank = @rank + 1 set @bic = @3mo end SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION Update MTce_toExcel set Mo3_bic = @firstbic, Mo3_rank = @rank where current of BicRank_DESC FETCH NEXT FROM bicrank_DESC into @compare, @3mo END commit transaction CLOSE BicRank_DESC DEALLOCATE BicRank_DESC --determine mo3 bic and m03 ranking for mtc dmoq's ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3') --rankings are completed per dmoq, service, bicuniverse combination --0% is considered best Declare BicRank_ASC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where ( Mo3_Percent < 101 AND MO3_PERCENT IS NOT NULL) and dmoq in ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3','MTTR_F') order by compare, Mo3_percent asc OPEN BicRank_ASC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_ASC into @compare, @3mo while (@@fetch_status <> -1) begin IF @heldcompare <> @compare begin set @rank =

        K Offline
        K Offline
        KANGAROO_
        wrote on last edited by
        #3

        would u please give me database only with fields too , so that i could run and help u by running this procedure. actually it is really hard to understand as like. u can use my mail id. :)

        manoj Kumar Jha "Learn to smile at every situation. See it as an opportunity to prove your strength and ability."

        1 Reply Last reply
        0
        • A aaraaayen

          Hi all, I am executing the following SP. But when i execute it, I get the error Server: Msg 16929, Level 16, State 1, Procedure BicRank, Line 34. The cursor is readonly. The Statement has been terminated. Please help me to come out from this problem. Its very urgent for me. This is the SP. SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO /****** Object: Stored Procedure dbo.BicRank / CREATE PROCEDURE BicRank AS -- determine mo3 bic and m03 ranking for mtc dmoq's ('TTR_1', 'TTR_2', 'TTR_3', 'PROGRS') -- ADDED ('TTR_6', 'TTR_12', 'TTR_24') By Nirmala 02/09/2007 --rankings are completed per dmoq, service, bicuniverse combination --100% is considered best Declare BicRank_DESC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where (Mo3_Percent < 101) and dmoq in ('TTR_1','TTR_2','TTR_3','TTR_6','TTR_12','TTR_24','PROGRS') order by compare, Mo3_percent desc declare @3mo as float, @rank as int, @heldcompare as varchar(60), @bic as float, @firstbic as float, @compare as varchar(60) declare @dmoq as varchar(20), @service as varchar(20), @bicuniverse as varchar(6), @RCD_CNT INTEGER OPEN BicRank_DESC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_DESC into @compare, @3mo while (@@fetch_status <> -1) begin IF (@heldcompare <> @compare) begin set @rank = 1 set @bic = @3mo set @firstbic = @3mo set @heldcompare = @compare end ELSE IF (@3mo <> @bic) begin set @rank = @rank + 1 set @bic = @3mo end SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION Update MTce_toExcel set Mo3_bic = @firstbic, Mo3_rank = @rank where current of BicRank_DESC FETCH NEXT FROM bicrank_DESC into @compare, @3mo END commit transaction CLOSE BicRank_DESC DEALLOCATE BicRank_DESC --determine mo3 bic and m03 ranking for mtc dmoq's ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3') --rankings are completed per dmoq, service, bicuniverse combination --0% is considered best Declare BicRank_ASC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where ( Mo3_Percent < 101 AND MO3_PERCENT IS NOT NULL) and dmoq in ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3','MTTR_F') order by compare, Mo3_percent asc OPEN BicRank_ASC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_ASC into @compare, @3mo while (@@fetch_status <> -1) begin IF @heldcompare <> @compare begin set @rank =

          A Offline
          A Offline
          andyharman
          wrote on last edited by
          #4

          Your update statement is using "where current of BicRank_DESC". This is only allowed if the cursor was declared with the "for update" clause. Regards Andy

          A 2 Replies Last reply
          0
          • A andyharman

            Your update statement is using "where current of BicRank_DESC". This is only allowed if the cursor was declared with the "for update" clause. Regards Andy

            A Offline
            A Offline
            aaraaayen
            wrote on last edited by
            #5

            Hi Thanks lot. Can you help me out how to apply that for update in my procedure. Since the same procedure executed in morning but when i tried later it gives an error. But didnt change anything in the procedure. Regards,

            1 Reply Last reply
            0
            • A andyharman

              Your update statement is using "where current of BicRank_DESC". This is only allowed if the cursor was declared with the "for update" clause. Regards Andy

              A Offline
              A Offline
              aaraaayen
              wrote on last edited by
              #6

              Hi, I tried to apply for update like below in SP. Error: Server: Msg 16957, Level 16, State 4, Procedure BicRank, Line 12 FOR UPDATE cannot be specified on a READ ONLY cursor. SP: SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO /****** Object: Stored Procedure dbo.BicRank Script Date: 08/01/2008 12:44:52 ******/ ALTER PROCEDURE BicRank AS -- determine mo3 bic and m03 ranking for mtc dmoq's ('TTR_1', 'TTR_2', 'TTR_3', 'PROGRS') -- ADDED ('TTR_6', 'TTR_12', 'TTR_24') By Nirmala 02/09/2007 --rankings are completed per dmoq, service, bicuniverse combination --100% is considered best Declare BicRank_DESC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where (Mo3_Percent < 101) and dmoq in ('TTR_1','TTR_2','TTR_3','TTR_6','TTR_12','TTR_24','PROGRS') order by compare, Mo3_percent desc for update of mo3_bic,mo3_rank declare @3mo as float, @rank as int, @heldcompare as varchar(60), @bic as float, @firstbic as float, @compare as varchar(60) declare @dmoq as varchar(20), @service as varchar(20), @bicuniverse as varchar(6), @RCD_CNT INTEGER OPEN BicRank_DESC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_DESC into @compare, @3mo while (@@fetch_status <> -1) begin IF (@heldcompare <> @compare) begin set @rank = 1 set @bic = @3mo set @firstbic = @3mo set @heldcompare = @compare end ELSE IF (@3mo <> @bic) begin set @rank = @rank + 1 set @bic = @3mo end SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION Update MTce_toExcel set Mo3_bic = @firstbic, Mo3_rank = @rank where current of BicRank_DESC FETCH NEXT FROM bicrank_DESC into @compare, @3mo END commit transaction CLOSE BicRank_DESC DEALLOCATE BicRank_DESC --determine mo3 bic and m03 ranking for mtc dmoq's ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3') --rankings are completed per dmoq, service, bicuniverse combination --0% is considered best Declare BicRank_ASC Cursor for Select dmoq + service + bicuniverse as compare, mo3_percent from mtce_toexcel where ( Mo3_Percent < 101 AND MO3_PERCENT IS NOT NULL) and dmoq in ('FAIL_FREQ', 'NRF', 'MTTR','MTTR_3','MTTR_F') order by compare, Mo3_percent asc for update of mo3_bic,mo3_rank OPEN BicRank_ASC set @heldcompare = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' FETCH NEXT FROM bicrank_ASC into @compare, @3mo while (@@fetch_status <> -1) begin IF @heldcompare <> @compare begin set @rank = 1 set @bic =

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups