Toad World® Forums

Application Variable Does Not Work in Using Index

Application Variables in Key Properties’ “Name of Using Index” does not resolve to the actual value of the application variable.

For example

IU_<%OwnerName%>

Generates the following SQL

ALTER TABLE Entity1 ADD CONSTRAINT PK_Entity1 PRIMARY KEY (my_key) 
USING INDEX IU_<%OwnerName%>

Rather than

ALTER TABLE Entity1 ADD CONSTRAINT PK_Entity1 PRIMARY KEY (my_key) 
USING INDEX IU_Entity1

Is there a setting or option that I'm missing that allows the user to use application variables in the USING INDEX? Or can you confirm this is a bug? If so, is there macro/script workaround?

Using TDM 7.1.0.216 On Windows 10 Enterprise Version 1809 OS build 17763.914.

Hello,
Using index property in Key is not supports A.V. at this time. As work around I can provide you macro code that set this property to IU_<%OwnerName%>. So you need run this macro before run Generate SQL code. You can place some condition before set to define keys for set.

function Main(){
  var App = System.GetInterface("Application");
  var Model = App.ActiveModel;  
  var Log = System.CreateObject("Log");    
                                    
  var i, j, Ent, Key;
  for(i=0;i<Model.Entities.Count;i++)
  {
    Ent = Model.Entities.GetObject(i);
    for(j=0;j<Ent.Keys.Count;j++)
    {
      Key = Ent.Keys.GetObject(j);
//Here you can place some condition
      Key.UsingIXName = Key.Resolve('IU_<%OwnerName%>');
    }    
  }  
}

let me know if you need any assistance with this macro

Regard
Daril