이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 166. SQL Stored Procedure


SQL Stored Procedure Component

Available as of Camel 2.17
The sql-stored: component allows you to work with databases using JDBC Stored Procedure queries. This component is an extension to the SQL Component but specialized for calling stored procedures.
This component uses spring-jdbc behind the scenes for the actual SQL handling.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-sql</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap

URI format

The SQL component uses the following endpoint URI notation:
sql-stored:template[?options]
Copy to Clipboard Toggle word wrap
Where template is the stored procedure template, where you declare the name of the stored procedure and the IN and OUT arguments.
You can also refer to the template in a external file on the file system or classpath such as:
sql-stored:classpath:sql/myprocedure.sql[?options]
Copy to Clipboard Toggle word wrap
Where sql/myprocedure.sql is a plain text file in the classpath with the template, as show:
SUBNUMBERS(
  INTEGER ${headers.num1},
  INTEGER ${headers.num2},
  OUT INTEGER resultofsub
)
Copy to Clipboard Toggle word wrap
You can append query options to the URI in the following format, ?option=value&option=value&...

Options

Expand
Option
Type
Default
Description
batch
boolean
false
Enables or disables batch mode
dataSource
string
Reference to a DataSource to look up in the registry.
noop
boolean
false
If set will ignore the results of the template and use the existing IN message as the OUT message for the continuation of processing
outputHeader string Store the template result in a header instead of the message body. By default outputHeader == null and the template result is stored in the message body any existing content in the message body is discarded. If outputHeader is set the value is used as the name of the header to store the template result and the original message body is preserved.
useMessageBodyForTemplate boolean false Whether to use the message body as the template and then headers for parameters. If this option is enabled then the template in the uri is not used.

Declaring the stored procedure template

The template is declared using a syntax that would be similar to a Java method signature. The name of the stored procedure, and then the arguments enclosed in parenthesis. An example explains this well:
<to uri="sql-stored:SUBNUMBERS(INTEGER ${headers.num1},INTEGER ${headers.num2},OUT INTEGER resultofsub)"/>
Copy to Clipboard Toggle word wrap
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.
In SQL term the stored procedure could be declared as:
CREATE PROCEDURE SUBNUMBERS(VALUE1 INTEGER, VALUE2 INTEGER,OUT RESULT INTEGER)
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat