我有一个存储过程返回过程执行代码在MySQL
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetNotExecutedOrders`(IN contractID INT(11))
BEGIN
SELECT idContract, idOrder, ProductID, Quantity, (SUM(`order`.Quantity))*(product.Price) as 'Total amount'
FROM typography.contract
JOIN typography.`order` ON contract.idContract=`order`.ContractID
JOIN typography.product ON `order`.ProductID=product.idProduct
WHERE idContract=contractID and ExecutionDate IS NULL
GROUP BY idOrder
ORDER BY idOrder;
END
我需要那么它是否有与该合同ID没有合同返回的执行代码<> 0来解决它,和合同列表如果与该合同ID有合同,则执行代码= 0。
使用'IF'语句。 – Barmar 2015-02-06 00:47:13
是的,我试过,但我不知道如何返回代码本身。你能帮我解决吗? – 2015-02-06 00:49:21
我建议为代码添加一个'OUT'参数。 – Barmar 2015-02-06 00:53:46