Skip to Main Content

SQL Developer Data Modeler

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

usage of template table

User_IC3C9Jan 22 2018 — edited Jan 22 2018

Using the template table i am able to add common columns but not in the right order defined in the template table.

pastedImage_0.png

What changes I need to make in this template script to full fill my requirement.

// columns are found by column name

// allowing reuse of already existing columns

// dynamic property ctemplateID is set afterwards - will keep connection to template

// column even if the name of column is changed

var t_name = "table_template";

var p_name = "ctemplateID";

template = model.getTableSet().getByName(t_name);

if(template!=null){

tcolumns = template.getElements();

tables = model.getTableSet().toArray();

for (var t = 0; t\<tables.length;t++){

 table = tables\[t\];

// compare name ignoring the case

 if(!table.getName().equalsIgnoreCase(t\_name)){

     for (var i = 0; i \< tcolumns.length; i++) {

        column = tcolumns\[i\];

        col = table.getElementByName(column.getName());

        if(col==null){

         col = table.getColumnByProperty(p\_name,column.getObjectID());

        }

        if(col==null){

         col = table.createColumn();

        }

        column.copy(col);

        //set property after copy otherwise it'll be cleared by copy

        col.setProperty(p\_name,column.getObjectID());

        table.setDirty(true);

     }

 }

}

}

This post has been answered by Dave Schleis on Jan 22 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2018
Added on Jan 22 2018
3 comments
709 views