1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Pepsi [2]
3 years ago
8

Write a script that creates and calls a stored procedure named test. This procedure should use a transaction that includes the s

tatements necessary to combine two customers. These statements should do the following: Select a row from the Customers table for the customer with a customer_id value of 6. This statement should lock the row so other transactions can’t read or modify it until the transaction commits, and it should fail immediately if the row is locked from another session. Update the Orders table so any orders for the selected customer are assigned to the customer with a customer_id value of 3. Update the Addresses table so any addresses for the selected customer are assigned to the customer with a customer_id value of 3. Delete the selected customer from the Customers table. If these statements execute successfully, commit the changes. Otherwise, rollback the changes.
Computers and Technology
1 answer:
natita [175]3 years ago
8 0

Answer:

Check the explanation

Explanation:

use `my_guitar_shop`;

#delete the procedure test if it exists.

DROP PROCEDURE IF EXISTS test;

DELIMITER //

CREATE PROCEDURE test ()

BEGIN

   #declare variable sqlerr to store if there is an sql exception

  declare sqlerr tinyint default false;

   #declare variable handler to flag when duplicate value is inserted

  declare continue handler for 1062 set sqlerr = TRUE;

   #start transaction

   start transaction;

  delete from order_items where order_id in

      (select order_id from orders where customer_id=6);

  delete from orders where customer_id=6;

  delete from addresses where customer_id=6;

  delete from customers where customer_id=6;

 

   if sqlerr=FALSE then

      commit;

        select 'Transaction Committed' as msg;

  else

       rollback;

       select 'Transaction rollbacked' as msg;

   end if;

end //

delimiter ;

call test();

You might be interested in
How do media and networks interact
valkas [14]

Answer:

Media are connected to networks that make information easier to access and pass on.

7 0
3 years ago
You can install several printers on your machine, but at least one must be the _______ printer.
Digiron [165]
<span>You can install several printers on your machine, but at least one must be the default printer.
When you have several machines attached to your computer, it is important to designate one of them as the 'default' machines so as to avoid confusion within the system. If you fail to do this, you may create some problems, so be sure to choose a default one.</span>
3 0
3 years ago
What is the purpose of a turbine in a power plant?
anastassius [24]
C. To make the generator work

4 0
3 years ago
Question #4
Nataliya [291]
A is your answer.............
3 0
3 years ago
Order the steps to use a logical argument as a rule type.
muminat

Answer:

Click home tab, click conditional formatting, click new rule, use formula to determine

6 0
3 years ago
Read 2 more answers
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • What command would you run from a windows command line to test a computer's network stack?
    7·1 answer
  • What provides quality education for students
    14·1 answer
  • What is a binary message
    12·2 answers
  • You create a new document and save it to a hard drive on a file server on your company's network. then you employ an encryption
    9·1 answer
  • A summer camp offers a morning session and an afternoon session. The list morningList contains the names of all children attendi
    6·1 answer
  • Write a qbasic program to design any simple software with output ​
    5·1 answer
  • How to execute python code in command prompt *window*?
    5·1 answer
  • 1.Microsoft Word is a/an ........​
    8·2 answers
  • In what medium do web applications operate?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!