# How to list all tables, columns, and column types of an Entity Relationship Diagram

**URL:** <https://forums.visual-paradigm.com/t/how-to-list-all-tables-columns-and-column-types-of-an-entity-relationship-diagram/12491>\
**Category:** Plug-in & Open API\
**Created:** [December 30, 2013, 6:37am UTC](https://forums.visual-paradigm.com/t/how-to-list-all-tables-columns-and-column-types-of-an-entity-relationship-diagram/12491 "2013-12-30T06:37:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adele](https://avatars.discourse-cdn.com/v2/letter/a/e56c9b/32.png) [@Adele](https://forums.visual-paradigm.com/u/Adele)\
**Post date:** [December 31, 2013, 9:28am UTC](https://forums.visual-paradigm.com/t/how-to-list-all-tables-columns-and-column-types-of-an-entity-relationship-diagram/12491/1 "2013-12-31T09:28:29Z")

</div>

Hi,  
I am trying to develop a VP plugin:

- I have draw a "Entity Relationship Diagram "wich contains some tables like Customers and Employees…
- I have read some tutorial about developing plugin but I cannot find a solution for my problem.

My problem is that for my plugin I need to list the tables, their columns and the type of the columns. Here my code:

```auto

      Iterator modelElementIterator = project.modelElementIterator("DBTable");
      IDBTable dbTable = null; 
      IDBColumn dbColumn = null; 
      
 try{
     
     viewManager.showMessage("Utilitaire de génération de fichier .vb à partir du modèle MCD");
     viewManager.showMessage(" ________________________________________________________________________");
     
     IModelElement[] dbTables = project.toModelElementArray("DBTable"); 
     for(int i = 0; i <= dbTables.length; i++){
    // IModelElement otherModel = (IModelElement) tablesAtRoot[j]; 
         Object object = dbTables[i]; 
         
         if(object instanceof IDBTable){
             dbTable = (IDBTable) object;  
             viewManager.showMessage("Table name is : " + dbTable.getName());
             IDBColumn[] columns = dbTable.toDBColumnArray() ;
             for(int k = 0; k <= columns.length ; k++){
                 Object object2 = columns[k];
                 
                 if(object2 instanceof IDBColumn){
                     dbColumn = (IDBColumn) object2;
                     viewManager.showMessage("===> Column name is : " + dbColumn.getName());
                     viewManager.showMessage("===> Column type is : " + dbColumn.getModelType().toString()); 
                     
                    // model type = DBColumn
                     
                     // But I want to list the type of the column as "Varchar2, Int, Date...
                     // And after that I want to cast for example "Varchar2 to String"... 
                 }// End for1
             }
         }
     }// End for2

```

When executing this code the view manager on VP show me only the data for one Table:

Table name is : Clients  
===\> Column name is : Client\_Id  
===\> Column type is : DBColumn  
===\> Column name is : Addresse  
===\> Column type is : DBColumn  
===\> Column name is : Registration\_Date  
===\> Column type is : DBColumn

And executing the code whitout the “Colums” loop it list me all the table names, consequently I cannot see the error.  
Can someone help me?

Thank you in advance
