andrew.wood
Follow / 5 Jan 2018 at 2:04am / Toad Data Modeler
Latest post by on 8 Jan 2018 at 10:48am

Script to identify Keys (Primary, Foreign and Primary Foreign)

Expand content
I am trying to mimic the action that occurs when one changes the Physical Model relationships from Primary Foreign Key to a Foreign Key . Why? My data model will soon have hundreds of tables. I don't...

I am trying to mimic the action that occurs when one changes the Physical Model relationships from  Primary Foreign Key to a  Foreign Key

Why?  My data model will soon have hundreds of tables.  I don't wish to perform this action by hand.

The actions seem to be:

1. The relationship line between the Entities change (Identifying = Solid line, Non-Identifying = Broken line)  NB: Code for this below

2. the associated Primary Foreign Key attributes within an Entity are 'changed' to be Foreign Key within (on, across, over) those attributes.  NB: I don't know how to do this.

3. An associated index is created on the Foreign Key.  NB: I don't know how to do this.

I have located code to identify keys object (though I could not find reference to Keys in the [Script Editor | Expert Mode] Reference Guide) However, it appears that the keys only refers to Primary Keys, not Foreign Keys or Primary Foreign Keys.  I am aware that in TOAD Data Modeler:

Foreign Keys are shown in Green Font Color
Primary Foreign Keys are identified by Blue Font  Color 
Primary Keys are shown in Red Font Color

Qu 1: Using code; How does one identify when an Attribute has a setting of Foreign or Primary Foreign

Qu 2. Using code: How to modify an Attribute setting to (Enforce a) Primary Key, Foreign Key or Primary Foreign Key.  (obviously a Attribute may only be in one of those states)

Qu 3. Using code: How does one create a new Index, containing not the Primary Key (of that Entity), but the Foreign Key (of that entity).  one Attribute, not compounded attributes.
   

I am aware that there are times when I will want to retain Primary Foreign Key over a  Foreign Key, but I believe I can program for that component.

Thank you.

//Code to Change Relationship types from Identifying to Non-Identifying

for (e=0; e<Model.Relations.Count; e++) 
{
  iterObject = Model.Relations.GetObject(e); 
  if (iterObject.Identifying)
  {
    iterObject.Identifying = false; //An associtated index will not be created, but you really should create an index to support this 
    //Do something here to create an index. I don't know what as of yet.
  }
}

//Code to identify if an Entity contains a Primary Key

for (e=0; e<Model.Entities.Count; e++)
{
  Entity = Model.Entities.GetObject(e);
    for (k=0; k<Entity.Keys.Count; k++)
    {
      Key = Entity.Keys.GetObject(k);
      if (Key.IsPrimaryKey)
      {
        //Key.Name = "PK_"+Entity.Name;
        Log.Information("Primary Key : " + Entity.Name );
      }
  }
}

227 1 / Create an account to join the discussion.
a_valued_customer
Follow / 20 Dec 2017 at 6:54am / Toad Data Modeler
Latest post by on 20 Dec 2017 at 8:04am

Cannot save package any more

Expand content
I have a custom package in TDM that has been migrated through various versions. But in 6.3 I can't save it any more. When I change something in one of the functions, and then click on Save the...

I have a custom package in TDM that has been migrated through various versions.

But in 6.3 I can't save it any more.

When I change something in one of the functions, and then click on Save the Message Explorer says:

Package 'LiquibaseSupport' can't be saved

When I click on "Details" in the context menu, the previous errors are:

Package 'Convert Microsoft SQL Server 2012 to Microsoft Azure SQL Database V12' has not been loaded.
Parent package has not been found, Id={60E17C77-4478-4CE4-B735-F9138B7D293C}

Package 'Convert Microsoft SQL Server 2012 to Microsoft Azure SQL Database (common)' has not been loaded.
Parent package has not been found, Id={758B5503-8083-4BDC-AB2A-80A3BAD59868}

What can I do, so that can I edit my package again?

The exact TDM Version is: 6.3.2.22 (64bit)

Unanswered 413 2 / Create an account to join the discussion.
andrew.wood
Follow / 13 Dec 2017 at 11:21pm / Toad Data Modeler
Latest post by on 15 Dec 2017 at 1:34am

Physical Model: Script to Delete all 'Extended Properties'...

Expand content
From the Physical Model, using Macro / Script etc: I need to be able to delete an Extended Property from either an Entity, or an Attribute. I'd like to do this regardless of if I know the 'Extended...

From the Physical Model, using Macro / Script etc:

I need to be able to delete an Extended Property from either an Entity, or an Attribute.  

