kreta/Kreta.DataAccess.Migrations/Scripts/20211115130259_DB_4057/DB_4057.sql
2024-03-13 00:33:46 +01:00

62 lines
No EOL
1.7 KiB
Transact-SQL

--Migration
disable trigger ALL on dbo.T_TANITASIORA;
go
declare @tanevek cursor;
declare @intezmenyid int;
declare @tanevid int;
set @tanevek = cursor static for
select t.C_INTEZMENYID, t.ID
from T_TANEV t
inner join T_INTEZMENY i on i.ID = t.C_INTEZMENYID
where i.TOROLT = 'F'
and t.TOROLT = 'F'
and t.C_NEV in ('2020/2021', '2021/2022')
and i.C_AZONOSITO not like '%[_]old'
and i.C_AZONOSITO not like 'move%'
and i.C_AZONOSITO not like '%[_]moved'
and i.C_AZONOSITO not like '%[_]removed'
and i.C_AZONOSITO not like '%deleted'
and i.C_AZONOSITO not like '%torolt'
order by t.C_INTEZMENYID, t.ID;
open @tanevek;
fetch next from @tanevek into @intezmenyid, @tanevid;
while (@@fetch_status = 0)
begin
exec dbo.uspUpdateTanoraEvesSorszam @pIntezmenyId = @intezmenyid, @pTanevId = @tanevid;
fetch next from @tanevek into @intezmenyid, @tanevid;
end
close @tanevek;
go
enable trigger ALL on dbo.T_TANITASIORA;
go
if exists(
select too.*
from T_TANITASIORA too
inner join T_TANEV v on v.ID = too.C_TANEVID
inner join T_INTEZMENY i on i.ID = v.C_INTEZMENYID
where v.TOROLT = 'F'
and v.C_NEV IN ('2020/2021', '2021/2022')
and too.TOROLT = 'F'
and too.C_ORAEVESSORSZAMA is null
and too.C_SORSZAMOZANDO = 'T'
and too.C_MEGTARTOTT = 'T'
and i.TOROLT = 'F'
and i.C_AZONOSITO not like '%[_]old'
and i.C_AZONOSITO not like 'move%'
and i.C_AZONOSITO not like '%[_]moved'
and i.C_AZONOSITO not like '%[_]removed'
and i.C_AZONOSITO not like '%deleted'
and i.C_AZONOSITO not like '%torolt'
)
throw 60000, 'Hiba a tanórák éves sorszámának számításakor', 1;
go