Toad World® Forums

Creating Indexes via Macro


#1

Is there a way to create indexes (or attributes, etc.) using a macro? I want to create indexes for every FK in each table and have them named properly. I have gotten several rename macros to work well but not sure how to go about creating new things in the model. Thanks.


#2

Hi,

at the following page you can find a script that creates index for autoincrement attributes:
http://modeling.inside.quest.com/entry.jspa?externalID=2245&categoryID=35

You can use it for inspiration.

Extract from the script where you can see how to create new index via script:

Index = Entity.CreateNewObject( 2012 );
//Create new Index (2012 is object type of PERIndex)
Index.Name = IndexName;
IndexItem = Index.CreateNewObject( 2013 );
//Create new Item of Index (2013 is object type of PERIndexItem)
IndexItem.Attribute = Attribute;

Feel free to write me back in case you need my help with modifications.

Regards,

Vaclav