I'd like to do this regardless of if I know the 'Extended Property' name or not.

NB I can create a new 'Extended Properties' and modify them just fine.

Unanswered 475 2 / Create an account to join the discussion.
anthony.vitale
Follow / 5 Dec 2017 at 2:51pm / Toad Data Modeler

RE: [Toad Data Modeler - Scripting & Customizations Discussion...

Expand content
Hi Daril Thanks as always, This now works 100% I am not sure if it is the most efficient way to do it, but it works and does what I want and does not blow up So there appeared ...
Hi Daril
 
Thanks as always,
 
This now works 100%
 
I am not sure if it is the most efficient way to do it, but it works and does what I want and does not blow up
 
So there appeared
 
1) Adding relationships to a shape for which the workspace was not setmodified to true caused issues
2) Using Substring multiple time vs once and using variable caused issue
 
 
This is my final Code
 
Thanks Again
 
function CreateCopyShape(WorkSpaceMain, WorkSpace, Object, WSType) {
    var k, ObjectShape, MainObjectShape;

    ObjectShape = WorkSpace.NewWorkSpaceShape(WSType, Object);
    for (k = 0; k < WorkSpaceMain.ShapeList.Count; k++) {
        MainObjectShape = WorkSpaceMain.ShapeList.GetObject(k);
        if ((MainObjectShape.ObjectType == WSType)
            && (MainObjectShape.ParentBaseID == ObjectShape.ParentBaseID)) {
            ObjectShape.Left = MainObjectShape.Left;
            ObjectShape.Top = MainObjectShape.Top;
            ObjectShape.Width = MainObjectShape.Width;
            ObjectShape.Height = MainObjectShape.Height;
            break;
        }
    }
}

function Main() {
    var App = System.GetInterface("Application");
    var Model = App.ActiveModel;
    var WorkSpaceActive = App.ActiveWorkSpace;
    var WorkingWorkspace = Model.Workspaces.GetObjectByName(WorkSpaceActive.Name);
    var WorkSpaceMain = Model.Workspaces.GetObject(0);
    var Log = System.CreateObject("Log");
    var i, e, r, Entity, Shape, Entity, Link, ChildEntity, ParentEntity, WLine;
    var Ent_Sub, Par_Sub, Child_Sub;

    Log.Information("Starting Link_Only_My_Entities_To_This_Workspace");

    Model.Lock();

    for (i = 0; i < Model.Entities.Count; i++) {

        Entity = Model.Entities.GetObject(i);
        Ent_Sub = Entity.Name.substring(0, 4);

        if (
            Ent_Sub == "trps" ||
            Ent_Sub == "tgra" ||
            Ent_Sub == "taoa"
        ) {
            if (WorkingWorkspace.ShapeList.GetObjectByName(Entity.Name) != null) {
                Log.Information(Entity.Name + " Is Already Found in Workspace");
            }
            else {
                Log.Information(Entity.Name + " Is Not Found in Workspace Adding it");
                CreateCopyShape(WorkSpaceMain, WorkingWorkspace, Entity, 2502); //ShapeEntity
            }
        } // Entity If Check Names
    } // For Entities

    Model.UnLock();
    Model.SetModified(true);
    Model.RefreshModel();

    Log.Information("Starting Link_Only_My_Relationship_Lines_To_This_Workspace");

    Model.Lock();

    for (e = 0; e < WorkSpaceActive.ShapeList.Count; e++) {
        Shape = WorkSpaceActive.ShapeList.GetObject(e);
        if (Shape.ObjectType == 2502) //entity shape on WorkSpaceActive
        {
            Entity = Shape.ParentBase;
            for (r = 0; r < Entity.Relations.Count; r++) {
                Link = Entity.Relations.GetObject(r);

                ChildEntity = Link.ChildEntity;
                ParentEntity = Link.ParentEntity;

                Log.Information("ParentEntity=" + ParentEntity.Name + " ChildEntity=" + ChildEntity.Name);

                Par_Sub = ParentEntity.Name.substring(0, 4);
                Child_Sub = ChildEntity.Name.substring(0, 4);

                if ((Par_Sub == "trps" ||
                    Par_Sub == "tgra" ||
                    Par_Sub == "taoa") &&
                    (Child_Sub == "trps" ||
                        Child_Sub == "tgra" ||
                        Child_Sub == "taoa")
                ) {
                    Log.Information("This is a Relation that if Missing will be added");
                    WLine = WorkSpaceActive.CreateWorkspaceLineByParentobject(Link, 2504); // Create  Relation line
                }
                else {
                    Log.Information("This is a Relation that Will not be Added because either the Parent or Child Tables are not within the Subset of you Tables");
                }
            }
        }
    }

    Model.UnLock();
    Model.SetModified(true);
    Model.RefreshModel();
    Log.Information("Completed Link_Only_My_Relationship_Lines_To_This_Workspace");
    Log.Information("Completed Link_Only_My_Entities_To_This_Workspace");

} // Main


