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.
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.
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.
The following events are available in Toad Data Modeler scripting:
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.
if(DataCheckBox1.Checked == true)
DataMemo1.Visible = true;
DataMemo1.Visible = false;
Explanation of items in bold.
DatacheckBox1 and DataMemo1
Press Commit to confirm the script.
When the checkbox is unchecked, the text area is hidden.
If you select the checkbox, the text area will display.
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.
var i, e;
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
EntListNotConfirmed[EntListNotConfirmed.length] = Ent.Name; // add to list of not confirmed entities
// write list of confirmed entities to Log.
Log.Information ("List of entities confirmed by customer");
for (e=0; e<EntListConfirmed.length; e++)
Log.Information ("# Number of confirmed entities: "+EntListConfirmed.length.toString());
// write list of NOT confirmed entities to Log.
Log.Information ("List of entities NOT confirmed by customer");
for (e=0; e<EntListNotConfirmed.length; e++)
Log.Information ("# Number of NOT confirmed entities: "+EntListNotConfirmed.length.toString());
.length and .toString()
Click Execute Script. Result will be displayed in the Message Explorer and Log area.