Chat now with support
Chat with Support

Toad Data Modeler 6.3 - 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

Create Script

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Create Script

You know how to execute scripts from the Scripting Window. If you want to store the script and call it from another form in the application, for example, do the following:

Create a new script WriteFeedbackToLog. See the "Adding Events" topic to find out how to create new scripts.

Write there function WriteFeedback.

Code

function WriteFeedback ()

{

  var Log = System.CreateObject('Log');

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

  var OrigModel;

  OrigModel = Application.Models.GetObjectByID(Model.ID);

  ....

  ....

}

Explanation

The WriteFeedback function is almost identical to the Main function we were executing from the Scripting Window.

The only difference is in the definition of OrigModel object. In the Scripting Window, we could select Videorental and define the OrigName name.

However, now we have no means to select the object visually (and we do not need it, the function will be executed for active model). Therefore we need to define the OrigModel object via Application.Models.GetObjectByID method, with parameter Model.ID.

This way we can get the currently active model.

We also need to register object Log. (It is not necessary to register Log in the Scripting Window. Log is registered in the Scripting Window automatically.)

The rest of the script is identical.

For more information, see Call Existing Script from Model Properties Form.

Call Existing Script from Model Properties Form

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Call Existing Script from Model Properties Form

Edit the Model Properties form. See the "Modify Form" topic to find out how to edit existing form.

Add there a new button and remember the name of the form - FmPERModelEdit. The name can be found in the Form Explorer.

Defined caption for the button - Write Customer Feedback To Log.

Set the name of the button to FeedbackButton.

Create a new script with the name of the Model Properties form - FmPERModelEdit.

Write event function to the script.

Code

function FeedbackButtonOnClick()

{

  WriteFeedbackToLog.WriteFeedback()

}

Explanation

  • FeedbackButton = name of the button.
  • OnClick = event.
  • WriteFeedbackToLog = name of script that contains called function.
  • WriteFeedback = called function.

When you click the button, an output will be displayed in Message Explorer (Log).

For more information, see Modify HTML Reports.

Modify HTML Reports

Features and Tools > Scripting and Customization > Scripting and Customization Sample > Modify HTML Reports

To modify HTML reports, we need to extend existing method. The first thing we need to do is to find out what script should be extended.

In Script Explorer, you can see BasicHTMLPERReportOR script with function ReportTableUserProperties. This is the script that generates Tables pages in HTML reports, specifically the section Table Properties.

You can also see script BasicHTMLPERReportOR10 that extends the BasicHTMLPERReportOR script.

Now we now need to write a script that will extend the ReportTableUserProperties function defined in the BasicHTMLPERReportOR script.

For that purpose, we need to open our CustomerFeedback metamodel and the method there.

Open the CustomerFeedback metamodel, add there a new class (see the Class icon in the toolbar), edit the class and set the name to BasicHTMLPERReportOR10. (One extension of that class already exists, in our metamodel we will create another extension of the class).

Define Object Type (the value can be currently found out in metamodel to HTML report for Oracle 10g package).

Add the ReportTableUserProperties method to the class.

Add two new parameters to the method. (The method name and number of parameters must be identical to the original method - see the first screenshot).

Return back to the General tab. Click Reload. Script name and method name will appear there. Add a prefix My to it (this will be changed in future, no manual modification will be required).

Click Edit Script.

Click OK and define code for the ReportTableUserProperties method that extends the existing method of the same name.

Code:

function ReportTableUserProperties(Document, Entity)

{  

  // Table definition

  Table = Document.CreateTable(false,true);

  Table.CreateColumn(20);

  Table.CreateColumn(80);

  var row = -1;

 

  if (Entity.ConfirmedByCustomer == true)

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'Yes' );

  }

  else if (Entity.ConfirmedByCustomer == false)

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'No' );

  }

  else

  {

    Table.CreateCell( ++row,0,'Confirmed' );

    Table.CreateCell( row,1,'Undefined' );

  }

 

  if (Entity.NotesFromCustomer.length > 0)

  {

    Table.CreateCell( ++row,0,'Notes from Customer' );

    Table.CreateCell( row,1, Entity.NotesFromCustomer );

  }

 

  if (row > -1)

  {

    Document.WriteStyled( 'CAPTION2', 'Customer Feedback' );

    Table.Draw();

    Table.Close();

  }        

 

  Instance.ReportTableUserProperties(Document, Entity);

 

 

};

Explanation

Table.CreateColumn(20) - the CreateColumn function belongs to the HTMLReportTable class. All functions related to the Table object can be found in the Toad Data Modeler Reference.

Entity.ConfirmedByCustomer - represents the variable we added earlier to the CustomerFeedback metamodel.

Entity.NotesFromCustomer.length - standard JavaScript function that returns number of characters of the NotesFromCustomer string.

Document.WriteStyled - represents function that belongs to the HTMLDocument class.

Instance.ReportTableUserProperties(Document, Entity);

  • Instance - using the Instance keyword, we can call existing function we extended. We could copy and paste the content of the ReportTableUserProperties function defined in the BasicHTMLPERReportOR script. However, if a change was made to the script later, we would have to update our script too, which would be difficult to maintain. That's why it's better to write code that will extend the existing functionality only, and call the rest from existing script via the Instance keyword.
  • ReportTableUserProperties - represents existing function we call.

When you generate HTML reports now, you will see the following output. New section Customer Feedback is generated on top, followed by the Table Properties part, as originally defined in the ReportTableUserProperties function in script BasicHTMLPERReportOR.

Customize Forms and Frames

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating