简体   繁体   English

如何在Anorm中称呼具有IN和OUT参数的“程序”

[英]How can I call “Procedures” having IN and OUT params in Anorm

In my Play (Scala) application I need to call procedures having IN and OUT params. 在我的Play(Scala)应用程序中,我需要调用具有IN和OUT参数的过程。 Can't find any example anywhere !! 在任何地方都找不到任何示例! I am using Play 2.5x (DB is Oracle). 我正在使用Play 2.5x(DB是Oracle)。

Seems there is no mechanism to use Anorm for accessing OUT param of stored procedure. 似乎没有机制可以使用Anorm访问存储过程的OUT参数。 On the other hand the connection object can be used directly and the stored procedure can be called using Java libraries. 另一方面,可以直接使用连接对象,并且可以使用Java库来调用存储过程。 Refer below example code: 请参考以下示例代码:

dbch.dbprod.withConnection { implicit connection =>
    val cs: CallableStatement = connection.prepareCall("{call MY_STORED_PROC(?)}")
    cs.registerOutParameter(1, Types.VARCHAR)
    cs.execute()
    val result = cs.getString(1)
    ....
}

Also refer link: https://docs.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html . 另请参阅链接: https : //docs.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html

Thanks to the hint provided on Play gitter channel. 多亏了Play gitter频道上提供的提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM