Professional Documents
Culture Documents
MYSQL Stored Procedures
MYSQL Stored Procedures
DELIMITER //
CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(25))
BEGIN
SELECT * FROM offices WHERE country = countryName;
END //
DELIMITER ;
CALL GetOfficeByCountry(USA);
CALL GetOfficeByCountry(FRANCE);
-- Call GetCustomerShipping()
SET @customerNo = 112;
SELECT country INTO @country
FROM customers
WHERE customernumber = @customerNo;
CALL GetCustomerShipping(@customerNo, @shipping);
SELECT @customerNo AS Customer,
@country AS Country,
@shipping AS Shipping;