DECLARE @id_venta int
DECLARE venta_cursor CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY FOR
select convert(int,Vista_Aux.dbo.Maestro.Observaciones)
from Vista_Aux.dbo.Maestro;
OPEN venta_cursor
FETCH NEXT FROM venta_cursor
INTO @id_venta
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE Ventas
set
ventas.id_cajero=1,
ventas.fecha=m.fechaticket,
ventas.descuento=m.descuentototal,
ventas.tipo_de_cambio=m.tc,
ventas.status_pago=1
from ventas as v
inner join Vista_Aux.dbo.Maestro as m on v.id_venta=convert(int,m.Observaciones)
where v.id_venta=@id_venta
FETCH NEXT FROM venta_cursor
INTO @id_venta
END
CLOSE venta_cursor;
DEALLOCATE venta_cursor;
ECLARE @id_dev char(10)
DECLARE dev_cursor CURSOR FOR
SELECT [id_venta]
FROM [Vista_Aux].[dbo].[Devoluciones];
OPEN dev_cursor
FETCH NEXT FROM dev_cursor
INTO @id_dev
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE Ventas
set status_pago=-1
where id_venta=@id_dev
FETCH NEXT FROM dev_cursor
INTO @id_dev
END
CLOSE dev_cursor;
DEALLOCATE dev_cursor;
No hay comentarios:
Publicar un comentario