Setting schema name of a IDBTable

I am tring to import various tables and its related info to a diagram inspired by your sample Create Entity-Relationship Diagram Using Open API - Visual Paradigm Know-how
, but could not find a way to set the schema name of a IDBTable ,which is already defined in the lookup as below

The API scripts is as follows, but unfortunately , the schema of the table “tableRetailCenter” can not be set to “schema2”

    //Create the table
    IDBTable tableRetailCenter = IModelElementFactory.instance().createDBTable();
    tableRetailCenter.setName("Retail Center");

    IDBSchemaLookup sch = IModelElementFactory.instance().createDBSchemaLookup();

I tried to get the lookup list (as in screen shot , schema,schema2,schema3 ) by using IDBLookupContainer and then set one of them to tables schema but it did not work too, because I get empty IDBSchemaLookup array “schs”.

IDBLookupContainer lkp =IModelElementFactory.instance().createDBLookupContainer();
IDBSchemaLookup[] schs= lkp.toDBSchemaLookupArray();

Your advice and guidance is greatly appreciated.

Hi Seyhmus,

Thank you for your post. Your question has been forwarded to our team. When there is an answer, I will let you know.

Best regards,
Jick Yeung

Hi Jick,

While we get answer from you I tried further with the script below but still no luck

    //Create table for retail centers
    IDBTable tableRetailCenter = IModelElementFactory.instance().createDBTable();
    tableRetailCenter.setName("Retail Center");
    String lSpecifiedModelType_schema = IModelElementFactory.MODEL_TYPE_DB_TABLE;
    IModelElement[] lschemalookups = lProject.toAllLevelModelElementArray(IModelElementFactory.MODEL_TYPE_DB_SCHEMA_LOOKUP);
    if (lschemalookups != null) {
        for (IModelElement lschemalookup : lschemalookups) {
            ApplicationManager.instance().getViewManager().showMessage("schema:" + lschemalookup.getName() );
            IDBSchemaLookup sch =(IDBSchemaLookup) lschemalookup;
            if (sch.getName().equals("schema2") ){


Sorry for not getting back to you sooner. I have updated the report I sent to our team by including your latest code sample.

Hi Seyhmus,

You may try the code below:

        final String tableName = "Retail Center";
        final String schemaName = "schema2";
        com.vp.plugin.model.IProject project = com.vp.plugin.ApplicationManager.instance().getProjectManager().getProject();
        com.vp.plugin.model.IDBTable table = com.vp.plugin.model.factory.IModelElementFactory.instance().createDBTable();
        com.vp.plugin.model.IDBLookupContainer lookupContainer = null;
        Iterator lookupContainerIterator = project.modelElementIterator(com.vp.plugin.model.factory.IModelElementFactory.MODEL_TYPE_DB_LOOKUP_CONTAINER);
        if (lookupContainerIterator != null && lookupContainerIterator.hasNext()) {
            lookupContainer = (com.vp.plugin.model.IDBLookupContainer);
        } else {
            lookupContainer = com.vp.plugin.model.factory.IModelElementFactory.instance().createDBLookupContainer();
        com.vp.plugin.model.IDBSchemaLookup schemalookup = (com.vp.plugin.model.IDBSchemaLookup) lookupContainer.getChildByName(com.vp.plugin.model.factory.IModelElementFactory.MODEL_TYPE_DB_SCHEMA_LOOKUP, schemaName);
        if (schemalookup == null) {
            schemalookup = lookupContainer.createDBSchemaLookup();

Best regards,
Jick Yeung


(post deleted by author)

Hello Jick
That worked . Thank you very much. :pray: