Курсовая работа: Информационная система военного округа
where t.[tip_i_nomer_obedinenia] = d.[tip_i_nomer_obedinenia] and
t.[Nomer_podrazdelenia] = d.[Nomer_podrazdelenia] and
t.[nazvanie_armii] = d.[nazvanie_armii])
begin
raiserror 50001 'Children still exist in table ''Chast''. Cannot update parent table ''Obedinenie''.'
rollback transaction
return
end
end
end
go
/* Update trigger "tu_armia" for table "armia" */
Create trigger [tu_armia]
on [armia] for update as
begin
declare @numrows int
select @numrows = @@rowcount
if @numrows = 0
return
/* Restrict child "Obedinenie" when parent "armia" updated */
if update([nazvanie_armii]) or
update([Nomer_podrazdelenia])
begin
if exists (select 1 from [Obedinenie] t, deleted d
where t.[nazvanie_armii] = d.[nazvanie_armii] and
t.[Nomer_podrazdelenia] = d.[Nomer_podrazdelenia])
begin
raiserror 50001 'Children still exist in table ''Obedinenie''. Cannot update parent table ''armia''.'
rollback transaction