1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| declare @ccy1 int, @ccy2 int, @month int, @year int
declare curs2 cursor
for select cp.Ccy1, cp.Ccy2, cp.month, cp.year
from CurrencyPair cp
open curs2
fetch from curs2 into @ccy1, @ccy2, @month, @year
while @@fetch_status = 0
begin
update CurrencyPair
set Rate = (1/err1.Rate) * err2.Rate
from ExchangeRateReadable err1, ExchangeRateReadable err2
where err1.Month = @month
and err1.Year = @year
and err1.BaseCcy = 'GBP'
and err1.QuotedCcy = @ccy1
and err1.Rate is not null
and err1.Rate != 0
and err2.Month = @month
and err2.Year = @year
and err2.BaseCcy = 'GBP'
and err2.QuotedCcy = @ccy2
fetch from curs2 into @ccy1, @ccy2, @month, @year
end
close curs2
deallocate curs2 |
Partager