Unify DB Query for Multiple Mapping


We need to use centralized DB Query for multiple mappings. Also, we would like to contain that query in one location and have the maps call the query and fetch the records.


We can achieve this requirement by defining the global template in mapping. By using global template we can use same query in multiple mapping as template will be shown on every mapping. Below are the steps to create the global template:-

  1. Create a XSL template using scope Global in the mapping.
  2. In the mapping XSL create a variable for DB connection info.
  3. Create a variable for Database query.
  4. Use this code in XSL template
<xsl:template name="DBQUERYHANDLE">
     <!-- template code starts-->
     <!-- DBConnection Info for the Database-->
 <xsl:variable name="VarConnection_Global" select="'192168001124146415593208100002'"/>
  <!-- Query to fetch data from the Database-->
<xsl:variable name="varquery" select="&apos;<<Select Query to fetch Records from DB>>&apos;"/>
 <!-- Variable Database query-->
<xsl:variable name="VarDBQuery" select="globalMethod:DBQuery($varConn,$_class,$_identifier,$_subject,$varquery,$VarConnection_Global,'true')" xmlns:globalMethod="java:com.adeptia.indigo.services.mapping.support.dbquery.MapperQueryExecutor"/>
 <!-- Use of Template to fetch data from database-->
 <xsl:value-of select="$VarDBQuery"/>
    <!-- template code ends-->
  1. Use the template on any element by selecting from global keyword in mapping.



Have more questions? Submit a request


Article is closed for comments.