Create the trigger with the provided code

Assignment Help PL-SQL Programming
Reference no: EM133043843

Assignment 9-1: Creating a Trigger to Handle Product Restocking

Brewbean's has a couple of columns in the product table to assist in inventory tracking. The REORDER column contains the stock level at which the product should be reordered. If the stock falls to this level, Brewbean's wants the application to insert a row in the BB_PRODUCT_REQUEST table automatically to alert the ordering clerk that additional inventory is needed. Brewbean's currently uses the reorder level amount as the quantity that should be ordered. This task can be handled by using a trigger.

1. Take out some scrap paper and a pencil. Think about the tasks the triggers needs to perform, including checking whether the new stock level falls below the reorder point. If so, check whether the product is already on order by viewing the product request table; if not, enter a new product request. Try to write the trigger code on paper. Even though you learn a lot by reviewing code, you improve your skills faster when you create the code on your own.

2. Open the c9reorder. . txt file in the Chapter09 folder. Review this trigger code, and determine how it compares with your code.

3. In SQL Developer, create the trigger with the provided code.

4. Test the trigger with product ID 4. First, run the query shown in Figure 9-36 to verify the current stock data for this product. Notice that a sale of one more item should initiate a reorder.

2322_Stock Information2.jpg

FIGURE 9-36 Checking stock data

5. Run the UPDATE statement shown in Figure 9-37. It should cause the trigger to fire. Notice the query to check whether the trigger fired and whether a product stock request was inserted in the BB_PRODUCT_REQUEST table.

1517_Stock Information3.jpg

FIGURE 9-37 Updating the stock level for product 4

6. Issue a ROLLBACK statement to undo these DML actions to restore data to its original state for use in later assignments.

7. Run the following statement to disable this trigger so that it doesn't affect other projects:
ALTER TRIGGER bb_reorder_trg DISABLE;

Reference no: EM133043843

Questions Cloud

What are seductive details : What are seductive details? Should they be included in the delivery of a training program? If yes, explain how to do this and give an example.
What the total assets that will appear in the statement : The total assets of the Sufian Company (subsidiary) appeared in the book at 220,000 dinars. What the total assets that will appear in the statement
Pain points of such concert-going experiences : What are the pain points of such concert-going experiences? Who are the customers of traditional classical concerts? Andre Rieu Case
Advice mrs naidu if she her plans to pay down the home loan : The investment property is earning a profit before tax of $12,000. Advice Mrs Naidu if she her plans to pay down the home loan is appropriate
Create the trigger with the provided code : Review trigger code, and determine how it compares with your code - create the trigger with the provided code.
Post-covid-19 work environment : 1. Provide practical and creative recommendations for organizations about how to prepare for a post-Covid-19 work environment in a Canadian workplace environmen
What is the greatest amount you can borrow : Assume that you want to buy a new car and your credit score is 650; the interest rate you are offered is 10.50% APR, What is the greatest amount you can borrow
Coordinating the corporate compensation : The compensation and benefits manager plays a vital role in coordinating the corporate compensation and benefits department. With reference to theory and exampl
Common problems that employee assistance program : Briefly explain any FIVE (5) the common problems that an Employee Assistance Program (EAP) can address in the organisation. Use relevant examples to substantiat

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd