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

I did set the code as if l am wrong as -- Unit 14 - Triggers -- Unit 14.1 \'Ali\

ID: 3707474 • Letter: I

Question

I did set the code as if l am wrong as

-- Unit 14 - Triggers
-- Unit 14.1 'Ali', 'Alrahem', 'S00879581@acad.tri-c.edu', 'M

DELIMITER //
CREATE TRIGGER Student_Before_Update BEFORE UPDATE ON student
FOR EACH ROW
BEGIN
UPDATE student
SET EnrolledDate = Date(now())
WHERE ID =1;
UPDATE student
SET EnrolledDate = DATE_ADD(NOW(), INTERVAL 1 DAY)
WHERE ID =1;
IF EnrolledDate != NEW.ID THEN
SIGNAL SQLSTATE 'HY000'
SET MESSAGE_TEXT = 'Enrolled date may not in the future';
  
END IF;
  
  
  
END//

the question as follw but l have syntex error

there is soamthing wrong with my written code so which data to set based on student table

maby l am coding the wrong infrmation based on the requred as

Screen shot of the Output Window showing the output both UPDATE statements

SQL that creates your trigger

Screen shot of the Output Window showing the output with the error.

[10] For this step, write a before update trigger that prevents an update to the student table if the EnrolledDate is in the future. Name the trigger Student_Before Update. If the date is in the future, create a SQL signal and error with the message: "Enrolled date may not be in the future." 2. After you've created the trigger, run this SQL UPDATE Student SET EnrolledDate DATE (now)) WHERE ID = 1 ; UPDATE Student SET EnrolledDate = DATE ADD(NOW(),INTERVAL 1 DAY) WHERE ID 1;

Explanation / Answer

Hi,
Let's first clear out the question, what it is asking to do, what are the given things, and what is the required output.

1. It asks to write a TRIGGER before update which should basically, throw a SQL error if the date is in the future..
2. What it means is, whenever in future, someone updates this table, or there's a program running on it, the date should never be entered a future date.
3. So, keeping the above things in mind, we'll create the trigger as follows:
***************************************SQL Query******************************************

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote