How to call a stored procedure from Mule 3.5 with a new database endpoint

I tested the new Mule Mule 3.5 database connector with the stored procedure ... (Link: - http://www.mulesoft.org/documentation/display/current/Database+Connector ) .. I had the following stored procedure: -

ALTER PROCEDURE [dbo].[sp_retrieveData]
 @Id  int
AS
Select * from getData Where ID = @Id

Which works fine in the old JDBC Mule connector ... I used to call the stored procedure from the JDBC endpoint using the following syntax: - <jdbc-ee:query key="RetriveQuery" value="CALL sp_retrieveData(${Id})"/>that worked fine ... But now the problem in Mule 3.5 is the new database endpoint I cannot call that same stored procedure ... My Mule configuration: -

<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
   <db:parameterized-query><![CDATA[CALL sp_retrieveData(58)]]></db:parameterized-query>
   <db:in-param name="Id" type="INTEGER" value="58"/>
  </db:stored-procedure>

, : ... - ?... , ...

: - : -

Exception stack is:
1. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException)
  com.microsoft.sqlserver.jdbc.SQLServerException:170 (null)
2. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.db.internal.processor.AbstractDbMessageProcessor:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:698)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:928)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
+4
2

- - - . : https://github.com/mulesoft/mule/tree/mule-3.5.0/modules/db/src/test/resources/integration/storedprocedure

, :

<db:stored-procedure config-ref="Generic_Database_Configuration">
  <db:parameterized-query>{ call sp_retrieveData(:Id) }</db:parameterized-query>
  <db:in-param name="Id" value="58" />
</db:stored-procedure>

( )

+14

:

<db:stored-procedure config-ref="Oracle_Configuration1" doc:name="Database">
    <db:parameterized-query><![CDATA[
    {
      call apps.create_sales_Order(:p_header_rec_oper, :P_order_number, :P_ordered_date, :P_line_id, :p_flow_Status_code, :P_return_status)
    }
    ]]>
    </db:parameterized-query>
    <db:in-param name="p_header_rec_oper" value="CREATE"/>
    <db:out-param name="P_order_number" type="INTEGER"/>
    <db:out-param name="P_ordered_date" type="DATE"/>
    <db:out-param name="P_line_id" type="VARCHAR"/>
    <db:out-param name="p_flow_Status_code" type="VARCHAR"/>
    <db:out-param name="P_return_status" type="VARCHAR"/>
</db:stored-procedure>
+2

Source: https://habr.com/ru/post/1543883/


All Articles