简体   繁体   English

获取存储过程camel-sql的输出参数

[英]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.

相关问题 骆驼-使用useMessageBodyForSql的骆驼SQL批处理插入 - Camel - camel-sql batch insert using useMessageBodyForSql 从SQL Server存储过程中获取输出参数和ResultSet值 - get both output parameter and ResultSet values from SQL Server stored procedure 骆驼sql存储的java,不能输入数组作为oracle存储过程的输入参数 - camel sql-stored java, cannot enter array as an input parameter for oracle stored-procedure SQL Server存储过程的输出参数被截断为4000个字符 - Output parameter from SQL Server stored procedure truncated at 4000 characters 如何获取作为数组的存储过程输出参数? - How do I get a stored procedure output parameter that is an array to work? 如何在SQLServer中获取存储过程sp_setapprole的OUTPUT参数 - How to get OUTPUT parameter of stored procedure sp_setapprole in SQLServer 从存储过程中获取 Output 参数而不调用 execute() - Get Output parameter from stored procedure without calling execute() 如何在 Java 中获取 SQL 服务器存储过程的 output - How to get output of an SQL Server stored procedure in Java 如何从休眠中的存储过程中获取OUTPUT值(SQL SERVER) - How to get OUTPUT value from stored procedure in hibernate (SQL SERVER) MsSql 中的存储过程期望输出参数作为输入 - Stored Procedure in MsSql expecting output parameter as input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM