Курсовая работа: Информационная система военного округа
rollback transaction
return
end
end
go
/* Delete trigger "td_armia" for table "armia" */
Create trigger [td_armia]
on [armia] for delete as
begin
declare @numrows int
select @numrows = @@rowcount
if @numrows = 0
return
/* Restrict child "Obedinenie" when parent "armia" deleted */
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 50003 'Children still exist in table ''Obedinenie''. Cannot delete from parent table ''armia''.'
rollback transaction
return
end
end
go
/* Delete trigger "td_Podrazdelenie" for table "Podrazdelenie" */
Create trigger [td_Podrazdelenie]
on [Podrazdelenie] for delete as
begin
declare @numrows int