1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
declare my_cursor cursor local for
select PRODUCT_REF,PRODUCT_RECO.[TYPE], PRODUCT_REF_RECO, sum(NOTE) as note
from PRODUCT_RECO
--where PRODUCT_REF='BODPSS60X' and PRODUCT_REF_RECO='ADIADBE10235'
group by PRODUCT_REF,PRODUCT_RECO.[TYPE],PRODUCT_REF_RECO
having COUNT(*)>1
order by PRODUCT_REF_RECO
open my_cursor
fetch next from my_cursor into @PRODUCT_REF,@TYPE,@PRODUCT_REF_RECO,@NOTE
while @@fetch_status=0
begin
print @PRODUCT_REF + ' ' + @PRODUCT_REF_RECO
delete from PRODUCT_RECO where product_ref=@PRODUCT_REF and type=@TYPE and PRODUCT_REF_RECO=@PRODUCT_REF_RECO
insert PRODUCT_RECO (PRODUCT_REF,PRODUCT_REF_RECO,TYPE,NOTE) values (@PRODUCT_REF,@PRODUCT_REF_RECO,@TYPE,@NOTE)
fetch next from my_cursor into @PRODUCT_REF,@TYPE,@PRODUCT_REF_RECO,@NOTE
end
close my_cursor
deallocate my_cursor |
Partager