Created
May 31, 2020 17:10
-
-
Save prashant4224/f7ba9c20d00f4365a7e2185f02550282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
CREATE PROCEDURE GetDeliveryStatus( | |
IN pOrderNumber INT, | |
OUT pDeliveryStatus VARCHAR(100) | |
) | |
BEGIN | |
DECLARE waitingDay INT DEFAULT 0; | |
SELECT | |
DATEDIFF(requiredDate, shippedDate) | |
INTO waitingDay | |
FROM orders | |
WHERE orderNumber = pOrderNumber; | |
CASE | |
WHEN waitingDay = 0 THEN | |
SET pDeliveryStatus = 'On Time'; | |
WHEN waitingDay >= 1 AND waitingDay < 5 THEN | |
SET pDeliveryStatus = 'Late'; | |
WHEN waitingDay >= 5 THEN | |
SET pDeliveryStatus = 'Very Late'; | |
ELSE | |
SET pDeliveryStatus = 'No Information'; | |
END CASE; | |
END$$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment