updating rows with cursor example
- From: "ziga" <ziga>
- Date: Tue, 24 Jan 2006 21:20:07 GMT
Here is an example how to udpate rows using cursors. But cursors are very slow, and everything can be done without using cursors!
Example(prim is table)
CREATE PROCEDURE [dbo].[krneki] AS
DECLARE @idtemp INT
DECLARE crs CURSOR FOR
SELECT id FROM prim FOR UPDATE OF id
OPEN crs
FETCH NEXT FROM crs
INTO @idtemp
WHILE @@FETCH_STATUS <> -1
BEGIN
IF @@FETCH_STATUS <> -2
BEGIN
UPDATE prim
SET id = 333
WHERE CURRENT OF crs
END
FETCH NEXT FROM crs INTO @idtemp
END
CLOSE crs
DEALLOCATE crs
>
> Hello there
>
> I've build program that needs to update data, in very complex way, so i had
> to use cursor for use it.
>
> The cursor works fine. But i need also to update the current record of the
> cursor
>
> Is there a way to do that?
> --
> øåòé âåìãäîø
> òúéã äðãñú úåëðä
> èì' 03-5611606
> ôìà' 050-7709399
> àéîééì: roy@xxxxxxxxxxxx
>
>
.
- References:
- Updating tables with cursor
- From: Roy Goldhammer
- Updating tables with cursor
- Prev by Date: Updating tables with cursor
- Next by Date: Re: Multi Dimensional Cases in Time Series
- Previous by thread: Updating tables with cursor
- Index(es):
Relevant Pages
|