Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help with 2) d, e and 3) c please thank you d. Create a SQL stored procedur

ID: 3719008 • Letter: N

Question

need help with 2) d, e and 3) c please thank you

d. Create a SQL stored procedure and call it SP_HW4SP2 with a manufacture code argument (e.g. @Manu _Code). e. Call the SP HW4SP2 ew database call it HW3_TR and perform the following task: a. Create a student table with two columns (Student id, Student_name) b. Create another table call it student_BACKUP table with two columns (Student_id, Student name c. Create a trigger call it TR_AfterInsert_Student. This trigger will be fired if a new record gets inserted on the student table and then store the new inserted a record on the student backup table Hint: use the following query inside the body of the trigger: BEGIN INSERT INTO STUDENT BACKUP SELECT FROM INSERTED END 28 music

Explanation / Answer

2-d) A procedure is created and argument Manu_Code will be passed to it. It will retrieve the manufacturer detail based on the passed Manu_Code.

CREATE PROCEDURE SP_HW4SP2 @Manu_Code int

AS SELECT *

FROM Manufacturer

WHERE code = @Manu_Code

GO

e)Executing stored procedure. For testing I am assuming Manu_code = 23 exist in Manufacturer table. Manu_Code can be replaced by any valid code.

EXEC SP_HW4SP2 @Manu_Code = 23

3-c) Insert after trigger is created. Whenever recird is inserted into the student table, the same record will also get inserted to the student_BACKUP table.

CREATE OR REPLACE TRIGGER TR_AfterInsert_Student AFTER INSERT ON student

FOR EACH ROW

DECLARE

BEGIN

insert into student_BACKUP values (:new.Student_id, :new.Student_name);

END;