觸發器
--Persons and BPersons
create trigger BPersonsInsert On Bpersons
after insert
as
SET IDENTITY_INSERT persons ON
insert persons (PersonID, UserID, FullName, UserAccount,
BioIDState, PersonFlags, Salutation, SalutationPhonemes,
Description, Notification, SecurityLevel)
select PersonID, UserID, FullName, UserAccount,
BioIDState, PersonFlags, Salutation, SalutationPhonemes,
Description, Notification, SecurityLevel
From inserted
Go
create trigger BPersonsUpdate On Bpersons
after update
as
declare @strBioIDState INT
declare @PersonID INT
select @PersonID= PersonID, @strBioIDState = BioIDState from inserted
if @strBioIDState = '1'
begin
update persons set UserID = b.UserID,
FullName = b.FullName,
UserAccount = b.UserAccount,
BioIDState = b.BioIDState,
PersonFlags = b.PersonFlags,
Salutation = b.Salutation,
SalutationPhonemes = b.SalutationPhonemes,
Description = b.Description,
Notification = b.Notification,
SecurityLevel = b.SecurityLevel
From persons a join inserted as b
on a.PersonID = b.PersonID
end
else
begin
delete Persons where PersonID= @PersonID
end
Go
insert into BPersons
(UserID,PassWord,FullName,UserAccount,BioIDState,PersonFlags,Salutation,Description,SecurityLevel)
values ('{ba9daeb3-f02e-4e14-9c8e-cb8d666a6c19}','Admin','Admin','Admin','1','9','Welcome $(FullName)','Admin','0.5')
Go
--InitDictionaryTable
insert into BDictionary (BDictiongary_ID,BDictionary_Key,BDictionary_Culture,BDictionary_Name)
values ('D8B5E5AD-E939-46FF-A4B3-01C6D8232454','C',NULL,NULL)
insert into BDictionary (BDictiongary_ID,BDictionary_Key,BDictionary_Culture,BDictionary_Name)
values ('86A2EBA7-1983-455E-B9C2-15757B54131C','R',NULL,NULL)
insert into BDictionary (BDictiongary_ID,BDictionary_Key,BDictionary_Culture,BDictionary_Name)
values ('ABB38F0D-825C-492E-B451-4FF418FFFBE7','M',NULL,NULL)
insert into BDictionary (BDictiongary_ID,BDictionary_Key,BDictionary_Culture,BDictionary_Name)
values ('CD21D9B3-F78B-4D21-BEB8-B5B13BBA6AE3','D',NULL,NULL)
Go
浙公网安备 33010602011771号