Database Systems: Design, Implementation, & Management
11th Edition
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
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 8, Problem 14P
Program Plan Intro
Trigger:
The trigger is a named set of SQL statement that is executed at the time of data modification or meets some data description.
- If the stated trigger condition meets up, then the mentioned action in the trigger has been performed.
There are three parts of trigger; they are:
Event:
- It specifies the change to be made, such as an UPDATE or DELETE of a record.
Condition:
- It specifies the condition to examine the records about to be affected. For each record, that meets the condition given in the trigger.
Action:
- The action performed after the start of the trigger.
The syntax to create a trigger is as given below:
CREATE TRIGGER trigger_name
{BEFORE| AFTER|INSTEAD OF} {INSERT|DELETE|UPDATE} ON
table_name
[FOR EACH{ROW|STATEMENT}] [WHEN(condition)]
<triggered SQL statement here>;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write the SQL statements to do the following:
Create a trigger named trg_updatecustbalance2 to update the CUST_BALANCE in the CUSTOMER table when a new invoice record is deleted. Whatever value appears in the INV_AMOUNT column of the deleted invoice should be subtracted to the customer’s balance.
Task 8: Create the UPDATE_INVOICE procedure to change the date of the invoice whose number is stored in I_INVOICE_NUM to the date currently found in I_INVOICE_DATE.
Expected Results
INVOICE_NUM
INVOICE_DATE
CUST_ID
00001
2021-11-21
294
Trigger please
Chapter 8 Solutions
Database Systems: Design, Implementation, & Management
Ch. 8 - What is a cross join? Give an example of its...Ch. 8 - What three join types are included in the outer...Ch. 8 - Using tables named T1 and T2, write a query...Ch. 8 - Prob. 4RQCh. 8 - Prob. 5RQCh. 8 - Prob. 6RQCh. 8 - Prob. 7RQCh. 8 - What does it mean to say that SQL operators are...Ch. 8 - Prob. 9RQCh. 8 - Prob. 10RQ
Ch. 8 - Prob. 11RQCh. 8 - Prob. 12RQCh. 8 - Prob. 13RQCh. 8 - Given the employee information in Question 11,...Ch. 8 - Prob. 15RQCh. 8 - Prob. 16RQCh. 8 - Prob. 17RQCh. 8 - Prob. 18RQCh. 8 - What string function should you use to list the...Ch. 8 - Prob. 20RQCh. 8 - Prob. 21RQCh. 8 - Prob. 22RQCh. 8 - Prob. 23RQCh. 8 - Prob. 24RQCh. 8 - Prob. 1PCh. 8 - Insert the data into the tables you created in...Ch. 8 - Prob. 3PCh. 8 - Prob. 4PCh. 8 - Prob. 5PCh. 8 - Prob. 6PCh. 8 - Prob. 7PCh. 8 - Prob. 8PCh. 8 - Prob. 9PCh. 8 - Modify the CUSTOMER table to include two new...Ch. 8 - Prob. 11PCh. 8 - Prob. 12PCh. 8 - Prob. 13PCh. 8 - Prob. 14PCh. 8 - Prob. 15PCh. 8 - Prob. 16PCh. 8 - Write a trigger to update the customer balance...Ch. 8 - Write a procedure to delete an invoice, giving the...Ch. 8 - Prob. 19PCh. 8 - Prob. 20PCh. 8 - Prob. 21PCh. 8 - Prob. 22PCh. 8 - Prob. 23PCh. 8 - Prob. 24PCh. 8 - Prob. 25PCh. 8 - Prob. 26PCh. 8 - Prob. 27PCh. 8 - Create a trigger named trg_line_total to write the...Ch. 8 - Create a trigger named trg_line_prod that...Ch. 8 - Create a stored procedure named prc_inv_amounts to...Ch. 8 - Create a procedure named prc_cus_balance_update...Ch. 8 - Modify the MODEL table to add the attribute and...Ch. 8 - Prob. 33PCh. 8 - Modify the CHARTER table to add the attributes...Ch. 8 - Write the sequence of commands required to update...Ch. 8 - Write the sequence of commands required to update...Ch. 8 - Write the command required to update the...Ch. 8 - Write the command required to update the...Ch. 8 - Write the command required to update the...Ch. 8 - Prob. 40PCh. 8 - Create a trigger named trg_char_hours that...Ch. 8 - Create a trigger named trg_pic_hours that...Ch. 8 - Create a trigger named trg_cust_balance that...Ch. 8 - Alter the DETAILRENTAL table to include a derived...Ch. 8 - Alter the VIDEO table to include an attribute...Ch. 8 - Update the VID_STATUS attribute of the VIDEO table...Ch. 8 - Alter the PRICE table to include an attribute...Ch. 8 - Prob. 48CCh. 8 - Prob. 51C
Knowledge Booster
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.Similar questions
- Delete the OWNER_INDEX 3 index from the OWNER table.arrow_forwardMS SQL server Create a Stored Procedures with the name of “usp_CalculateTotals”. usp_CalculateTotals should take three parameters: a client’s social security number (input parameter), mode (input parameter), and the total (output parameter). If the mode is 1, it should calculate the total balance of all the accounts of the client. If the mode is 2, it should calculate the total withdrawal amounts the client has done, and if the mode is 3, it should calculate the total deposit amounts the client has done. Implement the stored procedure below:arrow_forwardTask 8: Create the UPDATE_INVOICE procedure to change the date of the invoice whose number is stored in I_INVOICE_NUM to the date currently found in I_INVOICE_DATE.arrow_forward
- 1) Add the following record to the OWNER table: INSERT INTO OWNER VALUES('SA100', 'Sam', 'Afyouni', '100 Hello St', 'Anytown', 'MA', '55555'); 2) Create the UPD_OWNER_LAST_NAMEprocedure to change the last name of the owner whose number is stored in I_OWNER_NUM (provided as a parameter) to the value currently found in I_LAST_NAME.arrow_forwardCreate an Oracle sequence named CUST_NUM_SEQ to generate values for customer numbers. The sequence should start with the value 2000. Create an Oracle sequence named INV_NUM_SEQ to generate values for invoice numbers. The sequence should start with the value 9000. Create a trigger named trg_updatecustbalance to update the CUST_BALANCE in the CUSTOMER table when a new invoice record is entered. (Assume that the sale is a credit sale.) Whatever value appears in the INV_AMOUNT column of the new invoice should be added to the customer’s balance. Test the trigger using the following new INVOICE record, which would add 225.40 to the balance of customer 1001: 8005, 1001, '27-APR-18', 225.40arrow_forwardCreate an SQL package specification and body called JOB_PKG, containing the following procedures: Create a procedure called ADD_JOB to insert a new job into the JOBS table. The procedure has job id, job title, minimum salary and maximum salary as parameters. Ensure that the value of maximum salary is greater than minimum salary, raise an exception if this rule is violated (create a private procedure for salary validation).arrow_forward
- In the SQL Oracle Application Write one query to return the employee_id, job_id, hire_date, and department_id of all employees and a second query listing employee_id, job_id, start_date, and department_id from the job_history table and combine the results as one single output. Make sure you suppress duplicates in the output.arrow_forwardTHIS MODULE IS ABOUT SUBQUERIES, SO YOU MUST USE SUBQUERIES INSTEAD OF TABLE JOINS (a) From which two fields in which table can you calculate the enrollment of a section?(b) From which table can you get both course and section numbers?(c) Which field in table SECTION uniquely identifies a section, section id or section no?(d) Write a SQL statement to show sections and their enrollment.(e) Write a SQL statement to show sections with enrollment greater than five. Display both course andsection numbersarrow_forwardTask 9: Create the DELETE_INVOICE procedure to delete the invoice whose number is stored in I_INVOICE_NUM.arrow_forward
- Task 14: List the invoice number and invoice date for each invoice that contains an invoice line for a Wild Bird Food (25 lb).arrow_forwardTask 9: Create the DELETE_INVOICE procedure to delete the invoice whose number is stored in I_INVOICE_NUM.arrow_forwardConsidering Vaccination Database, write queries to: Display the Subject CNIC, Name, Contact, Dose1 Center, and Dose2 Center as shown below: CNIC Name Contact Dose1 Center Dose2 Center 22401-6645321-1 Nasir 3409991112 Lachi Kohat 2 14301-6045321-5 Shahab 3409991112 kohat 3 Dara The subjects who have been vaccinated different types in Dose1 and Dose2. For instance, subjects who were vaccinated ‘Sinovac’ in the first dose, while Pfizer in the second dose.How many Viles of each type have been consumed so far. How many subjects are vaccinated from expired viles. Suggest the name of Incharge for the best performance award based on the highest number of subjects vaccinated on a single dayarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
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
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
dml in sql with examples; Author: Education 4u;https://www.youtube.com/watch?v=WvOseanUdk4;License: Standard YouTube License, CC-BY