THEN SET NEW.District=’Unknown’; END IF : END; Does the CREATE TRIGGER statement accomplish this goal?

You wish to create a trigger on the ‘city’ table that will check the value of the ‘District’ field
before any INSERT. The trigger needs to change it to” Unknown” for an empty string or
NULL.
CREATE TRIGGER City_bi
BEFORE INSERT ON CITY
FOR EACH ROW
BEGIN
IF OLD. District IS NULL OR OLD.District= . .
THEN
SET NEW.District=’Unknown’;
END IF :

END;
Does the CREATE TRIGGER statement accomplish this goal?

You wish to create a trigger on the ‘city’ table that will check the value of the ‘District’ field
before any INSERT. The trigger needs to change it to” Unknown” for an empty string or
NULL.
CREATE TRIGGER City_bi
BEFORE INSERT ON CITY
FOR EACH ROW
BEGIN
IF OLD. District IS NULL OR OLD.District= . .
THEN
SET NEW.District=’Unknown’;
END IF :

END;
Does the CREATE TRIGGER statement accomplish this goal?

A.
Yes; the trigger works correctly.

B.
No; FOR EACH ROW is invalid syntax.

C.
No; the syntax should be CREATE TRIGGER city-bi ON city BEFORE INSERT….

D.
No; the OLD keyword cannot be used in an INSERT trigger.



Leave a Reply 5

Your email address will not be published. Required fields are marked *


gelito

gelito

Correct is D

Error 1363 (HY000): There is no OLD row in on INSERT trigger

vikram

vikram

there is no old.field for insert trigger