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.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer QUERY USE Ch08SimpleCo CREATE TABLE CUSTMYSQL CUSTNUM int CUSTLNAME VARCHAR10 CUSTFNAME VARCHAR10 CUSTBALANCE float PRIMARY KEY CUSTNUM CREATE ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!