Getting started Community Training Tutorials Documentation APIs, AI & Tools
<!-- Local Database Configuration -->
<db:config name="Database_Config">
<db:my-sql-connection host="localhost" port="1234" />
</db:config>
<!-- Properties according to the environment -->
<configuration-properties file="db.properties" />
<flow name="selectFlow" >
<!-- Perform a query based on a value passed by a variable -->
<db:select config-ref="${db.config}">
<db:sql >SELECT * FROM jobtitlelookup WHERE jobtitleid = :id</db:sql>
<db:input-parameters ><![CDATA[#[id : vars.jobid]]]></db:input-parameters>
</db:select>
<!-- Set two conditions depending on the query result -->
<choice>
<!-- If there is one or more values resulting from the query set those values as the payload -->
<when expression="#[sizeOf(payload) > 0]">
<set-payload value="#[payload[0].jobtitle]"/>
</when>
<!-- If the query throws no results, inform it in the payload -->
<otherwise>
<set-payload value="#['No job title for $(vars.jobid) was found']" />
</otherwise>
</choice>
<!-- Finally, pass the payload content as a Flow variable -->
<set-variable value="#[payload]" variableName="job" />
</flow>



