Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SQL triggers help INSERT UPDATE DELETE Before you begin, re-create your Sport Motors database. Write queries for the following tasks and save them in a

SQL triggers help INSERT UPDATE DELETE
image text in transcribed
Before you begin, re-create your Sport Motors database. Write queries for the following tasks and save them in a selfile labeled with comments. Upload your completed script to Blackboard in the Lab 2 link SportOrder Detail SportOrder Order Ordete Orderet Theory Dette PaymentType price of all In the SportOrder table, the Order NetTotalfield contains the total (SUM) of the quantity items in the related SportOrder Detailable for the order. In the figure below. For order 12. note how the quantity unit price is cakulated and added together to produce Order Ner Total: (1 95.99) + 115.39) + 148.99) = 147.34 FRON Sport Order T ROIN SportOrder Detail ON SportOrder Order ID - Sportorder Detail Order to ODD 11 200101100000000154095 2010-11 2007-03-11 00 00 00 00 1034 2001011000000107 16 Lab Tasks: 1. Create a scalor function named fn_Order Total that receives a parameter for Orderid and returns the total cost of the entire order, as calculated from the SportOrder Detail table (quantity price, added up for all items on the order). 2. Write a SELECT statement that displays the OrderiD, Order Date, and OrderNetTotal from the SportOrder table, along with a column named "Calculated Total column that uses the function fn_Order Total to calculate the order total, for order 12. Sample output is below. order orderDate 2007-03-11 00:00:00.000 OrderNetTotal 147 34 Calculated Total 147 34 3. Create the necessary INSERT, UPDATE, and DELETE triggers on the SportOrder Detail table, needed to maintain the correct amount in SportOrder OrderNetTotal for those actions. Your triggers can make use of the function you created in question 1 to calculate the new total when the order details change Before you begin, re-create your Sport Motors database. Write queries for the following tasks and save them in a selfile labeled with comments. Upload your completed script to Blackboard in the Lab 2 link SportOrder Detail SportOrder Order Ordete Orderet Theory Dette PaymentType price of all In the SportOrder table, the Order NetTotalfield contains the total (SUM) of the quantity items in the related SportOrder Detailable for the order. In the figure below. For order 12. note how the quantity unit price is cakulated and added together to produce Order Ner Total: (1 95.99) + 115.39) + 148.99) = 147.34 FRON Sport Order T ROIN SportOrder Detail ON SportOrder Order ID - Sportorder Detail Order to ODD 11 200101100000000154095 2010-11 2007-03-11 00 00 00 00 1034 2001011000000107 16 Lab Tasks: 1. Create a scalor function named fn_Order Total that receives a parameter for Orderid and returns the total cost of the entire order, as calculated from the SportOrder Detail table (quantity price, added up for all items on the order). 2. Write a SELECT statement that displays the OrderiD, Order Date, and OrderNetTotal from the SportOrder table, along with a column named "Calculated Total column that uses the function fn_Order Total to calculate the order total, for order 12. Sample output is below. order orderDate 2007-03-11 00:00:00.000 OrderNetTotal 147 34 Calculated Total 147 34 3. Create the necessary INSERT, UPDATE, and DELETE triggers on the SportOrder Detail table, needed to maintain the correct amount in SportOrder OrderNetTotal for those actions. Your triggers can make use of the function you created in question 1 to calculate the new total when the order details change

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago