Welcome to the Toad Data Modeling Community

 

Archive for July, 2008

How To Use Combo Boxes in Customized Forms

Thursday, July 31st, 2008

Hi All,

In this article, I will explain how to use DataComboBox, DataStaticDataComboBox and ComboBox components for form customization.

If you wish to follow all steps one by one, please download the ComboBoxExamples package and copy it to the same folder where the “My Package.txg” file is. Possible path: Documents and Settings\{user name}\My Documents\Toad Data Modeler\Packages\{Guid}\ .
Then enable Expert mode via Settings | Options | General item and select the Expert Mode checkbox. Finally click the Expert Mode item and clear the Save the definitions to ‘My Package’ package checkbox and restart Toad Data Modeler.

Let’s say we have a simple model with three entities, one stored procedure and one synonym.

In order to modify the form, we have to edit the existing synonym, right-click the form and select Customize Form as

As you can see, there are four new items on the form.

  • Entities (DataComboBox) - this item allows you to select entity from a list of entities and assign its value to the system ‘Object’ combo box. We can pass objects to other objects of Dispatch type.
  • DBLink (DataStaticComboBox) - this item will work as a replacement for the ‘Dblink’ field. We can pass values to other objects of String type.
  • Last combo box on the form contains items that can be used for verification. We can define combo box with defined values, don’t store the values anywhere but use values for events, in this case for verification.

Select the ComboBoxesExample package.

Modified form in Edit mode will open.

DataComboBox
Click the DataComboBox item.

In Component Inspector, see properties:

  • DataSource = Synonym
  • DataList = Entities (here we can select lists of objects)
  • DisplayPropertyName = Name (here we can select any property of Entity object)
  • DataField = Entity (property of type Dispatch)

DataComboBox should be used whenever you need to select an item from a list of existing objects and fill property of Dispatch type.

DataStaticComboBox
Click the DataStaticComboBox item.

In Component Inspector, see properties

  • DataSource = Synonym
  • DataField = Dblink (property of type String)
  • Items = defined list. Click the IDispatch item and press F2. Then click the three dots button to open appropriate dialog where you can manually specify the values.

DataStaticComboBox should be used whenever you need to select an item from predefined list fill property of String type.

ComboBox and Events
Click the last combo box on the form.

In Component Inspector, see properties:

  • Items = defined list of items. Click the IDispatch item and press F2. Then click the ‘…’ button to open appropriate dialog where you can specify values manually.

The simple ComboBox component should be used in combination with defined Events. Click the Verification button and see its name in Component Inspector.

The name is BtnExample. It is important to know the name becase event name must be formed as a combination of component name and event name. In our case, we will need a script that will contain BtnExampleOnClick function. Using this event we will be able to verify if object or entity has been assigned to the synonym. If we select ‘All’ from the last combo box and no object will be assigned, a message box with text “Nothing assigned ” will appear. Otherwise “Object assigned” or “Entity assigned” text will be displayed. Note: Remember to press Apply after changing values in Entity(DataComboBox).

Let’s see the definition of this script.

function BtnExampleOnClick()
{
var text = 'Nothing assigned ';
var Model = Synonym.Root();
var OrigSynonym = Model.Synonyms.GetObjectById( Synonym.Id );
// We need to read original object. 'Synonym' is only a temporary
// object (created when a form is edited) that that doesn't have
// all properties loaded/filled.
if (CBMSGDlg.Text == 'All')
{
if (OrigSynonym.Object!=null) text = 'Object is assigned';
}
else
{
if (OrigSynonym.Entity!=null) text = 'Entity is assigned';
}
System.ShowMessageDialog(1000,'Synonym Verification',text,3,4+8);
/* Opens new dialog

param1 - index of dialog for each dialog must be unique index
to implement the "Don't show again" function
param2 - Form name
param3 - Text of message
param4 - Type of dialog you can choose
Warning - 1
Error - 2
Information - 3
Confirmation - 4
Custom - 5
param5 - Buttons you can choose
1 - Yes
2 - No
4 - Ok
8 - Cancel
16 - Abort
32 - Retry
64 - Ignore
128 - All
256 - No to All
512 - Yes to All
1024 - Help
*/
}

MessageDialog
On line 17, you can see how to display MessageDialog via scripting.

Result:

That’s all. For more information about how to create a new package, how to create new scripts etc. please see out Toad Data Modeler Manual, section Customization | Customization Sample.

Regards,

Vaclav

Toad Data Modeler 3.2.4 Released!

Monday, July 21st, 2008

Hello,

I am pleased to announce the release of Toad Data Modeler 3.2.4.

This version brings many new features and enhancements, and more than one hundred resolved issues reported by users of Toad Data Modeler.

============
New Features
============
- Support for Oracle 11g
- Support for MS Access 2000/2002/2003
- Possibility to Load Oracle Models from SQL Script in the RE Wizard and via LIVE RE (Via LIVE RE, you can load besides Entities, Views and Synonyms also Types, Functions, Procedures, Materialized views etc. - just drag&drop the selected items!)
- New functions ‘Simple Model Conversion’ and ‘Simple Model Merge’
- Possibility to design relationship lines in right-angled mode, change lines from straight to right-angled, move selected line segments, align break points, move relationship caption.
- and much more.

For more information on the new release, please read the announcement posted in the Modeling community at:
http://modeling.inside.quest.com/thread.jspa?threadID=7157&tstart=0

Thank you.

We look forward to your feedback!

Regards,

Vladka & TDM Team

How to Estimate Database Size

Thursday, July 17th, 2008

Hi,

in this article you will find out how to take advantage of internal scripting to estimate database size. I will show you how to enable Expert Mode and how to write and execute a script that will iterate through all entities and process some entitity properties.

As you probably know, in both Physical and Logical models you can specify Size on the Entity Properties dialog. In my example, I will use the Videorental sample - physical model for Oracle 10g.

Step 1: Open Sample Model
Click File | Open Samples… and select the Videorental model.

Step 2: Define Sizes for several entities
Edit several entities and define SIZE.

Step 3: Enable Expert Mode
a) Click Settings | Options and select tab General.
b) Enable the Expert Mode checkbox.

Step 4: Open Scripting Window
a) Click Tools | Scripting Window.
b) Click View | Show Registered Objects.

On the left side, you can see a list of currently opened models. Only the Videorental sample is available in my example. Let’s select the Videorental item and click the Right Arrow button to move it to the box on the right.

Step 5: Change Name in Script
Click the Name in Script item and rename it to ‘Model’.

Step 6: Define the Function main() content

Define function main() this way:

function main()
{
var e, Entity, dbSize;
dbSize = 0;
Model.Lock();
for (e=0; e<Model.Entities.Count; e++)
{
Entity = Model.Entities.GetObject(e);
Entity.Lock();
dbSize += Entity.Size;
Entity.UnLock();
}
Model.UnLock();
Log.Information("Estimated database size is: "+dbSize + "MB");
}

Script explanation:

  • function main() is the only executable function. You can write sevelar functions but only function main() will be executed after clicking on the green Execute Script icon.
  • On line 3, you can find definition of three variables. Variable ‘e’ will be used for iteration, to ‘Entity’ I will assign particular entity (object) and dbSize will represent the final estimated size of my database.
  • On line 6, you can see ‘for’ loop where the number of entities is accessed via Model.Entities.Count. Where to find out how to access the number of entities? - In Reference Guide. Click Help | Reference and see PERModel class. PER = Physical Entity Relationship.

Model has Entities. Entities is a List. Click the List link to see properties of the List class.

List class has the Count property. The Reference Guide document contains all accessible objects, its functions, properties and some other valuable data. Back to our script….

  • On line 10, the value of SIZE property of particular iterated entity is added to the current value of the dbSize variable. Again, how will you find out that Entity.Size can be used for getting the value of SIZE property? Open the Reference Guide and select the PEREntity class. You will find there the ’size’ property.

Note: If you want to access property specific for Oracle 10g database, select PEREntityOR10 class etc.

  • The rest of the script is, I believe, self-explanatory.

Step 7: Execute Script
Click the Execute Script icon (green arrow) and see the result.

Of course, you can modify the script e.g. to filter entities by Schema and output subtotals and so on.

I look forward to your feedback. :)

Regards,

Vaclav