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