Курсовая работа: Информационная система военного округа

/* Delete trigger "td_Rota" for table "Rota" */

Create trigger [td_Rota]

on [Rota] for delete as

begin

declare @numrows int

select @numrows = @@rowcount

if @numrows = 0

return

/* Restrict child "Vzvod" when parent "Rota" deleted */

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 50003 'Children still exist in table ''Vzvod''. Cannot delete from parent table ''Rota''.'

rollback transaction

return

end

end

go

/* Delete trigger "td_Vzvod" for table "Vzvod" */

Create trigger [td_Vzvod]

on [Vzvod] for delete as

begin

declare @numrows int

select @numrows = @@rowcount

if @numrows = 0

К-во Просмотров: 1251
Бесплатно скачать Курсовая работа: Информационная система военного округа