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.99 KB | None | 0 0
  1. DELIMITER //
  2.  
  3. CREATE PROCEDURE mockupNewOrder()
  4. BEGIN
  5.    insert into order_details (ProductID, UnitPrice, Quantity, Discount)
  6.    select
  7.     odp.ProductID
  8.     ,p.UnitPrice
  9.     ,1 as `Quantity`
  10.     ,0 as `Discount`
  11.     from order_data_processing odp
  12.     left join products p on odp.ProductID = p.ProductID;
  13.    
  14.    
  15.     insert into orders (CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode)
  16.     select
  17.     -- autoincrement OrderID,
  18.     odp.CustomerID,
  19.     1 as EmployeeID,
  20.     curdate() as OrderDate,
  21.     NULL as RequiredDate,  
  22.     NULL as ShippedDate,
  23.     1 as ShipVia,
  24.     1 as Freight,
  25.     c.CompanyName as ShipName,
  26.     c.Address as ShipAddress,
  27.     c.City as ShipCity,
  28.     c.Region as ShipRegion,
  29.     NULL as ShipPostalCode
  30.     from order_data_processing odp
  31.     left join customers c on odp.CustomerID = c.CustomerID;
  32.    
  33.     delete
  34.     from order_data_processing;
  35. END //
  36.  
  37. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement