lease review this SQL trigger and let me know why instead of just updating the CS_Loyalty level for the customer that has a newly inserted ticket it updates all the customer's loyalty level to Emmy. CREATE TRIGGER Increment_ticket ON ticket

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter12: Subqueries And Merge Statements
Section: Chapter Questions
Problem 19MC
icon
Related questions
icon
Concept explainers
Question

Please review this SQL trigger and let me know why instead of just updating the CS_Loyalty level for the customer that has a newly inserted ticket it updates all the customer's loyalty level to Emmy.

CREATE TRIGGER Increment_ticket
ON ticket
AFTER insert AS BEGIN
UPDATE Customer SET CS_VISITS=CS_VISITS+1 IF 5 > (Select CS_VISITS from Customer where Customer.CS_ID= (Select C_ID from inserted))
UPDATE CUSTOMER SET CS_Loyalty= 'Emmy' where Customer.CS_ID= (Select C_ID from inserted)
ELSE
IF 15 > (Select CS_VISITS from Customer where Customer.CS_ID= (Select C_ID from inserted))
UPDATE CUSTOMER SET CS_Loyalty ='Grammy' where Customer.CS_ID= (Select C_ID from inserted)
ELSE
IF 30 > (Select CS_VISITS from Customer where Customer.CS_ID= (Select C_ID from inserted))
UPDATE CUSTOMER SET CS_Loyalty= 'Oscar' where Customer.CS_ID= (Select C_ID from inserted)
ELSE
IF 50 > (Select CS_VISITS from Customer where Customer.CS_ID= (Select C_ID from inserted))
UPDATE CUSTOMER SET CS_Loyalty= 'Tony' where Customer.CS_ID= (Select C_ID from inserted)
ELSE
IF 50 <= (Select CS_VISITS from Customer where Customer.CS_ID= (Select C_ID from inserted)) UPDATE CUSTOMER SET CS_Loyalty = 'EGOT' where Customer.CS_ID= (Select C_ID from inserted)
END;

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.
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning