Question

The ‘SALES - Sunshine’ department has unfortunately run into a technical issue and is temporarily unable to process any ‘Credit’ or ‘Debit’ transactions. As a result, it only accepts ‘Cash’ transactions. Besides, the department is offering a 30% discount on ‘Data Recovery’ at the moment. Write a SQL statement to create an Oracle trigger SUNSHINE_DEPT that will set the PaymentType to always be ‘Cash’ for any purchases where the client is served by an employee of this department, and if the ServiceType is ‘Data Recovery’, give the customer a 30% discount. Note that this discount is exclusive to the ‘SALES - Sunshine’ department. Database structure:

The Database: The SALES database (Figure 1) captures the sales information in a company that provides IT services. The databa

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The trigger is created below. The trigger is on table Purchase, whenever a purchase happens this trigger will get fired. It will set the paymentType to Cash and give the discount to user who is served by the employee of dept Sales Sunshine and also if the service type is data recovery.

Trigger-

CREATE TRIGGER SUNSHINE_DEPT
BEFORE INSERT ON PURCHASE
FOR EACH ROW
BEGIN
   UPDATE PURCHASE
   SET PaymentType = "Cash", Amount = Amount - Amount * 0.30
   WHERE ServedBy = (SELECT EmpNo FROM EMP INNER JOIN DEPT ON EMP.DeptNo = DEPT.DeptNo WHERE DEPT.DName = "SALES-Sunshine")
   AND ServiceType = "Data Recovery";
END;

Add a comment
Know the answer?
Add Answer to:
The ‘SALES - Sunshine’ department has unfortunately run into a technical issue and is temporarily unable...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following ERD and two tables represent a partial model similar to what we used in...

    The following ERD and two tables represent a partial model similar to what we used in class. Answer all questions by writing SQL syntax to solve each. If a question requires more time, please move on to the next. Employee EmpNo (PK) Ename Job ManagerID HireDate Salary Commission DeptNo (FK) Department DeptNo Dname Location 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON Department DeptNo (PK) Dname Location 1400 Employee Monthly EmpNo Ename Job ManagerID HireDate...

  • You are part of an accounting firm Advisory team that has been engaged by a client to assess how ...

    You are part of an accounting firm Advisory team that has been engaged by a client to assess how they might make their “sales to order” process more “efficient”, perhaps with the introduction of new technologies. The client has provided a written description of their business, and the process under review, as follows: HHH is a small manufacturer of university based sportswear (a highly competitive market where fast response times are prized by customers). Sales span every region of the...

  • You are part of an accounting firm Advisory team that has been engaged by a client to assess how ...

    You are part of an accounting firm Advisory team that has been engaged by a client to assess how they might make their “sales to order” process more “efficient”, perhaps with the introduction of new technologies. The client has provided a written description of their business, and the process under review, as follows: HHH is a small manufacturer of university based sportswear (a highly competitive market where fast response times are prized by customers). Sales span every region of the...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT