Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER //
- CREATE PROCEDURE mockupNewOrder()
- BEGIN
- insert into order_details
- select
- -- order id
- odp.ProductID
- ,p.UnitPrice
- ,1 as `Quantity`
- ,0 as `Discount`
- from order_data_processing odp
- left join product p on odp.ProductID = p.ProductID;
- insert into orders
- select
- -- autoincrement OrderID,
- odp.CustomerID,
- 1 as EmployeeID,
- curdate() as OrderDate,
- NULL as RequiredDate,
- NULL as ShippedDate,
- 1 as ShipVia,
- 1 as Freight,
- c.CompanyName as ShipName,
- c.Address as ShipAddress,
- c.City as ShipCity,
- c.Region as ShipRegion,
- NULL as ShipPostalCode
- from order_data_processing odp
- left join customers c on odp.CustomerID = c.CustomerID;
- delete
- from order_data_processing;
- END //
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement