12-15-09, 12:56 #1Registered User
- Join Date
- Dec 2009
Unanswered: Error in Stored Procedure - PLEASE HELP
OK - while running a stored procedure, we get this error:
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
WHERE Processed = 0 AND NewSiteID IS NULL
ORDER BY NewCustID, ImportSequence
FOR UPDATE OF NewCustID, ErrorMessage
FETCH NEXT FROM CSR_SITEID INTO @NewCustID
WHILE @@FETCH_STATUS = 0
-- If we have a new customer ID, find highest-numbered existing site for it.
IF @LastCustID <> @NewCustID
SELECT @LastSiteNbr = ISNULL(MAX(CONVERT(int,SUBSTRING(SiteID,LEN(RTRIM( @NewCustID))+1,10))),0)
FROM [dbo].[Site] WHERE CustID = @NewCustID
SELECT @LastCustID = @NewCustID
Any ideas how to fix the FOR UPDATE OF line?
12-15-09, 22:47 #2Annie's Dog Walker
Provided Answers: 6
- Join Date
- Nov 2004
- on the wrong server
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.