[英]Get output parameter of a stored procedure camel-sql
I'm writing some routes using camel and running them in JBoss Fuse 6.2. 我正在使用骆驼编写一些路线,并在JBoss Fuse 6.2中运行它们。
I want to execute a stored procedure in a SQL Server database and read the value of a output parameter. 我想在SQL Server数据库中执行存储过程,并读取输出参数的值。
I'm making this: 我正在做这个:
from("direct:WRITE_IN_STORED_PROCEDURE")
.to("sql:exec PROCEDIMIENTO_TEST 'TEST_DATA'?dataSource=dataSource")
.log(LoggingLevel.INFO, "[${body}]");
This route actually WRITE in the database, I checked and the value 'TEST_DATA' is in the database according to the stored procedure logic. 我检查了该路由,实际上在数据库中写了,根据存储过程逻辑,值“ TEST_DATA”在数据库中。
The problem is: I have no idea how to pass and how to read an OUT parameter. 问题是:我不知道如何传递以及如何读取OUT参数。 The "exec" call is not putting the result of the procedure in the body (like when I use "select").
“ exec”调用不会将过程的结果放入正文中(就像我使用“ select”时一样)。
What must i do? 我必须做什么?
Thanks! 谢谢!
The sql component do not yet support stored procedures. sql组件尚不支持存储过程。
There is a ticket: https://issues.apache.org/jira/browse/CAMEL-4725 有票: https : //issues.apache.org/jira/browse/CAMEL-4725
And there is code in the works: https://github.com/apache/camel/pull/749 在工作中有代码: https : //github.com/apache/camel/pull/749
You can for example instead use the mybatis component as mybatis supports calling stored procedures: http://camel.apache.org/mybatis 例如,您可以改为使用mybatis组件,因为mybatis支持调用存储过程: http : //camel.apache.org/mybatis
the syntax should be exactly similar to the call as would make from db : mysql below 语法应该与从db进行的调用完全相似:
mysql>delimiter //
mysql>create procedure selectusers(out param1 int) begin select count(*)
from mysql.user; end//
mysql> delimiter ;
mysql> call selectusers(@param1);
+----------+
| count(*) |
+----------+
| 2 |
+----------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Similarly from camel your route would now look like below 同样,从骆驼出发,您的路线现在如下所示
<to uri="sql:exec call selectusers(@param1)?datasource=datasource/>
The result if you print would be as below
[) thread #0 - file://src/data/] rhalling-unmarshalling-exmaple INFO [{count(*)=2}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.