我在存储过程中调用了两个函数:
CALL createPost(IN value,@Outvalue);
现在我想通过' @Outvalue'到其他存储过程:
CALL createPostMedia(@Outvalue);
答案 0 :(得分:0)
我创建了一个很有用的小测试:
DELIMITER //
CREATE PROCEDURE `createPost`(
IN `_value` VARCHAR(50),
OUT `_out_post_id` BIGINT UNSIGNED
)
BEGIN
INSERT INTO `post` (`value`) VALUES (`_value`);
SET `_out_post_id` := LAST_INSERT_ID();
END//
CREATE PROCEDURE `createPostMedia`(
IN `_in_post_id` BIGINT UNSIGNED
)
BEGIN
INSERT INTO `postmedia` (`post_id`) VALUES (`_in_post_id`);
END//
CREATE PROCEDURE `sp_test`()
BEGIN
CALL `createPost`('post_one', @`_out_post_id`);
CALL `createPostMedia`(@`_out_post_id`);
END//
CALL `sp_test`//
DELIMITER ;