サポートと今すぐチャット
サポートとのチャット

Toad Data Modeler 7.3 - User Guide

Introduction User Interface Models and Model Objects
Physical Data Model
Entity Relationship Diagram Objects Basic Database Design Advanced Database Design
Universal Data Model Logical Data Model Working with Model Objects
Features and Tools
Application Variables Export/Import DDL Script Generation Graphics Model Actions Print Create New Project Reports Reverse Engineering Scripting and Customization About Templates Tips and Tricks Toad for Oracle Integration Toad Intelligence Central (TIC) Integration Tools Version Control
Options and Configuration Databases
Amazon Redshift 1.0 IBM DB2 LUW 9.5 IBM DB2 LUW 9.7 IBM DB2 LUW 10.1 IBM DB2 LUW 10.5 IBM DB2 LUW 11.1 IBM DB2 z/OS 10 IBM DB2 z/OS 11 Greenplum 4.1 Greenplum 4.2 Ingres 9.3 Ingres 10.0 EDB Postgres Advanced Server 10 Microsoft Access 2007/2010 Microsoft Azure SQL Database V12 Microsoft SQL Server 2005 Microsoft SQL Server 2008 Microsoft SQL Server 2012 Microsoft SQL Server 2014 Microsoft SQL Server 2016 Microsoft SQL Server 2017 Microsoft SQL Server 2019 MySQL 5.0 MySQL 5.1 MySQL 5.5 MySQL 5.6 MySQL 5.7 MySQL 8.0 Oracle 10g Oracle 11g Release 1 Oracle 11g Release 2 Oracle 12c Release 1 Oracle 12c Release 2 Oracle 18c Oracle 19c PostgreSQL 9.0 PostgreSQL 9.1 PostgreSQL 9.2 PostgreSQL 9.3 PostgreSQL 9.4 PostgreSQL 9.5 PostgreSQL 10 PostgreSQL 11 PostgreSQL 12 SQLite 3.7 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
Copyright Legal Notices

Creating New Objects

In this topic you can find information about how to create new objects via scripting.

Creating a New Entity

function main()

{

var app = System.GetInterface('Application');

var Model = app.Models.GetObject(0);

Model.Lock();

var Entity = Model.CreateNewObject( 2002 ); // 2002 is object type of PEREntity

Entity.Name = 'Customer';

Model.UnLock();

Model.RefreshModel();

}

More information about the Entity object can be found in the Reference Guide (in Expert Mode main menu, Expert Mode has to be enabled first). See PEREntity class or PEREntityOR (for Oracle) class etc.

Creating a New Index

function main()

{

var app = System.GetInterface("Application");

var Model = app.Models.GetObject(0); // gets first model in application

Model.Lock();

var Entity = Model.Entities.GetObject(0); // gets first entity in model

Attribute = Entity.Attributes.GetObject(0); // gets first attribute in entity

var Index = Entity.CreateNewObject( 2012 ); // 2012 is object type of PERIndex

Index.Name = "IXName";

var IndexItem = Index.CreateNewObject ( 2013 ); //2013 is object type of PERIndexItem

IndexItem.Attribute = Attribute;

Model.UnLock();

Model.RefreshModel();

}

Creating a New Domain

function main()

{

var app = System.GetInterface('Application');

var Model = app.Models.GetObject(0);

var Domain;

var DataType_Number = Model.ModelDef.DataTypes.GetObjectById("{3A22E4F9-EE24-4A39-835D-62C3EF76CAA4}"); // Number(x,y);

Model.Lock();

Domain = Model.CreateNewObject( 2006 ); // 2006 is object type of PERDomain

Domain.Name = 'MyDomain';

Domain.SetLinkedObject("DataType", DataType_Number);

Domain.DataTypeParam1 = "10";

Domain.DataTypeParam2 = "2";

Model.UnLock();

}

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

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

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.

関連ドキュメント

The document was helpful.

評価を選択

I easily found the information I needed.

評価を選択