以下是我的存储过程
DELIMITER $$
USE `us_db`$$
DROP PROCEDURE IF EXISTS `getTransactionDetails`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `getTransactionDetails`(IN _MainDB VARCHAR(32),
IN _mobile VARCHAR(50),
IN _market_id VARCHAR(50),
IN _from DATE,
IN _to DATE)
BEGIN
SELECT
transaction_id AS txn_id,
DATE_FORMAT(createdon,"%d-%b-%Y %H:%i:%S") AS createdon,
order_id,
order_conv_total AS amount,
msisdn AS msisdn,
channel_id,
transmode_id,
statusid,
(SELECT fullname FROM _MainDB.entities WHERE entity_id=retailer_id) AS retailer,
FROM `us_transaction` `t` WHERE
t.market_id = _market_id AND msisdn = _mobile AND t.createdon BETWEEN CONCAT(DATE(_from)," 00:00:00") AND CONCAT(DATE(_to)," 23:59:59") ORDER BY t.createdon DESC LIMIT 100;
END$$
DELIMITER ;
现在的问题是零售商名称存储在一个单独的数据库中,我想通过 _MainDB 调用它。该数据库名称作为参数出现,但由于 _MainDB 被视为 varchar 类型,因此无法正确出现。如何将数据库名称作为存储过程中的参数???