This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit ff245e12bd1b8a29e3a963a42dbf422de0ba03c0 Author: Brett Meyer <br...@3riverdev.com> AuthorDate: Thu Feb 8 23:52:09 2018 -0500 CAMEL-12212 sql-stored: support INOUT parameters (docs) --- .../src/main/docs/sql-stored-component.adoc | 57 ++++++++++++++-------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/components/camel-sql/src/main/docs/sql-stored-component.adoc b/components/camel-sql/src/main/docs/sql-stored-component.adoc index 664ea9a..19b4e59 100644 --- a/components/camel-sql/src/main/docs/sql-stored-component.adoc +++ b/components/camel-sql/src/main/docs/sql-stored-component.adoc @@ -34,7 +34,7 @@ sql-stored:template[?options] ----------------------------- Where template is the stored procedure template, where you declare the -name of the stored procedure and the IN and OUT arguments. +name of the stored procedure and the IN, INOUT, and OUT arguments. You can also refer to the template in a external file on the file system or classpath such as: @@ -52,7 +52,8 @@ template, as show: SUBNUMBERS( INTEGER ${headers.num1}, INTEGER ${headers.num2}, - OUT INTEGER resultofsub + INOUT INTEGER ${headers.num3} out1, + OUT INTEGER out2 ) -------------------------- @@ -119,27 +120,31 @@ method signature. The name of the stored procedure, and then the arguments enclosed in parenthesis. An example explains this well: [source,java] ----------------------------------------------------------------------------------------------------------- -<to uri="sql-stored:SUBNUMBERS(INTEGER ${headers.num1},INTEGER ${headers.num2},OUT INTEGER resultofsub)"/> ----------------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------------------------------------------------- +<to uri="sql-stored:STOREDSAMPLE(INTEGER ${headers.num1},INTEGER ${headers.num2},INOUT INTEGER ${headers.num3} result1,OUT INTEGER result2)"/> +---------------------------------------------------------------------------------------------------------------------------------------------- -The arguments is declared by a type and then the mapping to the Camel -message using simple expression. So in this example the first two -parameters are IN values that are INTEGER type, that maps to the message -headers. The last parameter is the OUT value, also an INTEGER type. +The arguments are declared by a type and then a mapping to the Camel +message using simple expression. So, in this example the first two +parameters are IN values of INTEGER type, mapped to the message +headers. The third parameter is INOUT, meaning it accepts an INTEGER +and then returns a different INTEGER result. The last parameter is +the OUT value, also an INTEGER type. In SQL term the stored procedure could be declared as: [source,java] ------------------------------------------------------------------------------- -CREATE PROCEDURE SUBNUMBERS(VALUE1 INTEGER, VALUE2 INTEGER,OUT RESULT INTEGER) ------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------------------------- +CREATE PROCEDURE STOREDSAMPLE(VALUE1 INTEGER, VALUE2 INTEGER, INOUT RESULT1 INTEGER, OUT RESULT2 INTEGER) +--------------------------------------------------------------------------------------------------------- + +#### IN Parameters -IN parameters take four parts separated by a space: parameter name, SQL type(with scale), type name and value source. +IN parameters take four parts separated by a space: parameter name, SQL type (with scale), type name and value source. Parameter name is optional and will be auto generated if not provided. It must be given between quotes('). -SQL type is required and can be a integer(positive or negative) or reference to integer field in some class. +SQL type is required and can be an integer (positive or negative) or reference to integer field in some class. If SQL type contains a dot then component tries resolve that class and read the given field. For example SQL type com.Foo.INTEGER is read from the field INTEGER of class com.Foo. If the type doesn't contain comma then class to resolve the integer value will be java.sql.Types. @@ -147,7 +152,7 @@ Type can be postfixed by scale for example DECIMAL(10) would mean java.sql.Types Type name is optional and must be given between quotes('). -Value source is required. Value source populates parameter value from the Exchange. +Value source is required. Value source populates the parameter value from the Exchange. It can be either a Simple expression or header location i.e. :#<header name>. For example Simple expression ${header.val} would mean that parameter value will be read from the header "val". Header location expression :#val would have identical effect. @@ -168,13 +173,15 @@ URI is identical to previous on except SQL-type is 100 and type name is "mytypen Actual call will be done using org.springframework.jdbc.core.SqlParameter. -OUT parameters work same way as IN parameters and they they contain three parts: SQL type(with scale), type name and output parameter name. +#### OUT Parameters -SQL type works as in IN parameters. +OUT parameters work similarly IN parameters and contain three parts: SQL type(with scale), type name and output parameter name. -Type name is optional and work as in IN parameters. +SQL type works the same as IN parameters. -Output parameter name is used for the e OUT parameter name and header where the result will be stored there also. +Type name is optional and also works the same as IN parameters. + +Output parameter name is used for the OUT parameter name, as well as the header name where the result will be stored. [source,java] ---------------------------------------------------------------------------------------------------------- @@ -190,6 +197,18 @@ This is identical to previous one but type name will be "mytype". Actual call will be done using org.springframework.jdbc.core.SqlOutParameter. +#### INOUT Parameters + +INOUT parameters are a combination of all of the above. They receive a value from the exchange, as well as store a +result as a message header. The only caveat is that the IN parameter's "name" is skipped. Instead, the OUT +parameter's "name" defines both the SQL parameter name, as well as the result header name. + +[source,java] +---------------------------------------------------------------------------------------------------------- +<to uri="sql-stored:MYFUNC(INOUT DECIMAL(10) ${headers.inheader} outheader)"/> +---------------------------------------------------------------------------------------------------------- + +Actual call will be done using org.springframework.jdbc.core.SqlInOutParameter. ### Camel Sql Starter -- To stop receiving notification emails like this one, please contact davscl...@apache.org.