Contact Free trial Login

Execute Stored Procedures - Mule 4

Invoke stored procedures that combine, input, output, and input-output parameters.

For example:

<!-- Invoke a procedure with input parameters -->
<db:stored-procedure config-ref="dbConfig">
    <db:sql>{ call updatePlanetDescription('Venus', :description) }</db:sql>
        #[{'description' : payload}]

<!-- Invoke a procedure with input-output parameters -->
<db:stored-procedure config-ref="dbConfig">
  <db:sql>{ call doubleMyInt(:myInt) }</db:sql>
      <db:in-out-parameter key="myInt" value="3"/>

<!-- Invoke a procedure with both input AND output parameters -->
<db:stored-procedure config-ref="dbConfig">
    <db:sql>{ call multiplyInts(:int1, :int2, :result1, :int3, :result2) }</db:sql>
            'int1' : 3,
            'int2' : 4,
            'int3' : 5
        <db:output-parameter key="result1" type="INTEGER"/>
        <db:output-parameter key="result2" type="INTEGER"/>
        <db:output-parameter key="myInt" type="INTEGER"/>

Many combinations are possible.

After execution, the resulting values of the output and input-output parameters are available in the operation’s result. Leverage DataSense to help you get them.
For connector version 1.4.0 or later, make sure that no whitespace is between the name of the stored procedure and the first parentheses.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub