Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.77 KB | None | 0 0
  1. CREATE PROCEDURE `mockup_new_order` ()
  2. BEGIN
  3.     select
  4.     -- order id
  5.     odp.ProductID
  6.     ,p.UnitPrice
  7.     ,1 as `Quantity`
  8.     ,0 as `Discount`
  9.     from order_data_processing odp
  10.     left join product p on odp.ProductID = p.ProductID
  11.     into orders;
  12.    
  13.     select
  14.     -- autoincrement OrderID,
  15.     odp.CustomerID,
  16.     1 as EmployeeID,
  17.     curdate() as OrderDate,
  18.     NULL as RequiredDate,
  19.     NULL as ShippedDate,
  20.     1 as ShipVia,
  21.     1 as Freight,
  22.     c.CompanyName as ShipName,
  23.     c.Address as ShipAddress,
  24.     c.City as ShipCity,
  25.     c.Region as ShipRegion,
  26.     NULL as ShipPostalCode
  27.     from order_data_processing odp
  28.     left join customers c on odp.CustomerID = c.CustomerID
  29.     into order_details;
  30.    
  31.     delete
  32.     from order_data_processing;
  33.  
  34. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement