Anorm Mysql Stored Procedure calling

烈酒焚心 提交于 2020-01-24 13:20:06

问题


This is my simple stored procedure ,

DELIMITER $$

USE `TestDB`$$

DROP PROCEDURE IF EXISTS `test123`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `test123`(id INT(11) , user_name VARCHAR(15), branch VARCHAR(15))
BEGIN
INSERT INTO Testlog(id,user_name,branch)
VALUES(id,user_name,branch);
END$$

DELIMITER ;

i can run above stored procedure with below command in mysql

CALL `TestDB`.test123(3,"swap","desc")

but using anorm how to do that??

DB.withConnection { implicit c =>
SQL("EXCE  test123 {id},{name},{branch}").
on('id -> 22,
'name -> "lcs",
'branch -> "desc").executeQuery()

}

How to run stored procedure in Anorm


回答1:


this works for me

SQL("call  test123 ({id},{name},{branch})").
          on('id -> 21,
            'name -> "lcs",
            'branch -> "desc").executeUpdate()

}


来源:https://stackoverflow.com/questions/35740465/anorm-mysql-stored-procedure-calling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!