当前位置: 动力学知识库 > 问答 > 编程问答 >

MySQL create trigger declare

问题描述:

I am trying to complete this question

**

Produce an audit trail (in a separate table) that records the current username, system date & grade change when someone attempts to update a Students grade

**

Here are the tables and columns

Module (code,credits,cost,name)

session (code,date,room)

Exam (no,code,grade)

course (code,credits,name)

Student (no,name,cell)

Here is the code I have so far

DELIMITER $$

USE `HarlemHS`$$

CREATE

DEFINER=`HarlemHS`@`%`

TRIGGER `HarlemHS`.`ExamChange`

AFTER UPDATE ON `HarlemHS`.`Exam`

FOR EACH ROW

BEGIN

INSERT INTO NEW.GradeUpdateLog Date_Of_Change,old_grade)

VALUES (CURDATE(), grade);

END$$

I know I have to use DECLARE somewhere but not too sure where to use it and what to put in the DECLARE statement.

If i have missed anything let me know,

Thank you for the help :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: