Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    Unhappy Unanswered: Error in Stored Procedure - PLEASE HELP

    OK - while running a stored procedure, we get this error:

    Initializing...
    Validating...
    Converting Customer IDs...
    Assigning new Site IDs...
    Msg 16932, Level 16, State 1, Procedure DataImport_Site_Import, Line 238
    The cursor has a FOR UPDATE list and the requested column to be updated is not in this list.
    The statement has been terminated.

    The section of the stored procedure that creates this error is this:

    -- Create new values.
    PRINT 'Assigning new Site IDs...'
    SELECT @LastSiteNbr = 0, @LastCustID = ''
    DECLARE CSR_SITEID CURSOR LOCAL FOR
    SELECT NewCustID
    FROM [dbo].[DataImport_Site]
    WHERE Processed = 0 AND NewSiteID IS NULL
    ORDER BY NewCustID, ImportSequence
    FOR UPDATE OF NewCustID, ErrorMessage
    OPEN CSR_SITEID
    FETCH NEXT FROM CSR_SITEID INTO @NewCustID
    WHILE @@FETCH_STATUS = 0
    BEGIN
    -- If we have a new customer ID, find highest-numbered existing site for it.
    IF @LastCustID <> @NewCustID
    BEGIN
    SELECT @LastSiteNbr = ISNULL(MAX(CONVERT(int,SUBSTRING(SiteID,LEN(RTRIM( @NewCustID))+1,10))),0)
    FROM [dbo].[Site] WHERE CustID = @NewCustID
    SELECT @LastCustID = @NewCustID
    END

    Any ideas how to fix the FOR UPDATE OF line?

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Brian, no one is answering your question because no one here codes like that. Cursors are frowned upon generally. I would hazard rewriting this as a single update but for the life of me (and maybe it's late) I do not know what it is trying to accomplish.

    can you tell us what it is supposed to do?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •