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