Question
Write a trigger to update the CUST_BALANCE when an invoice is deleted. Name the trigger trg_updatecustbalance2. (You should delete INV_NUM 9006 from INV_MYSQL to ensure
Write a trigger to update the CUST_BALANCE when an invoice is deleted. Name the trigger trg_updatecustbalance2.
(You should delete INV_NUM 9006 from INV_MYSQL to ensure your code is correct.)
Problems 8.26-8.30 Complete Problem 29 Feedback Some expected rows were missing (shown in red below). Some unexpected rows were returned. Test Query SELECT * FROM CUST_MYSQL WHERE CUST_NUM=2000 2000 Expected Results CUST_NUM CUST_LNAME CUST_FNAME CUST_BALANCE Actual Results 2000 ( Smith Smith Jeanne CUST_NUM CUST_LNAME CUST_FNAME CUST_BALANCE < Jeanne 3/4 1050.11 > ||| = 1351.83 query.sql + 1 DROP TRIGGER IF EXISTS trg_updatecustbalance2; 2 CREATE TRIGGER trg_updatecustbalance2 3 AFTER DELETE ON INV_MYSQL FOR EACH ROW 4 UPDATE CUST_MYSQL 5 SET CUST_MYSQL.CUST_BALANCE=CUST_MYSQL.CUST_BALANCE-OLD. INV_AMOUNT CUST_MYSQL.CUST_NUM=OLD.CUST_NUM; 6 DELETE FROM INV_MYSQL WHERE INV_NUM=9006; 7 8 9 " SQL Viewer Ch08 Simple Co + D Query completed
Step by Step Solution
3.40 Rating (131 Votes )
There are 3 Steps involved in it
Step: 1
Answer QUERY USE Ch08SimpleCo CREATE TABLE CUSTMYSQL CUSTNUM int CUSTLNAME VARCHAR10 CUSTFNAME VARCHAR10 CUSTBALANCE float PRIMARY KEY CUSTNUM CREATE ...Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started