I need help making this trigger, the output has to match the following question.
ID: 3832755 • Letter: I
Question
I need help making this trigger, the output has to match the following question. I need this in Microsoft SQL Server, not in Oracle.
ENROLLMENT table before delete command in ENROLLMENT table Stu Tech ID Enr Term Enr Total Credits 12345678 Fall 2016 12345678 Spring 2017 12 23456789 Spring2017 18 34567890 Fall 2016 15 61234567 Fall 2018 8 ENROLLMENT table after delete command in ENROLLMENTtable Stu Tech ID Enr Tema Enr Total Credits 12345678 Fall 2016 12345678 Spring 2017 12 23456789 Spring 2017 18 34567890 Fall 2016 15 CARD table after delete command in ENROLLMENTtable Stu Tech ID Card Number Print Money Campus Cash 12345678 52272001 8.00 4.00 23456789 52272002 8.00 0.00 34567890 52272001 8.00 0.00 52272004 61234567 0.00 0.00 When a student drops out of their classes and the total number of credits for that term is 0, irrespective of what they have in print money, it has to be updated to 0. The update is to be done in Print Money account only. Use the following codes to test and see how your triggers work and make sure it matches with the output table attached with this question Step 1: Delete enrollment information for a student DELETE FROM ENROLLMENT WHERE Stu Tech ID 61234567 Step 2 Test if trigger worked Select from Enrollment Select from CardExplanation / Answer
Trigger:
A trigger is a special kind of a store procedure that executes in response to certain action on the table like insertion, deletion or updation of data
Triggers Can be classified into
After Triggers:
Instead Of Triggers:
Code:
CREATE TRIGGER trgEnrollment ON Student
AFTER DELETE
AS
declare @studentid int;
Set @studentid=(Select stu_tech_id from Enrollment where Enr_Total_Credits=0)
Delete from Enrollment where stu_tech_id=@studentid
Update Card Set Print_Money=0 where stu_tech_id=@studentid
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.