%META:TOPICPARENT{name="VirtDB2EntityFrameworkUsage"}%

===Linking Tables from DB2 into Virtuoso===

1. Start the Virtuoso Web User Interface.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtWebHome.png" style="wikiautogen"/>%BR%%BR%

2. Select the **Conductor** link in the left frame and login as the **dba** user.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtConductor.png" style="wikiautogen"/>%BR%%BR%

3. Select the **Databases** -> **External Data Source** -> **Data Sources** tab menu items.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB21.png" style="wikiautogen"/>%BR%%BR%

4. Select the **Connect** button for the **db2v8ma** DB2 DSN.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB22.png" style="wikiautogen"/>%BR%%BR%

5. On succesful connection, select the **Link Objects** button to obtain a list of available tables.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB23.png" style="wikiautogen"/>%BR%%BR%

6. Select the tables that you would like to link.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB24.png" style="wikiautogen"/>%BR%%BR%

7. Change the Catalog for each table to be **SAMPLE** using the **Set All** button.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB25.png" style="wikiautogen"/>%BR%%BR%

8. All the catalog names are changed to be **SAMPLE**.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB6.png" style="wikiautogen"/>%BR%%BR%

9. Select the **Link** button to link the selected tables into Virtuoso.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB29.png" style="wikiautogen"/>%BR%%BR%

10. On completion of the Link process, the tables will be displayed in the **External Linked Objects** tab.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB27.png" style="wikiautogen"/>%BR%%BR%

11. The linked tables can be queried by clicking on the hyperlink in the **Local Name** column of the **External Linked Objects** tab above. This loads the Virtuoso **Interactive SQL** interface with the required SQL **Select** for retrieving the remote table data . We shall use the **SAMPLE.db2v8ma.EMPLOYEE** table to demonstrate this.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB29.png" style="wikiautogen"/>%BR%%BR%
   
12.  Click the **Execute** button to run the query and retrieve the results from the remote table.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB210.png" style="wikiautogen"/>%BR%%BR%
   
13.  The tables can also be viewed as part of the Virtuoso **SQL Schema Objects** under the **SAMPLE** catalog name.
%BR%%BR%<img src="%ATTACHURLPATH%/VirtLinkDB28.png" style="wikiautogen"/>%BR%%BR%

The Link process is now complete enabling the tables to be queried as if part of the Virtuoso Schema.