Anthony Vitale
 
From: Daril [mailto:bounce-Daril@toadworld.com]
Sent: Tuesday, December 05, 2017 5:00 AM
To: tdmscript@toadworld.com
Subject: RE: [Toad Data Modeler - Scripting & Customizations Discussion Forum] Hi, I wrote a Macro to add Entities into a Active Workspace that meet a naming criteria, and then add missing relationship lines, And I had to make this 2 seperate macros to get it t...
 
Reply by Daril

Hi Anthony,

  if you want mark model as modified (so save model icon will be enabled) please call

Model.SetModified(true);

  To memory error. I'm not sure how substring method works with string that is shorter than 4 in your case.  Could you try store substring(0,4) of parent and child entity to variable before if statement and determine that is not problem when child entity has short name (less than 4)? What kind of memory error is it?

Thanks

Daril

To reply, please reply-all to this email.

Stop receiving emails on this subject.
Or Unsubscribe from Toad Data Modeler - Scripting & Customizations Forum notifications altogether.
Toad Data Modeler - Scripting & Customizations Discussion Forum

Flag this post as spam/abuse.

316 0 / Create an account to join the discussion.
anthony.vitale
Follow / 4 Dec 2017 at 6:42pm / Toad Data Modeler
Latest post by on 5 Dec 2017 at 9:59am

Hi, I wrote a Macro to add Entities into a Active Workspace that meet...

Expand content
Hi Guys I have a Need to have a Macro which adds Entities to an active workspace which match a naming criteria, and then add missing relationship lines to the workspace in which the parent/child tables...

Hi Guys

I have a Need to have a Macro which adds Entities to an active workspace which match a naming criteria, and then add missing relationship lines to the workspace in which the parent/child tables also match a naming criteria.

What you see below as 2 macros I tried to make a single macro but found that I would get memory exceptions and it would blow up My Toad Process.

What I discovered is that the 1st macro, when it adds entities to a workspace, even though I am performing a RefreshModel, does not mark the workspace as having been updated and as such does not allow for save without me having to manually change something in the workspace.

So In Order for this to work even as 2 macros, I need to 

1) Run this macro, And when It completes, I then need to move an entity or do something on the workspace manually which then enables the Save and I can Save the model.  If I do not do that then if I exit toad no changes are saved

//Macro to add entities to active workspace that start with specific characters

function Main() {
var App = System.GetInterface("Application");
var Model = App.ActiveModel;
var WorkSpaceActive = App.ActiveWorkSpace;
var WorkingWorkspace = Model.Workspaces.GetObjectByName(WorkSpaceActive.Name);
var WorkSpaceMain = Model.Workspaces.GetObject(0);
var Log = System.CreateObject("Log");
var i, e, Entity, Shape, Entity, Link, ChildEntity, ParentEntity, WLine;

if (Model == null) {
Log.Information("You Must have a Model Open to Run This Macro\nThe Process Is Ending Unsuccessfully");
return;
} // Model == null

if (WorkSpaceActive == null) {
Log.Information("You Must have a Model Open to Run This Macro\nThe Process Is Ending Unsuccessfully");
return;
} // WorkSpaceActive == null

Log.Information("Starting SME_Link_Only_My_Entities_To_This_Workspace");

Model.Lock();

for (i = 0; i < Model.Entities.Count; i++) {

Entity = Model.Entities.GetObject(i);
if (
Entity.Name.substring(0, 4) == "trps" ||
Entity.Name.substring(0, 4) == "tgra" ||
Entity.Name.substring(0, 4) == "taoa"
) {
if (WorkingWorkspace.ShapeList.GetObjectByName(Entity.Name) != null) {
Log.Information(Entity.Name + " Is Already Found in Workspace");
}
else {
Log.Information(Entity.Name + " Is Not Found in Workspace Adding it");
CreateCopyShape(WorkSpaceMain, WorkingWorkspace, Entity, 2502); //ShapeEntity
}
} // Entity If Check Names
} // For Entities

Model.UnLock();
Model.RefreshModel();
Log.Information("Completed SME_Link_Only_My_Entities_To_This_Workspace");
} // Main

 


2) Then After I save the Model I can Run this macro to add the missing relationship lines. This appears to behave  differently as when it runs if it actually adds New RElationships It does enable the Save.of the model without subsequent need for me to change something manually

 

//Macro to add missing relationship lines to active workspace that Have Parent and Child Tables whichstart with specific characters


function Main() {
var App = System.GetInterface("Application");
var Model = App.ActiveModel;
var WorkSpaceActive = App.ActiveWorkSpace;
var WorkingWorkspace = Model.Workspaces.GetObjectByName(WorkSpaceActive.Name);
var WorkSpaceMain = Model.Workspaces.GetObject(0);
var Log = System.CreateObject("Log");
var i, e, Entity, Shape, Entity, Link, ChildEntity, ParentEntity, WLine;

if (Model == null) {
Log.Information("You Must have a Model Open to Run This Macro\nThe Process Is Ending Unsuccessfully");
return;
} // Model == null

if (WorkSpaceActive == null) {
Log.Information("You Must have a Model Open to Run This Macro\nThe Process Is Ending Unsuccessfully");
return;
} // WorkSpaceActive == null


Log.Information("Starting SME_Link_Only_My_Relationship_Lines_To_This_Workspace");

Model.Lock();

for (e = 0; e < WorkSpaceActive.ShapeList.Count; e++) {
Shape = WorkSpaceActive.ShapeList.GetObject(e);
if (Shape.ObjectType == 2502) //entity shape on WorkSpaceActive
{
Entity = Shape.ParentBase;
for (r = 0; r < Entity.Relations.Count; r++) {
Link = Entity.Relations.GetObject(r);

ChildEntity = Link.ChildEntity;
ParentEntity = Link.ParentEntity;

Log.Information("ParentEntity=" + ParentEntity.Name + " ChildEntity=" + ChildEntity.Name);

if (ParentEntity.Name.substring(0, 4) == "trps" ||
ParentEntity.Name.substring(0, 4) == "tgra" ||
ParentEntity.Name.substring(0, 4) == "taoa"
) {
if (ChildEntity.Name.substring(0, 4) == "trps" ||
ChildEntity.Name.substring(0, 4) == "tgra" ||
ChildEntity.Name.substring(0, 4) == "taoa"
) {
Log.Information("This is a Relation that if Missing will be added");
WLine = WorkSpaceActive.CreateWorkspaceLineByParentobject(Link, 2504); // Create Relation line
}
else {
Log.Information("This is a Relation that Will not be Added because either the Parent or Child Tables are not within the Subset of you Tables");
}
}
else {
Log.Information("This is a Relation that Will not be Added because either the Parent or Child Tables are not within the Subset of you Tables");
}
}
}
}

Model.UnLock();
Model.RefreshModel();
Log.Information("Completed SME_Link_Only_My_Relationship_Lines_To_This_Workspace");
} // Main


3) Finally, You see 2 If statements in the macro above which I should have been able to make into 1 if statement with the use of bracketts and the  &&, however when I use && in this IF statement  I get a memory error and Toad blows up.

 

So this

 

if (ParentEntity.Name.substring(0, 4) == "trps" ||
ParentEntity.Name.substring(0, 4) == "tgra" ||
ParentEntity.Name.substring(0, 4) == "taoa"
) {
if (ChildEntity.Name.substring(0, 4) == "trps" ||
ChildEntity.Name.substring(0, 4) == "tgra" ||
ChildEntity.Name.substring(0, 4) == "taoa"
) {

Should have been allowed to be this

if ( (ParentEntity.Name.substring(0, 4) == "trps" || ParentEntity.Name.substring(0, 4) == "tgra" || ParentEntity.Name.substring(0, 4) == "taoa" ) &&
 (ChildEntity.Name.substring(0, 4) == "trps" || ChildEntity.Name.substring(0, 4) == "tgra" || ChildEntity.Name.substring(0, 4) == "taoa" )  )

 

But when i use the && above I get a memory error.

 

Do you guys see anything I did wrong as I would love it if it was a single Macro with the && instead of 2 macros with a manual Change and then Save in the middle.

 

Thanks

Anthony Vitale

1173 1 / Create an account to join the discussion.
anthony.vitale
Follow / 13 Nov 2017 at 10:59pm / Toad Data Modeler
Latest post by on 4 Dec 2017 at 8:59pm

What is the Best Jscript Method to find FK Relations by Child Table...

Expand content
Hi I have been Trying to Decipher the Reference Guide to try to help me write a Jscript which would allow me to Generate a Report I know how to Iterate Entities and within Entities to Iterate the...

Hi

I have been Trying to Decipher the Reference Guide to try to help me write a Jscript which would allow me to Generate a Report

I know how to Iterate Entities and within Entities to Iterate the Attributes

And I Can discover in my iteration of the Attributes that I can use the Field Attribute.CountParentAttributes and if it is > 0  then I know it is a Foreign.

However, I want to for a Entity/Attribute which is a Foreign key list the Parent Entity/Attriubute

So I can Iteration ALL Relationships in My Model using this in order to Produce a Report

function main()
{
var app = System.GetInterface('Application');
var Model = app.Models.GetObject(0); // first model in Application View
var r,a, Relation,Foreignkey, Parent_Attributes, Child_Attributes;

for (r=0; r<Model.Relations.Count; r++)
{
Relation = Model.Relations.GetObject(r);
Parent_Attributes="";
Child_Attributes="";

for (a=0; a<Relation.ForeignKeys.Count; a++)
{
Foreignkey=Relation.ForeignKeys.GetObject(a);

if (a == 0)
{
Parent_Attributes=Foreignkey.AttrParent.Name;
Child_Attributes=Foreignkey.AttrChild.Name;
}
else
{
Parent_Attributes=Parent_Attributes+","+Foreignkey.AttrParent.Name;
Child_Attributes=Child_Attributes+","+Foreignkey.AttrChild.Name;
}
}
Log.Information("Relation = "+Relation.Name+" Parent= "+Relation.ParentEntity.Name+"("+Parent_Attributes+")"+" Child= "+Relation.ChildEntity.name+"("+Child_Attributes+")");
}
Log.Information("DONE");
}

But I would like to know what is the Most Efficient way to Go from Entity/Attribute which I know is a Foreign key (Aka it is the Relation.ChildEntity.name and one of the Attributes of that relations Relation.ForeignKeys.AttrChild.Name in order to on the Same line as the Entity/Attribute produce the Parent Entity Name and its Attribute Name (Aka the  Relation.ParentEntity.Name and the Foreignkeys.AttrParent.Name)

Is there a Method to do that (like Relations.GetSomething(parentname,childname) without Creating a Internal Array of All Parent/Child Attribute lists and Scanning it every time.

Please let me know.

Thanks

Anthony Vitale

Unanswered 772 4 / Create an account to join the discussion.
anthony.vitale
Follow / 16 Nov 2017 at 10:50pm / Toad Data Modeler
Latest post by on 22 Nov 2017 at 6:16am

I am not sure I am Following the Instructions related to adding a...

Expand content
Hi folks I include a JScript below for just example, Lets Say that I have a Script that I know works and Runs from the Scripting Window, Like this Script which Replaces ' ' with '-'...

Hi folks

I include a JScript below for just example, Lets Say that I have a Script that I know works and Runs from the Scripting Window, Like this Script which Replaces ' ' with '-' in Names.

However I cannot seem to figure out how to Add This as an Actual Function with its Unique name and to add it to a Menu or to a Button So All I have do do is to click the object (menu or button) and make it run.

Can you please point me to where within the UserGuide I can see where to do this.

Or if it is not too much writting, a brief Summary of how I can Do it.

function main()
{
var app = System.GetInterface('Application');
var Model = app.Models.GetObject(0);
var e, a, Entity, Attribute, NewName, Index;;
Model.Lock();

for (e=0; e<Model.Entities.Count; e++) // iterate entities
{
Entity = Model.Entities.GetObject(e);
Entity.Lock();

for (a=0; a<Entity.Attributes.Count; a++) // iterate attributes
{
Attribute = Entity.Attributes.GetObject(a);
NewName=Attribute.Name;
NewName = NewName.replace(" ","_");

Attribute.Lock();
if (Attribute.Name != NewName)
{
Attribute.Name=NewName;
}
Attribute.UnLock();
}

for (a=0; a<Entity.Indexes.Count; a++)
{
Index = Entity.Indexes.GetObject(a);
NewName=Index.Name;
NewName = NewName.replace(" ","_");

Index.Lock();
Index.Name=NewName;
if (Index.Name != NewName)
{
Index.Name=NewName;
}
Index.UnLock();
}

for (a=0; a<Entity.Keys.Count; a++)
{
Key = Entity.Keys.GetObject(a);
Key.Lock();
NewName=Key.Name;
NewName = NewName.replace(" ","_");

if (Key.Name != NewName)
{
Key.Name=NewName;
}

Key.UnLock();
}

Entity.UnLock();
}
Model.UnLock();
}

Thanks

Anthony Vitale

821 5 / Create an account to join the discussion.
anthony.vitale
Follow / 14 Nov 2017 at 2:12pm / Toad Data Modeler
Latest post by on 14 Nov 2017 at 5:16pm

Is there any method at the workspace/shapelist level which would allow...

Expand content
Hello As We Use Multiple Workspaces in order to best create and display ERD's within our Models, I produce a Report of Entity's and there attachment to Workspaces (basically 2 Columns, Entity...

Hello

As We Use Multiple Workspaces in order to best create and display ERD's within our Models, I produce a Report of Entity's and there attachment to Workspaces (basically 2 Columns, Entity.Name and Workspace.Name)

And I want to list All Entities and the Workspace(s) they are attached to within the Model

So If Table1 is found within All Items as well as Within Workspace1 then the Chart would be 

Table   | Workspace

Table1 | All Items

Table1 | Workspace1

Etc.. 

I know I can apply brute force and build Arrays of the entities listed by Workspace and them Basically Join the Arrays as I Iterate All the Arrays and produce the result

But I would Like to know, If I itererate all the Entities of a Model, Is there anyway from the Entity Name or some component of the Entitiy to iterate the workspaces or Direct method to find workspaces by Entity.

This is the Code I have which iterates the workspaces and then the Entities within the Workspaces.

function main()
{
var app = System.GetInterface('Application');
var Model = app.Models.GetObject(0);
var Workspace,i,e;

for (i=0; i<Model.Workspaces.Count; i++) // iterate Workspaces
{
Workspace = Model.Workspaces.GetObject(i);
Log.Information('Workspace = '+Workspace.Name);

for (e=0; e<Workspace.ShapeList.Count; e++) // iterate entities
{
Entity = Model.Entities.GetObjectByName(Workspace.ShapeList.GetObject(e).Name);
Log.Information('Entity.Name = '+Entity.Name);
}
}
}

Please let me know.

Thanks

Anthony Vitale

Answered 650 2 / Create an account to join the discussion.
anthony.vitale
Follow / 3 Nov 2017 at 4:12pm / Toad Data Modeler
Latest post by on 6 Nov 2017 at 3:02pm

Where Can I find specific Information on TDM's jscript or vbscript...

Expand content
Hi, I am not sure if this is the appropriate place for this request, however I have not figured out a better place to ask it. I am New To Toad Data Modeler. I have learned how to use the scripting...

Hi, I am not sure if this is the appropriate place for this request, however I have not figured out a better place to ask it.

I am New To Toad Data Modeler.


I have learned how to use the scripting Window very well via the examples that have been available to me to manipulate Data within the TDM MetaModel.

However,  Jscript examples or vbscript examples I have found on the Web are not executable via the Scripting Window in TDM so I believe that it is a Customization of jscript or vbscript   unless I am doing something wrong.

And the reason I am looking into examples is because I have been trying to see if via jscript or vbscript using the scripting window If I can redirect output to a file

What I mean is In the small jscript script below which lists the attributes of 2 entities, If I wanted to write output it to a file called as example "C:\toadoutput.txt" instead of the only thing currently I can do which is to output to the log buffer using the line Log.Information command.


Is that possible ?

Also, Is there a way within jscript or vbscript like in the example below to filter entities by there discovery within a workspace. Meaning, if I have Table_1 and Table_2 in my Model, and Table_1 is currently a EntityShortcut in a Workspace called "AnthonyWS" Is there a way to only find entities which are linked to the Workspace "AnthonyWS"

Any Assistance in this would be appreciated as I am looking to write some Custom Reports in which are Custom Enough to be best served via a Custom Script that I write.

function main()
{
var app = System.GetInterface('Application');
var Model = app.Models.GetObject(0);
var e, a, Entity, Attribute;
for (e=0; e<2; e++) // iterate entities
{
Entity = Model.Entities.GetObject(e);
for (a=0; a<Entity.Attributes.Count; a++) // iterate attributes
{
Attribute = Entity.Attributes.GetObject(a);
Log.Information('Entity = '+Entity.Name+' Attribute Name '+Attribute.Name);
}
}
}

Thanks

Unanswered 694 2 / Create an account to join the discussion.
Robert
Follow / 5 Oct 2017 at 4:08pm / Toad Data Modeler
Latest post by on 23 Oct 2017 at 11:43am

Object permission

Expand content
Hi, please can You help me: how setting Toad Data Modeler for SQL Preview including object permission? I need view SQL script with grants, for examle: CRATE TABLE xyz ( ... ) go GRANT SELECT...

Hi, please can You help me: how setting Toad Data Modeler for SQL Preview including object permission? I need view SQL script with grants, for examle:

CRATE TABLE xyz (

...

)

go

GRANT SELECT on xyz to user_a

go

(I have defined users and groups in fold 'Permissions', but in SQL Script aren't), thanks.

Unanswered 1008 8 / Create an account to join the discussion.
SAinCA
Follow / 5 Oct 2017 at 1:44am / Toad Data Modeler
Latest post by on 6 Oct 2017 at 6:22am

Macro - how to get the schema property for an Entity

Expand content
I have a macro that gives 99% of the information I need to work through a list of entities NOT painted on a Workspace. I need the SCHEMA so I can emit schema.entityName to the Message pane. This doesn't...

I have a macro that gives 99% of the information I need to work through a list of entities NOT painted on a Workspace.

I need the SCHEMA so I can emit schema.entityName to the Message pane.

This doesn't work:

Log.Information (iteratedEntity.Schema + "." + iteratedEntity.Name);

It gives: undefined.entityName

Can someone please point me to a usable scripting reference?  I have open the TDMReference.chm, but it's full of not really usable information on "how to get a schema name for an entity..."  Likewise the Toad Data Modeler Help.chm file - nothing of any use.

Here's hoping...  Thanks!

841 3 / Create an account to join the discussion.
greg long
Follow / 9 Dec 2016 at 5:18am / Toad Data Modeler
Latest post by on 27 Sep 2017 at 12:38pm

Seeking advice on how to prevent creation of field captions when generating...

Expand content
I've looked but haven't found any option or guidance on how to prevent the generation of field captions when creating an Access database. Use of captions in Access is a nightmare - no matter...

I've looked but haven't found any option or guidance on how to prevent the generation of field captions when creating an Access database.

Use of captions in Access is a nightmare - no matter what alias you choose to give a field in a query, Access persists in using the field's 'caption' value, if one exists. This then allows two or more query columns to have the same name - which for the unwary (like my clients) can be a  confusing show-stopper.

(Yes - I can create code that removes them once I've built the database...but happy not to explore that option. And yes, I could modify the DDL (VBA) before I run it to prevent the caption from being created.  But, I'd rather a toggle option in TOAD.)

Thanks for any advice

Greg

1554 3 / Create an account to join the discussion.
thastings
Follow / 11 Jul 2017 at 2:31am / Toad Data Modeler
Latest post by on 14 Jul 2017 at 7:16am

Can someone help me with a macro to set database space

Expand content
I have reverse engineered one of our existing datbases and made a change. But now I have a validation error as the database space has not defaulted to system. Is there a way I can do this without editing...

I have reverse engineered one of our existing datbases and made a change. But now I have a validation error as the database space has not defaulted to system. Is there a way I can do this without editing every entity.

Thanks

Terry

Unanswered 1203 5 / Create an account to join the discussion.
3digits - Desarrollo
Follow / 5 Jun 2017 at 5:05pm / Toad Data Modeler
Latest post by on 7 Jun 2017 at 3:41pm

Macro for adding entities and sequences to PostgreSQL model ends with...

Expand content
Hi! TDM Version 5.4, PostgreSQL 9.2 model. I'm developing a macro that adds an Entity and its related sequence to PostgreSQL model. After macro ends I launch a model test and I get this message...

Hi!

TDM Version 5.4, PostgreSQL 9.2 model.

I'm developing a macro that adds an Entity and its related sequence to PostgreSQL model. After macro ends I launch a model test and I get this message:

Nonpaired objects "TPERCustomObject.<name_of_seq>" and"TPEREntity.<name_of_entity>", property "OwnedByTable". Back link is missing.

Macro for adding tables:

Entity = Model.CreateNewObject(2002); // add new entity
Entity.Name = "...";
Entity.Caption = "...";
//...code for adding attributes, PK, ..., and other table stuff

Macro for adding sequences:

var seq = Model.CreateNewObject(51000); //sequence
seq.Name = "...";
if (seq.SupportsProperty("OwnedByTable")) {
  seq.OwnedByTable = Entity;
  seq.OwnedByColumn = prefix + "_CODE";
  var atr = Entity.Attributes.GetObjectByName(seq.OwnedByColumn);
  atr.DefaultValue = "nextval('" + nomSeq + "')";
}
if (seq.SupportsProperty("StartWith")) {
  seq.StartWith = "1";
}
if (seq.SupportsProperty("IncrementBy")) {
  seq.IncrementBy = "1";
}
if (seq.SupportsProperty("Cache")) {
  seq.Cache = "10";
}
if (seq.SupportsProperty("Comments")) {
  seq.Comments = "Secuencia para " + Entity.Name + "." + prefix + "_CODIGO";
}

What does it means "Back link is missing."? Some kind of "link" in the table or attribute?

Am I missing some step in my code? 

Thanks in advance.

Regards!

Answered 1271 5 / Create an account to join the discussion.
eric.tobias_812
Follow / 19 May 2017 at 7:19pm / Toad Data Modeler
Latest post by on 22 May 2017 at 7:44am

How many relations match a string?

Expand content
I'd like to get a count of relations in a physical model that match a particular string. I see a "GetObjectByName" function, but it doesn't seem to return a count. I'd like to be...

I'd like to get a count of relations in a physical model that match a particular string. I see a "GetObjectByName" function, but it doesn't seem to return a count. I'd like to be able to do something like:

  • Model.Relations.GetObjectByName("MyRelationName").Count

How would I achieve this?

941 1 / Create an account to join the discussion.
3digits - Desarrollo
Follow / 7 Sep 2012 at 3:23pm / Toad Data Modeler
Latest post by on 25 Apr 2017 at 7:49am

Model remains unchanged after macro execution

Expand content
Hi, This is. Model remains unchanged after macro execution, and for example, a table is added. I have to make a "dummy" change to model and then I can save it. Regards, Biel B.
Hi,

This is. Model remains unchanged after macro execution, and for example, a table is added. I have to make a "dummy" change to model and then I can save it.

Regards,

Biel B.
12796 4 / Create an account to join the discussion.
Nicola Clement
Follow / 27 Feb 2017 at 9:44am / Toad Data Modeler
Latest post by on 28 Feb 2017 at 12:35pm

How to call Toad Data Modeler from C# application?

Expand content
I generated a TXP model using Toad Data Modeler 6.1 I launched the command: TDM.exe /regserver I written and executed automation script to perform various Toad Data Modeler tasks. How to call TDM from...

I generated a TXP model using Toad Data Modeler 6.1
I launched the command: TDM.exe /regserver
I written and executed automation script to perform various Toad Data Modeler tasks.

How to call TDM from C# application? I tried to execute the following csharp code:

{

Type toadType = System.Type.GetTypeFromProgID("TDM.App");
 dynamic App = System.Activator.CreateInstance(toadType);

while (!App.Application.IsPackagesLoaded)
 {
         Thread.Sleep(1000);
 }

var Model = App.OpenModelFromFile("C:\MyProject.txp");

 // TO DO...

}

but The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)).

How can I solve this problem, anyone knows?  Thanks very much!

Regards,
Nicola

Unanswered 1249 3 / Create an account to join the discussion.
Nicola Clement
Follow / 28 Feb 2017 at 10:47am / Toad Data Modeler

Where's Toad Object Library (API COM) ?

Expand content
How to automate Toad Data Modeler from Microsoft Visual C# .NET ? I need to create an Automation Client for Toad in C#. How can I do it? Thanks a lot in advance for any help, Nicola

How to automate Toad Data Modeler from Microsoft Visual C# .NET ? I need to create an Automation Client for Toad in C#.

How can I do it?

Thanks a lot in advance for any help,

Nicola

Unanswered 676 0 / Create an account to join the discussion.
sigmond
Follow / 20 Dec 2016 at 4:37am / Toad Data Modeler
Latest post by on 20 Dec 2016 at 8:39am

Workspace Properties > Select Children > Not Working?

Expand content
I am trying to add the children of an Entity to the Workspace. This is what I am doing: Right-click Workspace Click Edit Select the parent Entity Right-click the parent Entity Click Select...

I am trying to add the children of an Entity to the Workspace.  This is what I am doing:

  • Right-click Workspace
  • Click Edit
  • Select the parent Entity
  • Right-click the parent Entity
  • Click Select Children
  • Click OK

Only the original Entity that was selected is added to the Workspace.  It's children are not.

Q: What am I missing here?

1306 1 / Create an account to join the discussion.
mail8mz
Follow / 31 Oct 2016 at 6:04pm / Toad Data Modeler
Latest post by on 2 Nov 2016 at 3:29pm

Database development procedure

Expand content
Hello, We are using the Toad modeler and Oracle as our database development environment. There are several enviornments(development, testing, production), we have multiple release working in parallel...

Hello,

We are using the Toad modeler and Oracle as our database development environment. There are several enviornments(development, testing, production), we have multiple release working in parallel. For example, there may several drops for each Release in development environment, we need to consolidate these into one drop to testing environment. Meanwhile,  we would like the keep the consistence between the model and the production database. We are using SVN as the version control system.

Toad modeler has the function of reverse enginnering, generate DDL, merge model and etc, which makes it a good tool for such development. Is there any best practice of the procedure or toturial for such database development using Toad modeler, version control and database system?

Thanks,

1749 4 / Create an account to join the discussion.