DELIMITER $$
DROP PROCEDURE IF EXISTS SP2 $$ CREATE PROCEDURE SP2() BEGIN
Declare InputCustomerID int; Declare InputOrderID int; Declare
OrderStateDate Datetime;
Select CustomerID into InputCustomerID From Cusomers Where
CustomerID NOT IN (Select FK_CustomerID From CustomerOrders) and
IsApproved = True and CustomerID IN
(Select FK_CustomerID From CustomerProductOrders
Where Date (OrderStartDate) = Date(Now()));
Select OrderID into InputOrderID From CustomerOrders Where
FK_CustomerID NOT IN (Select FK_CustomerID From CustomerProdcutOrders)
and IsApproved = True and Date(OrderStartDate) = Date(Now());
Call SP1(InputCustomerID, InputOrderID);
END $$
DELIMITER ;