camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Tarocchi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-11716) error in handling return parameters in db functions
Date Mon, 28 Aug 2017 15:55:00 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-11716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16143929#comment-16143929
] 

Andrea Tarocchi commented on CAMEL-11716:
-----------------------------------------

Created a PR for this: https://github.com/apache/camel/pull/1902

> error in handling return parameters in db functions
> ---------------------------------------------------
>
>                 Key: CAMEL-11716
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11716
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-sql
>            Reporter: Andrea Tarocchi
>
> Let's consider for instance the following db function:
> {code}
> create or replace function sum_two_numbers_function
>   (a in number, b in number)
> return number deterministic is
> begin
>  return a + b;
> end;
> {code}
> One might think to run this camel route in order to call the mentioned db function:
> {code}
> sql-store:sum_two_numbers_function(INTEGER ${body[0]}, INTEGER ${body[1]})?function=true
> {code}
> but SqlCall build incorect query:
> {code}
> ? = call sum_two_numbers_function(?)
> {code}
> which fail on wrong number of arguments. After an investigation is found out that first
parameter was skipped for function calls.
> https://github.com/spring-projects/spring-framework/blob/v4.3.3.RELEASE/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlCall.java#L135
> So one might try to add one parameter which should be used as output for return statement.
But the only valid format of parameter (for db functions) seems to be {{InputParameter}} which
is not possible to use as output for result.
> {code}
> sql-store:sum_two_numbers_function(INTEGER ${body[2]}, INTEGER ${body[0]}, INTEGER ${body[1]})?function=true
> {code}
> If {{OutputParameter}} are used than this https://github.com/apache/camel/blob/master/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/TemplateStoredProcedure.java#L77
will force to create SQL procedure call (instead of a function one), for instance this:
> {code}
> sql-store:sum_two_numbers_function(OUT INTEGER result, INTEGER ${body[0]}, INTEGER ${body[1]})?function=true
> {code}
> results in this query call:
> {code}
> call sum_two_numbers_function(?, ?, ?)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message