Search code examples
mysqlscalastored-proceduresplayframeworkanorm

Anorm Mysql Stored Procedure calling


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


Solution

  • this works for me

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