I have two function called in stored procedure:
CALL createPost(IN value,@Outvalue);
Now I want to pass '@Outvalue' to other stored procedure:
CALL createPostMedia(@Outvalue);
I created a small test that can be useful:
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 ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.