Toad World® Forums

Error During Synch


#1

I did a synch model to DB, and it generated an error while trying to create the script.


#2

It generated that error about 6 or so times. It did successfully open the script file in TOAD (Yay!).

I had only selected one table to compare, to try to minimize what needed to be done, and to make it easier for me to evaluate the generated script. For some reason, it appears to have compared the entire DB. It generated an 8,900 line script file for one table! That table does have some FK’s on it, but not enough to warrant rebuilding the entire DB.


#3

If it helpds, here is the TDM script file that popped up in TDM:

//******************************************************************************
// Pravidlo pro alter script pro PEREntitu z MS08 do MS08
//******************************************************************************

function CreateEntity( Node, AlterModel1, OtherName, arrParam )
{
var Result = “”;
var Indexes, Keys, Triggers, Attributes, i, Key, KeyNode, Index, IndexNode;
var Check, CheckSQL, a, Attr, flagFirst, CheckAttrDom;
var ObjectConversion = Node.GetMainObjectConversion();
var SO = ObjectConversion.SourceObj( !AlterModel1 );
var DCGenerator = SO.Root().DefaultCodeGenerator;
var RowedTerminator = DCGenerator.RowedTerminator;
var Entity = SO;
var Attribute, TypeNode, TypeTempName;
var arrAttrChangedUDTName = new Array();

//changed name of appropriate UDT and DictType for attributes
for (i=0; i<SO.Attributes.Count; i++)
{
Attribute = SO.Attributes.GetObject(i);
if (Attribute.UserDataType != null)
{
TypeNode = Node.Convertor.GetProcessedObject(Attribute.UserDataType.Id, !AlterModel1);
if (TypeNode.IsRegisteredChange(“DROPCREATE”))
{
TypeTempName = Attribute.UserDataType.Name;
if (TypeTempName.length > 123)
TypeTempName = TypeTempName.substr(0,123);
TypeTempName = TypeTempName + “" + Attribute.UserDataType.Id.replace(/[-{}]/g,"");
TypeTempName = TypeTempName.substr(0,128);
arrAttrChangedUDTName[“U.”+Attribute.Id] = TypeTempName;
}
}
if (Attribute.DictType != null)
{
TypeNode = Node.Convertor.GetProcessedObject(Attribute.DictType.Id, !AlterModel1);
if (TypeNode.IsRegisteredChange(“DROPCREATE”))
{
TypeTempName = Attribute.DictType.Name;
if (TypeTempName.length > 123)
TypeTempName = TypeTempName.substr(0,123);
TypeTempName = TypeTempName + "
” + Attribute.DictType.Id.replace(/[-{}]/g,"");
TypeTempName = TypeTempName.substr(0,128);
arrAttrChangedUDTName[“D.”+Attribute.Id] = TypeTempName;
}
}
}

//table
if ((OtherName != “”) && (OtherName != “777”))
{
if (Entity.Resolve(Entity.BeforeScript) != “”)
Result += “\r\n”
+ Entity.Resolve(Entity.BeforeScript)
+ “\r\n”;

if ((arrParam != null) && (arrParam[“FLAG_PartitionScheme”] != null))
arrAttrChangedUDTName[“FLAG_PartitionScheme”] = false;
Result += DCGenerator.CreateTable(Entity, OtherName, arrAttrChangedUDTName);
}
else
{
if (OtherName != “777”)
{
if (Entity.Resolve(Entity.BeforeScript) != “”)
Result += “\r\n”
+ Entity.Resolve(Entity.BeforeScript)
+ “\r\n”;

Result += DCGenerator.CreateTable(Entity, “”, null);

if (Entity.Resolve(Entity.AfterScript) != “”)
Result += “\r\n”
+ Entity.Resolve(Entity.AfterScript);
}
else
{
if (Entity.Resolve(Entity.AfterScript) != “”)
Result += “\r\n”
+ Entity.Resolve(Entity.AfterScript);

flagFirst = true;
//Default Constraints
for (a=0; a<SO.Attributes.Count; a++)
{
Attr = SO.Attributes.GetObject(a);
if ((! Attr.IsDefaultObject) && (Attr.DefaultValueAsText != “”))
if (Attr.DefaultConstraintName != “”)
{
if (flagFirst)
{
Result += “\r\n”;
flagFirst = false;
}
Result += “\r\n”;
Result += “ALTER TABLE “+SO.QuotedFullName()+” ADD”;
if (Attr.DefaultConstraintName != “”)
Result += " CONSTRAINT “+DCGenerator.Quote(Attr.DefaultConstraintName);
Result += " DEFAULT “+Attr.Resolve(Attr.DefaultValueAsText)
+ " FOR “+Attr.QuotedName();
Result += RowedTerminator;
}
}
//Table Check Constraints
for (i=0; i<SO.CheckConstraints.Count; i++)
{
Check = SO.CheckConstraints.GetObject(i);
if (Check.GenerateCode)
{
CheckSQL = Check.Resolve(Check.AsText, DCGenerator );
if (CheckSQL != “”)
{
if (flagFirst)
{
Result += “\r\n”;
flagFirst = false;
}
Result += “\r\n”;
Result += “ALTER TABLE “+SO.QuotedFullName()
+ ((Check.DisabledConstraint)?” WITH NOCHECK”:””)
+ " ADD CONSTRAINT “+Check.QuotedName()+” CHECK”
+ ((Check.NotForReplication)?" NOT FOR REPLICATION":"")
+ " ("+CheckSQL+")";
Result += RowedTerminator;
}
}
}
//Columns Check Constraints (with CheckConstraints in domain)
for (a=0; a<SO.Attributes.Count; a++)
{
Attr = SO.Attributes.GetObject(a);
CheckAttrDom = Attr.GetCheckConstraintsResolved();
for (i=0; i<CheckAttrDom.Count; i++)
{
Check = CheckAttrDom.GetObject(i);
if (Check.GenerateCode)
{
CheckSQL = Check.Resolve(Check.AsText, DCGenerator );
if (CheckSQL != “”)
{
if (flagFirst)
{
Result += “\r\n”;
flagFirst = false;
}
Result += “\r\n”;
Result += “ALTER TABLE “+SO.QuotedFullName()
+ ((Check.DisabledConstraint)?” WITH NOCHECK”:"")
+ " ADD";
// Don’t generate domain check constraint names, they are not unique
if (Check.ObjectType != 2031) //Domain Check constraint
{
if (Check.Name != “”)
Result += " CONSTRAINT “+Check.QuotedName();
}
else
{
if (DCGenerator.GenerateCheckConstraintDomainNames && (Check.Name != “”))
Result += " CONSTRAINT “+DCGenerator.Quote(Check.Resolve(Check.Name));
}
Result += " CHECK”
+ ((Check.NotForReplication)?” NOT FOR REPLICATION":"")
+ " ("+CheckSQL+")";
Result += RowedTerminator;
}
}
}
}
}

Result += DCGenerator.DisabledCheckConstraint(Entity);

// Binds default object and rule object to column
var Attribute, text;
var isFirst = true;
for (i=0; i<Entity.Attributes.Count; i++)
{
Attribute = Entity.Attributes.GetObject(i);
text = DCGenerator.BindDefaultRule(Attribute);
if (text != “”)
{
if (isFirst)
{
isFirst = false;
text = “\r\n” + text;
}
Result += text + “\r\n”;
}
}

// Generate table comments and column comments
if (DCGenerator.CreateComments)
{
if ((Entity.Resolve(Entity.Comments) != “”) && (DCGenerator.UseQualifiedNames) && (Entity.Schema != null))
{
Result += “\r\n\r\n”;
Result += DCGenerator.GenerateCommentToTable(Entity)+RowedTerminator;
}
Entity.Attributes.ResetIterator();
if(Entity.Attributes.Count>0)
{
Attributes = Entity.Attributes;
while (Attributes.Iterate("","",(((Attributes.IterateItem.Resolve(Attributes.IterateItem.Comments)!="")&&(DCGenerator.UseQualifiedNames)&&(Attributes.IterateItem.Owner.Schema!=null))?"\r\n"+DCGenerator.GenerateCommentToTColumn(Attributes.IterateItem)+RowedTerminator:""),"",""));
Result += Entity.Attributes.IterateText;
}
}

//indexes
var ExistSpatial = false;
var ix, IndexItem, AttrInfo;
for (ix=0; ix<Entity.Indexes.Count; ix++)
{
Index = Entity.Indexes.GetObject(ix);
if (Index.GenerateCode && (Index.IndexItems.Count>0))
{
IndexItem = Index.IndexItems.GetObject(0);
if (IndexItem.Attribute != null)
{
AttrInfo = IndexItem.Attribute;
if (AttrInfo.Domain != null)
AttrInfo = AttrInfo.Domain;
if (AttrInfo.DataType != null)
{
if ((AttrInfo.DataType.Caption == “Geometry”) || (AttrInfo.DataType.Caption == “Geography”))
ExistSpatial = true;
}
}
}
}
if ( ExistSpatial
&& ((DCGenerator.OrderSettings.OrderDetail(2010) == 0) || (DCGenerator.OrderSettings.OrderDetail(2010) == 1)) )
{
// Generovani Primary Key (when Spatial Index exist)
Entity.Keys.ResetIterator();
if(Entity.Keys.Count>0)
{
Keys = Entity.Keys;
while (Keys.Iterate("","",(Keys.IterateItem.GenerateCode && Keys.IterateItem.IsPrimaryKey && (Keys.IterateItem.KeyItems.Count>0))?"\r\n\r\n"+DCGenerator.CreatePrimaryKey(Keys.IterateItem)+RowedTerminator:"","",""));
Result += Entity.Keys.IterateText;
}
}
Entity.Indexes.ResetIterator();
if(Entity.Indexes.Count>0)
{
Indexes = Entity.Indexes;
while (Indexes.Iterate("","",(Indexes.IterateItem.GenerateCode?"\r\n\r\n"+DCGenerator.CreateIndex(Indexes.IterateItem,0)+RowedTerminator:""),"",""));
Result += Entity.Indexes.IterateText;
}
// Generate index comments
if (DCGenerator.CreateComments)
{
Entity.Indexes.ResetIterator();
if(Entity.Indexes.Count>0)
{
Indexes = Entity.Indexes;
while (Indexes.Iterate("","",((Indexes.IterateItem.GenerateCode && (Indexes.IterateItem.Resolve(Indexes.IterateItem.Comments)!="") && (DCGenerator.UseQualifiedNames) && (Indexes.IterateItem.Owner.Schema!=null))?"\r\n"+DCGenerator.GenerateCommentToTIndex(Indexes.IterateItem)+RowedTerminator:""),"",""));
Result += Entity.Indexes.IterateText;
}
}

// Generate Create Fulltext Index
if (DCGenerator.CreateFulltextIndexes)
{
if (Entity.IndexName != “”)
{
Result += “\r\n\r\n”;
Result += DCGenerator.CreateFulltextIndex(Entity)+RowedTerminator;
}
}

if((DCGenerator.OrderSettings.OrderDetail(2010) == 0) || (DCGenerator.OrderSettings.OrderDetail(2010) == 1))
{
var FSKey = DCGenerator.KeyForFilestreamDetector(Entity);
//primary keys
if (! ExistSpatial)
{
Entity.Keys.ResetIterator();
if(Entity.Keys.Count>0)
{
Keys = Entity.Keys;
while (Keys.Iterate("","",((Keys.IterateItem.GenerateCode && Keys.IterateItem.IsPrimaryKey && (Keys.IterateItem.KeyItems.Count>0)) && ((FSKey == null) || (Keys.IterateItem.Id != FSKey.Id)))?"\r\n\r\n"+DCGenerator.CreatePrimaryKey(Keys.IterateItem)+RowedTerminator:"","",""));
Result += Entity.Keys.IterateText;
}
}

//alternate keys
Entity.Keys.ResetIterator();
if(Entity.Keys.Count>0)
{
Keys = Entity.Keys;
while (Keys.Iterate("","",((Keys.IterateItem.GenerateCode && (! Keys.IterateItem.IsPrimaryKey) && (Keys.IterateItem.KeyItems.Count>0)) && ((FSKey == null) || (Keys.IterateItem.Id != FSKey.Id)))?"\r\n\r\n"+DCGenerator.CreateAlternateKey(Keys.IterateItem)+RowedTerminator:"","",""));
Result += Entity.Keys.IterateText;
}
}
// Generate key comments
if (DCGenerator.CreateComments)
{
Entity.Keys.ResetIterator();
if(Entity.Keys.Count>0)
{
Keys = Entity.Keys;
while (Keys.Iterate("","",((Keys.IterateItem.GenerateCode && (Keys.IterateItem.KeyItems.Count>0) && (Keys.IterateItem.Resolve(Keys.IterateItem.Comments)!="") && (DCGenerator.UseQualifiedNames) && (Keys.IterateItem.Owner.Schema!=null))?"\r\n"+DCGenerator.GenerateCommentToTKey(Keys.IterateItem)+RowedTerminator:""),"",""));
Result += Entity.Keys.IterateText;
}
}

//triggers
Entity.Triggers.ResetIterator();
if(Entity.Triggers.Count>0)
{
Triggers = Entity.Triggers;
while (Triggers.Iterate("","",((Triggers.IterateItem.GenerateCode)?"\r\n\r\n"+DCGenerator.CreateTrigger(Triggers.IterateItem,0)+RowedTerminator:""),"",""));
Result += Entity.Triggers.IterateText;
}
}

Result += “\r\n”;

return Result;
}

function SwitchModifyProperties( PropertyConversion, AlterModel1 )
{
switch (PropertyConversion.Property1Name)
{
case ‘FilestreamFilegroup’: return ChangeEntityDropCreate( PropertyConversion, AlterModel1 );
case ‘FilestreamPartitionScheme’: return ChangeEntityDropCreate( PropertyConversion, AlterModel1 );
case ‘CompressionType’: return ChangeEntityCompression( PropertyConversion, AlterModel1 );
case ‘IsPartitionCompression’: return ChangeEntityCompression( PropertyConversion, AlterModel1 );
case ‘PartitionCompression’: return ChangeEntityCompression( PropertyConversion, AlterModel1 );
case ‘FulltextIndexFilegroup’: return ChangeFulltextIndexDropCreate( PropertyConversion, AlterModel1 );
case ‘Stoplist’: return ChangeFulltextIndexDropCreate( PropertyConversion, AlterModel1 );
case ‘FIStoplistOFF’: return ChangeFulltextIndexDropCreate( PropertyConversion, AlterModel1 );
default : return Instance.SwitchModifyProperties( PropertyConversion, AlterModel1 );
}
//402 … change CompressionType (rebuild)
//503 … change Stoplist and FIStoplistOFF (Stoplist) in Fulltext Index
/*

  • Pri celkove zmene Data Compression pouzivam prikaz REBUILD
  • Pri zmene Data Compression pro jednotlive partitions pouzivam Drop/Create tabulky (s pouzitim temporary tabulky)
  • Pri zmene Stoplist a FIStoplistOFF se provede ALTER FULLTEXT INDEX.
    */
    };

function ChangeEntityDropCreate( PropertyConversion, AlterModel1 )
{
var Result = “”, SLname = “”, DLname = “”;
var ObjectConversion = PropertyConversion.Owner;
var SO = ObjectConversion.SourceObj( !AlterModel1 );
var DO = ObjectConversion.SourceObj( AlterModel1 );

var flag = false;
switch (PropertyConversion.Property1Name)
{
case ‘FilestreamFilegroup’:
if (SO.FilestreamFilegroup != null)
SLname = SO.FilestreamFilegroup.Name;
if (DO.FilestreamFilegroup != null)
DLname = DO.FilestreamFilegroup.Name;
if (SLname != DLname)
flag = true;
break;
case ‘FilestreamPartitionScheme’:
if (SO.FilestreamPartitionScheme != null)
SLname = SO.FilestreamPartitionScheme.Name;
if (DO.FilestreamPartitionScheme != null)
DLname = DO.FilestreamPartitionScheme.Name;
if (SLname != DLname)
flag = true;
break;
default: flag = true;
}
if (flag)
return 1;

return 0;
}

function ChangeEntityCompression( PropertyConversion, AlterModel1 )
{
var Result = “”, SLname = “”, DLname = “”;
var ObjectConversion = PropertyConversion.Owner;
var SO = ObjectConversion.SourceObj( !AlterModel1 );
var DO = ObjectConversion.SourceObj( AlterModel1 );

if ((! SO.IsPartitionCompression) && (! DO.IsPartitionCompression))
{
if (SO.CompressionType != DO.CompressionType)
return 402;
}

return 1;
}

function ChangeFulltextIndexDropCreate( PropertyConversion, AlterModel1 )
{
var Result = “”, SLname = “”, DLname = “”;
var ObjectConversion = PropertyConversion.Owner;
var SO = ObjectConversion.SourceObj( !AlterModel1 );
var DO = ObjectConversion.SourceObj( AlterModel1 );

var flag = false;
var flagStoplist = false;
if ((SO.IndexName != “”) || (DO.IndexName != “”))
{
if (PropertyConversion.Property1Name == “FulltextIndexFilegroup”)
{
if (SO.FulltextIndexFilegroup != null)
SLname = SO.FulltextIndexFilegroup.Name;
if (DO.FulltextIndexFilegroup != null)
DLname = DO.FulltextIndexFilegroup.Name;
if (SLname != DLname)
flag = true;
}
else
if ( (PropertyConversion.Property1Name == “Stoplist”)
|| (PropertyConversion.Property1Name == “FIStoplistOFF”) )
{
if (SO.Stoplist != null)
SLname = SO.Stoplist.Name;
if (DO.Stoplist != null)
DLname = DO.Stoplist.Name;
if (SLname != DLname)
flagStoplist = true;
if (flagStoplist || (PropertyConversion.Property1Name == “FIStoplistOFF”))
return 503;
}
}

if (flag)
return 501;

return 0;
}


#4

Hi,

thank you for you feedback. It should work fine in the next BETA version that should be released next week. The bug was fixed.

Regards,

Vaclav