1. Trang chủ
  2. » Giáo Dục - Đào Tạo

NguyenPHPSE62075 LAB5

5 96 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 19,21 KB

Nội dung

Tên: Phạm Hoàng Phúc Nguyên Lớp: SE1069 MSSV: SE62075 LAB -I.1 IF OBJECT_ID('department_msg','TR') IS NOT NULL DROP TRIGGER department_msg CREATE TRIGGER department_msg ON tblDepartment AFTER INSERT, UPDATE AS DECLARE @MANGERID INT ,@depCode INT, @decode1 int SELECT @MANGERID= mgrSSN, @depCode=depCode FROM inserted SELECT @decode1= tblInstructor.depCode FROM tblInstructor WHERE tblInstructor.insSSN=@MANGERID IF(@depCode@decode1 OR @decode1 IS NULL) BEGIN RAISERROR('ERROR OUCUR',16,1) ROLLBACK TRANSACTION END GO -I.3 -IF OBJECT_ID ('TR_SIZE_OF_CLASS','TR') IS NOT NULL DROP TRIGGER TR_SIZE_OF_CLASS CREATE TRIGGER TR_SIZE_OF_CLASS ON tblStudent AFTER INSERT, UPDATE AS DECLARE @numberStudent int, @classCode int SELECT @classCode=claCode from inserted SELECT @numberStudent= COUNT(*) FROM tblStudent WHERE tblStudent.claCode=@classCode GROUP BY tblStudent.claCode IF(@numberStudent >=25) BEGIN RAISERROR ('Erro',16,1) ROLLBACK TRANSACTION END GO -I.2 IF OBJECT_ID ('TR_COURSE_TEACHER','TR') IS NOT NULL DROP TRIGGER TR_COURSE_TEACHER CREATE TRIGGER TR_COURSE_TEACHER ON tblTeaching AFTER INSERT, UPDATE AS DECLARE @depCode_Sub INT, @depCode_INS INT,@subCode INT,@inssn INT SELECT @subCode=subCode ,@inssn=insSSN FROM inserted SELECT @depCode_Sub=tblSubject.depCode FROM tblSubject WHERE tblSubject.subCode=@subCode SELECT @depCode_INS=depCode FROM tblInstructor WHERE insSSN=@inssn IF (@depCode_INS@depCode_Sub) BEGIN RAISERROR('ERRO',16,1) ROLLBACK TRANSACTION END GO I.5 IF OBJECT_ID('TR_MIN_INS','TR') IS NOT NULL DROP TRIGGER TR_MIN_INS CREATE TRIGGER TR_MIN_INS ON tblSection AFTER DELETE,UPDATE AS DECLARE @COUNT INT, @subCode INT SELECT @subCode=subCode FROM deleted SELECT @COUNT= COUNT(C.insSSN) FROM(SELECT DISTINCT S.* FROM tblSection S, tblSection R WHERE S.secNumber=R.secNumber AND S.secSemester=R.secSemester AND S.secYear=R.secYear AND S.subCode=R.subCode AND S.subCode=@subCode ) AS C GROUP BY C.subCode IF(@COUNT

Ngày đăng: 26/10/2019, 23:54

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w