Advertisement
gmendezm

Cursor Todas las Entregas Confirmadas

May 28th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.96 KB | None | 0 0
  1. DECLARE @estadoEntrega tipo_confirmado, @idProyecto INT, @codigoEntrega INT, @idMaterial INT, @idDestino
  2. DECLARE CursorEntregas CURSOR FOR SELECT entregaConfirmada, idProyecto, codigoEntrega, idMaterial, idDestino FROM entregas
  3.  
  4. OPEN CursorEntregas
  5.     FETCH NEXT FROM CursorEntregas INTO @estadoEntrega, @idProyecto, @codigoEntrega, @idMaterial, @idDestino
  6.     WHILE @@FETCH_STATUS = 0
  7.         BEGIN
  8.             SELECT @estadoEntrega = entregaConfirmada FROM entregas WHERE
  9.             idProyecto = @idProyecto,
  10.             idMaterial = @idMaterial,
  11.             codigoEntrega = @codigoEntrega,
  12.             idDestino = @idDestino
  13.             IF @estadoEntrega = 'F'
  14.                 BEGIN
  15.                     UPDATE entregas SET entregaConfirmada = 'T'  WHERE
  16.             idProyecto = @idProyecto,
  17.             idMaterial = @idMaterial,
  18.             codigoEntrega = @codigoEntrega,
  19.             idDestino = @idDestino
  20.                 END
  21.             FETCH NEXT FROM CursorEntregas INTO @estadoEntrega, @idProyecto, @codigoEntrega, @idMaterial, @idDestino
  22.         END
  23. CLOSE CursorEntregas
  24. DEALLOCATE CursorEntregas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement