DELIMITER $$
USE `mg_ims`$$
DROP PROCEDURE IF EXISTS `sp_get_drop_down_data`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_drop_down_data`(
IN _name VARCHAR(15))
BEGIN
CASE
WHEN _name = 'CUSTOMERS' THEN
SELECT cust_id,cust_name,address FROM tb_customers;
WHEN _name = 'SUPPLIERS' THEN
SELECT supp_name FROM tb_suppliers;
WHEN _name = 'BRANDS' THEN
SELECT b.name FROM tb_brands b;
WHEN _name = 'REGIONAL_OFFICES' THEN
SELECT r.name FROM tb_area_offices r;
WHEN _name = 'SUB_OFFICES' THEN
SELECT s.name FROM tb_locations s;
ELSE
SELECT 404 `Code`,'Case not Found' Description;
END CASE;
END$$
DELIMITER ;
以上所有情况都正常,除了' regional_offices' ...虽然语法和逻辑是正确的......
答案 0 :(得分:1)
您的问题是_name
是varchar(15)
,但字符串'REGIONAL_OFFICES'
长度为16个字符!