Create a trigger that adds a warning \"Negative balance!!! Add money now!\" in t
ID: 3572963 • Letter: C
Question
Create a trigger that adds a warning "Negative balance!!! Add money now!" in the comment attribute of the customer table each time c_acctbal is updated to a negative value. Also, create a trigger that removes that warning if the balance goes back positive. Write a SQL statement that sets the balance to -200 for all the customers in ASIA. Write a query that returns the number of customers with negative balance from CHINA. Write a SQL statement that sets the balance to 100 for all the customers in CHINA. Write a query that returns the number of customers with negative balance from ASIA. Put all the SQL statements in file 2.sql.Explanation / Answer
CREATE TRIGGER negative_account_balance
BEFORE DELETE OR INSERT OR UPDATE ON customer
FOR EACH ROW
WHEN (c_acctbal < 0)
UPDATE customer SET comment = 'Negative balance !!! Add money now';
CREATE TRIGGER positive_account_balance
BEFORE DELETE OR INSERT OR UPDATE ON customer
FOR EACH ROW
WHEN (c_acctbal > 0)
UPDATE customer SET comment = ' ';
UPDATE customer SET c_acctbal = -200 WHERE continent='ASIA';
SELECT * FROM customer WHERE c_acctbal<0 AND country='CHINA';
UPDATE customer SET c_acctbal = 100 WHERE country='CHINA';
SELECT * FROM customer WHERE c_acctbal<0 AND continent='ASIA';
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.