Unify DB Query for Multiple Mapping Japraj Romana June 06, 2016 15:41 Updated Situation: 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. Solution: 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:- Create a XSL template using scope Global in the mapping. In the mapping XSL create a variable for DB connection info. Create a variable for Database query. 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="'<<Select Query to fetch Records from DB>>'"/> <!-- 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--></xsl:template> Use the template on any element by selecting from global keyword in mapping. Related articles Fetch multiple columns by using DB query function How to create SQL Query in order to avoid complexity and unwanted errors. Pick up last occurrence of duplicate record Video: Data Mapping Function Call Stored Procedure Setting multiple context variable in parent flow Comments 0 comments Article is closed for comments.