Which type of database constraint does the following trigger implement? a.Key constraint b.Dynamic integrity constraint c.Static integrity constraint d.Inter-relational integrity constraint

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter7: Database Administration
Section: Chapter Questions
Problem 7TD: Delete the index named ITEM_INDEX3.
icon
Related questions
icon
Concept explainers
Question

Which type of database constraint does the following trigger implement?

a.Key constraint
b.Dynamic integrity constraint
c.Static integrity constraint
d.Inter-relational integrity constraint
DELIMITER $$
CREATE TRIGGER TRG_BEFORE_UPDATE_ON_part
BEFORE UPDATE ON part FOR EACH ROW
BEGIN
DECLARE errorMessage VARCHAR (255) ;
SET errorMessage = CONCAT ( ' The new selling price of ',
NEW.part_sellingprice,
' cannot be 2 times greater than the current selling
price of ',
OLD.part_sellingprice);
IF NEW.part_sellingprice > OLD.part_sellingprice * 2 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = errorMessage;
END IF;
END $$
DELIMITER;
Transcribed Image Text:DELIMITER $$ CREATE TRIGGER TRG_BEFORE_UPDATE_ON_part BEFORE UPDATE ON part FOR EACH ROW BEGIN DECLARE errorMessage VARCHAR (255) ; SET errorMessage = CONCAT ( ' The new selling price of ', NEW.part_sellingprice, ' cannot be 2 times greater than the current selling price of ', OLD.part_sellingprice); IF NEW.part_sellingprice > OLD.part_sellingprice * 2 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = errorMessage; END IF; END $$ DELIMITER;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr