Chat now with support
Chat with Support

Toad Data Modeler 6.2 - User Guide

Introduction User Interface Models and Model Objects
Physical Data Model
About Physical Data Modeling Benefits of Physical Data Model Entity Relationship Diagram Objects Basic Database Design Advanced Database Design
Universal Data Model Logical Data Model Working with Model Objects Model Properties Model Statistics
Features and Tools
Application Variables Export/Import DDL Script Generation Graphics Model Actions Print Projects Reports Reverse Engineering Scripting and Customization SQL Templates Tips and Tricks Toad for Oracle Integration Toad Intelligence Central (TIC) Integration Tools Version Control
Options and Configuration Databases
Supported Databases Connection Types by Database DB2 UDB v. 8 (LUW) DB2 v. 9 (LUW) DB2 v. 9.5 (LUW) DB2 v. 9.7 (LUW) DB2 v. 10.1 (LUW) DB2 v. 10.5 (LUW) DB2 z/OS v. 9 DB2 z/OS v.10 DB2 z/OS v. 11 Greenplum 4.1 Greenplum 4.2 Ingres 9.3 Ingres 10.0 Microsoft Access 2000/2002/2003 Microsoft Access 2007/2010 Microsoft Azure SQL Database Microsoft Azure SQL Database V12 Microsoft SQL Server 2000 Microsoft SQL Server 2005 Microsoft SQL Server 2008 Microsoft SQL Server 2012 Microsoft SQL Server 2014 Microsoft SQL Server 2016 MySQL 5.0 MySQL 5.1 MySQL 5.5 MySQL 5.6 MySQL 5.7 Oracle 9i Oracle 10g Oracle 11g Release 1 Oracle 11g Release 2 Oracle 12c Release 1 Oracle 12c Release 2 PostgreSQL 8.1 PostgreSQL 8.2 PostgreSQL 8.3 PostgreSQL 8.4 PostgreSQL 9.0 PostgreSQL 9.1 PostgreSQL 9.2 PostgreSQL 9.3 PostgreSQL 9.4 PostgreSQL 9.5 SQLite 3.7 Sybase ASE 12.5 Sybase ASE 15 Sybase ASE 15.5 Sybase ASE 15.7 SAP ASE 16.0 Sybase IQ 15.2 Sybase SQL Anywhere 11 SAP SQL Anywhere 17 Teradata 13 Vertica Database 8.0
Legal Information

Modify Form

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Modify Form

Back to our Oracle 10 physical model.

Edit an entity to open standard Entity Properties form.

Right-click the form and select Customize Form as...

Select a package you want to store modifications in.

The following forms and palettes will appear. Note that the Entity Properties form has dotted grid now.

In the Form Explorer, see that the form name is FmPEREntityEdit. We will need this information later.

To add a new tab to the Entity form, right-click any tab in the form and select New Page.

 

Define Caption for the new tab in Component Inspector.

Then select DataCheckBox item from the Component Palette.

And add a new checkbox to the CustomerFeedback tab.

Select the Entity item from DataSource field in the Component Inspector.

Then select ConfirmedByCustomer item from DataField.

Select DataMemo from Component Palette and add new text field (datamemo) item to the Customer Feedback tab.

Result:

Close the Entity Properties form by clicking the red X button at top of the form. Component Inspector, Component palette, Form Explorer will disappear.

Then right-click the form and select Save Form to CustomerFeedback.

New items are in the form.

For more information, see Set Default Values.

Set Default Values

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Set Default Values

How to Define Default Values

If you need to change the default value for new items, do the following:

Right-click the form (Entity Properties form in our example) and select Default Values for Class.

We want the Confirmed by customer checkbox to be selected by default for new entities.

Select property name and click the Default Value column. Then press F2 to edit the value.

Select where the definition will be stored. In our example, we need to store it into the CustomerFeedback package.

Click the dialog to confirm your selection in combo box and then confirm OK.

Done.

For more information, see Add Events.

Add Events

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Add Events

The following events are available in Toad Data Modeler scripting:

  • OnCreate
  • OnCheck
  • OnChange
  • OnClick
  • OnClickSilent
  • OnClose

Let's add OnCheck event to the checkbox on the Customer Feedback tab of the Entity Properties dialog. When the checkbox is selected, the text box with Notes from Customer will be visible. When the checkbox is unchecked, the text box will disappear.

In Package Explorer, select the Script folder under the CustomerFeedback package. Right-click it and select AddScript.

Set the script name to FmPEREntityEdit. - This is the name of the form we want to write the script for. See the "Modifying a Form" topic to find out where the form name is defined.

Set visibility to Oracle 10g only.

Close the window, right-click the script again and select Edit Source Code.

Add there the event function.

Code:

function DataCheckBox1OnCheck()

{

    if(DataCheckBox1.Checked == true)

        DataMemo1.Visible = true;

    else

        DataMemo1.Visible = false;

}

Explanation of items in bold.

DataCheckBox1OnCheck()

  • DataCheckBox1 - name of item that has been added to the Entity form.
  • OnCheck - name of event.

DatacheckBox1 and DataMemo1

  • Both are names of items that were added to the Entity form. Modify Form

Press Commit to confirm the script.

Result:

When the checkbox is unchecked, the text area is hidden.

If you select the checkbox, the text area will display.

For more information, see Access Property Values via Scripting Window.

Access Property Values via Scripting

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Access Property Values via Scripting

You can write scripts inToad Data Modeler , save the scripts to packages, distribute the packages etc. - This will be explained later. Now you will see how to work with Scripting Window that allows you to run scripts at once, without the necessity to have them stored in packages.

Click Expert Mode | Scripting Window to open it. (Of course, Expert Mode has to be turned on.)

The following dialog appears. If you don't see the upper part of the Scripting Window, select View | Show Registered Objects.

On the left, you can see available models. Use the arrows to select model you want to work with. In our example, we will execute script for Videorental model (for Oracle 10g).

In the Name in Script column, you can define name that will be used in the script. Our OrigModel value will represent the selected Videorental model.

Write script to the main() function.

Code:

function main(){

 

  var i, e;  

  var Ent;

  var EntListConfirmed = new Array();

  var EntListNotConfirmed = new Array();

 

  // iterate through entities and check the value of ConfirmedByCustomer property    

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

  {

         

          Ent = OrigModel.Entities.GetObject(i);

          if(Ent.ConfirmedByCustomer == true)

            EntListConfirmed[EntListConfirmed.length] = Ent.Name; // add to list of confirmed entities

          else    

            EntListNotConfirmed[EntListNotConfirmed.length] = Ent.Name; // add to list of not confirmed entities

  }

       

  // write list of confirmed entities to Log.

  Log.Information ("--------------------------------------");

  Log.Information ("List of entities confirmed by customer");

  Log.Information ("--------------------------------------");

  for (e=0; e<EntListConfirmed.length; e++)

  {

    Log.Information(EntListConfirmed[e]);

  }

  Log.Information ("# Number of confirmed entities: "+EntListConfirmed.length.toString());

       

  // write list of NOT confirmed entities to Log.  

  Log.Information ("--------------------------------------");

  Log.Information ("List of entities NOT confirmed by customer");

  Log.Information ("--------------------------------------");

  for (e=0; e<EntListNotConfirmed.length; e++)

  {

    Log.Information(EntListNotConfirmed[e]);

  }  

  Log.Information ("# Number of NOT confirmed entities: "+EntListNotConfirmed.length.toString());

 

}

Where to find information about objects and their properties and methods?

Explanation of Items in Bold:

OrigModel.Entities.Count

  • OrigModel - represents object assigned in the upper part of the Scripting Window (Videorental object renamed to OrigModel).


  • Entities - we work with Physical Entity Relationship model, therefore we need to search for PER object. Model is for Oracle 10g, let's find the PERModelOR10 object in the Reference.

  • Count - represents a feature that is available for all List objects. On the screenshot above, you can see that the Entities datatype is a List. Let's click the List link and see details of the List class.

OrigModel.Entities.GetObject(i)

  • GetObject - belongs to the List class.

Ent.ConfirmedByCustomer

  • Ent - is a variable that holds assigned Entity objects (assigned earlier using the OrigModel.Entities.GetObject(i)function).
  • ConfirmedByCustomer - property of PEREntityOR10 object, added to Metamodel of the CustomerFeedback package.

Ent.Name

  • Ent - is a variable that holds assigned Entity objects (assigned earlier using the OrigModel.Entities.GetObject(i)function).
  • Name - property of PEREntityOR10 object. We still work with PER model and now we need to find property of Entity in Oracle 10g model. Let's see properties of the PEREntityOR10 object.

.length and .toString()

  • both are standard JavaScript items.

Executing the Script

Click Execute Script. Result will be displayed in the Message Explorer and Log area.

For more information, see Create Script.

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating