Advanced Customization > Info*Engine User’s Guide > Info*Engine Data Management > Managing and Manipulating Groups with Info*Engine > Manipulating Several Groups and Displaying the Resulting Group
  
Manipulating Several Groups and Displaying the Resulting Group
Expanding on the employee example described previously, this scenario demonstrates how to obtain a single list of employees from two distinct departments. The following example combines the employees from the sales department and the development department of your company. Assume that each department has their employee lists in different locations of a database at the company. This scenario gets employee information from both locations and combines it in such a way that it looks like one list of employees.
First, author a JSP page to query a database for information about employees. You can start with the task webject similar to the one shown previously in Basic Group Creation and Display. This task webject looks for those employees defined in the “salesemp” table. Now, you can add another webject that queries for information from the “devemp” table. For example, the page could contain query webjects similar to the following:
<ie:webject name="Query-Objects" type="OBJ">
  <ie:param name="INSTANCE"  data="com.myHost.Adapter"/>
  <ie:param name="CLASS"     data="salesemp"/>
  <ie:param name="WHERE"     data="()"/>
  <ie:param name="GROUP_OUT" data="sales"/>
</ie:webject>

<ie:webject name="Query-Objects" type="OBJ">
  <ie:param name="INSTANCE"  data="com.myHost.Adapter"/>
  <ie:param name="CLASS"     data="devemp"/>
  <ie:param name="WHERE"     data="()"/>
  <ie:param name="GROUP_OUT" data="development"/>
</ie:webject>
The first Query-Objects webject asks for information about employees from the sales employee database table (using the “salesemp” table name in the CLASS parameter). Specifically, it asks for information about all of the employees in the sales department. The results of the query are then placed in the VDB in a group called “sales”. You can think of the sales group in terms of the following table:
ename
phone
department
title
Burton, Jack
873-2302
Sales
Sales Representative
Law, Gracie
873-2200
Sales
Sales Manager
LoPan, David
873-3313
Sales
Administrative Assistant
The second Query-Objects webject also asks for information from the database, but this time the information comes from the development employee table (using the “devemp” table name in the CLASS parameter). The results of this second query are then placed in the VDB in a group called “development”. You can think of the development group in terms of the following table:
ename
phone
department
title
Anderson, Pat
873-2428
Development
Engineer
Stein, Chris
873-2608
Development
Manager
Wong, May
873-2741
Development
Engineer
Now there are two groups in the VDB, one called “sales” and one called “development”. The scenario is not yet complete because we want to combine the two groups into one list of employees. To combine the groups, you can add the following Merge-Groups webject to the JSP page:
<ie:webject name="Merge-Groups" type="GRP">
  <ie:param name="GROUP_IN"  data="sales"/>
  <ie:param name="GROUP_IN"  data="development"/>
  <ie:param name="SORTED"    data="ASC"/>
  <ie:param name="SORTBY"    data="ename"/>
  <ie:param name="GROUP_OUT" data="employees"/>
</ie:webject>
This webject takes the sales and development groups and merges the information into one large group using the employee name from the “ename” attribute as a guide. All of the information is sorted in ascending order based on the employee name. The results of the merged information are then placed in a third group called “employees”. This final group is then placed in the VDB for later use.
To view the employee information that is stored in the employees group, you can use a display webject that is similar to the scenario used in the Basic Group Creation and Display:
<ie:webject name="Display-Table" type="DSP">
  <ie:param name="GROUP_IN"  data="employees"/>
  <ie:param name="BORDER"    data="1"/>
  <ie:param name="ATTRIBUTE"
            data="ename,department,phone,title" delim=","/>
  <ie:param name="HEADER"
            data="Name,Department,Telephone,Title" delim=","/>
</ie:webject>
The resulting display is the following table that contains the employees from both the sales and development departments. The display includes the department attribute, which had been left out in the earlier scenario: