Toadfordataanalysts User Guide
Toadfordataanalysts User Guide
User Guide
2012 Quest Software, Inc.
This guide contains proprietary information protected by copyright. The software described in
this guide is furnished under a software license or nondisclosure agreement. This software
may be used or copied only in accordance with the terms of the applicable agreement. No
part of this guide may be reproduced or transmitted in any form or by any means, electronic
or mechanical, including photocopying and recording for any purpose other than the
purchasers personal use without the written permission of Quest Software, Inc.
If you have any questions regarding your potential use of this material, contact:
www.quest.com
email: [email protected]
Refer to our web site for regional and international office information.
Trademarks
Quest, Quest Software, the Quest Software logo, Benchmark Factory, Toad, T.O.A.D.,
Toad World, and vToad are trademarks and registered trademarks of Quest Software, Inc
in the United States of America and other countries. For a complete list of Quest
Softwares trademarks, please see http://www.quest.com/legal/trademark-information.aspx.
Other trademarks and registered trademarks used in this guide are property of their
respective owners.
Understand 10
Determine the Best Method to Locate Objects 10
Object Explorer 10
Filter Databases and Objects 11
Tutorial:Understand a Table Using the Database Explorer 13
Search for Objects 16
Tutorial:Create a Database Diagram to Use as a Query Template 17
Browse Data in Related Tables 19
Query 21
Tutorial:Visually Build a Query 21
Create Cross-Connection Queries 23
Considerations and Limitations of Cross-Connection Queries 25
Tutorial:Build a Subquery 30
About Editing SQL 33
Configure Editor Options 35
Troubleshoot Data 38
Manage Reports 51
About Managing Reports 51
DB2 Reports 52
MySQL Reports 56
ODBC Reports 56
Oracle Reports 56
Find Unbatched Transactions (Use the Row Count Field and If..Condition..
Activity) 87
Note: If creating an Oracle ODBC connection, select the ODBC driver provided by
Oracle. The Microsoft ODBC for Oracle driver has less functionality than the driver
provided by Oracle.
6. Specify the configuration properties required for the database in the windows
configuration dialog.
Notes:
l If you have an Oracle database with Unicode data, make sure to select Force
SQL_WCHAR Support on the Workarounds tab of the windows Oracle ODBC
Configuration dialog. If you do not, you will not be able to see the data.
l If creating a MySQL ODBC connection to use in a cross-connection query,
you must specify a database in the windows MySQL ODBC Configuration
dialog. See Troubleshoot MySQL Issues for more information.
7. Specify the connection properties in the Create New Connection dialog. Review the
following for additional information:
Data source Select the driver or data source name you added in the previous
Toad for Data Analysts User Guide 8
Connect
name steps.
Information
Driver Displays the ODBC driver associated with the data source.
Category Select or create a category if you want to color code Editor tabs
for a specific connection. This can help differentiate between
development and production databases. You can also set an
option to color code the Object Explorer pane and object editor
windows (Create, Alter, Drop, etc.). Click here to view a
video of this feature.
8. Click Connect to save the connection and immediately connect to the database.
or
Tip:Connections are stored in the connections.xml file and can be found by clicking the
Application Data Directory link in Help |About.
Click here to view a video about creating connections in Toad for Data Analysts
Tips:
l To view the number of actual database connections that exist for a Toad connection
and how many of those database connections are active, place the cursor over the
connection in the Navigation Manager or the Connection toolbar (illustrated in the
following example).
l You can view the progress of statements executing in the background in a progress
bar located on the lower right side of the status bar. To cancel a script's execution,
click the progress bar to display the Background Processes window. It is
recommended to cancel only your own processes, as terminating Toad activities may
lead to unexpected behavior.
l (DB2 and Oracle only) If your database supports executing multiple queries
simultaneously on a shared connection, the query is placed in a queue and executes as
soon as the current operation completes.
l If your database does not support executing multiple queries on a shared connection, a
dialog prompts you to either permanently associate the window with a new database
connection, cancel the previous operation, or add the query to a queue until the
current operation completes, and the execute it. If you place multiple queries in the
queue, each one executes in the order that it was added to the queue.
Note: Although you can share a database connection, any commits apply to the selected
window only.
3
Understand
Column name, but do not know the table Use Object Search
name
Object Explorer
You can view database objects for the current connection with the Object Explorer. This
feature is useful for dragging and dropping database objects into an open Editor, Query
Builder, or other document window. Right-click the objects in the Object Explorer to access
additional features such as multiple tasks and actions.
Schema (first Select the schema you want to view. You can filter the list of
field) schemas that display. See "Filter Databases and Objects"
(page 11) for more information.
Object Filter You can quickly set a filter in this field. To do so, enter a
(second field) name or partial name of an object and press ENTER. Any
advanced object filters you set display in this field.
You can also perform advanced filtering based on case
sensitivity, statistics, or other options. See "Filter Databases
Toad for Data Analysts User Guide 11
Understand
Note: For tables and views, the columns, data types, and comments display at the
bottom of this window.
Tips:
l To navigate to a previously selected object, click . You can also click to move
to the next selected object.
l To locate objects including procedures, functions, views, variable names and
comments in an object's source code, use Object Search. See "Search for Objects"
(page 16) for more information.
l To use a different method to select objects such as tabs, drop-downs, or a tree
view, click .
l To generate reports, export data, create SQL statements, version control objects, or
send objects to the Project Manager, SQL Modeler, or Master Detail windows, right-
click the objects and select an option.
l To open the Background Processes window and cancel a query, click the progress bar
at the bottom of the window.
l Quick filterApplies to the current schema, or objects in the current schema only.
Any unnamed filter you set is in effect the next time you open Toad
l Unnamed filterApplies to the current schema, or objects in the current schema only.
Any unnamed filter you set is in effect the next time you open Toad.
l Named filterApplies to any database connection for the current database provider.
Any named filter you set is in effect the next time you open Toad.
Note: If you rename a table that has a filter defined, it results in an orphaned filter.
Orphaned filters are automatically removed unless you used a tool other than Toad to
remove them.
A filter is associated with a specific list of objects from a specific database. Consider the
following guidelines when setting filters:
Toad for Data Analysts User Guide 12
Understand
l A filter defined for a set of objects such as tables on one specific database connection
does not apply to a list of objects for another database connection.
l A filter defined for a list of tables on one schema in the database does not apply to
the list of tables for a different schema on the same database.
l A filter set for a specific schema or object is applied when altering objects, using the
SQL Editor, Master Detail Browser, etc., for that schema or object.
Tip: To apply any filters you set to the code completion list in the editor, select the
Apply explorer filters checkbox in Tools |Options | Editor |Code Completion.
Enter text to use for filtering in the field below the database/schema name in the
Object Explorer:
5. Enter a name for the filter if you want to use the filter for other database connections
and click .
Icon Description
6. If you set a named filter, you can click the arrow beside the icon to apply or
remove the filter:
Tips:
l To export a named filter or any filters associated with the current connection, click the
arrow beside the icon and select Export Filters.
l Click in the Explorer toolbar to clear all database, object, and data filters.
Scenario
You need to build a query listing customers and want to know more
about the table before writing the query.
Note: This exercise uses the Toad Sample Database. This connection
does not have the relationship and script tabs. The tabs available can
differ depending on the type of connection.
Note: This topic focuses on information that may be unfamiliar to you. It does not include all
step and field descriptions.
5. Place the cursor over the LAST_NAME column, click , and select Acton.
The only row that now displays is the one with Acton as the last name.
6. Click to the right of the LAST_NAME column again and select All to
clear the filter.
7. Click the CONTACT_ID column to sort the rows in ascending or descending order.
The filter string displays at the bottom on the grid. Click to remove the filter.
Toad for Data Analysts User Guide 15
Understand
10. Select a row of data in the grid. Notice that the row number changes in the bottom
right of the status bar:
11. Under the SEX column, right-click the area below the last row in the grid that says
"Right-click to add column totals" and select Count. The total number of rows that
have either a M or F value display.
12. Click to the right of the SEX column and select F. The count value updates based
on the new filter.
13. Click to the right of the SEX column again and select All to clear the filter.
14. Select the SEX column header and drag it the area above the columns that says "Drag
a column header here to group by that column":
c. Go to the BIRTH_DATE column and use the date picker to change the date.
Note: If you are using Oracle or a database that does not have auto commit on,
you will need to press Commit at the left hand bottom of the window.
d. Press F5 in the data grid. Notice the bottom right status bar now says "1 of 50
(scroll for more)".
The option you set controls the number of rows fetched in the Data tab.
l Text in objects that include source code, which typically includes procedures,
functions, triggers, data types, and views. However, the database provider determines
which objects include source code.
Note:To append additional search results to the current search, click Append instead.
If you click Search, new results replace the previous search results in the data grid.
Toad for Data Analysts User Guide 17
Understand
Tips:
l To remove objects from the search results, right-click the objects in the data grid and
select Remove Items. This is useful if you want to narrow the list of results to
relevant objects.This does not remove the objects from your database.
l To create a DDL script from the search results, right-click the data grid and select
Create DDL Script. You can then paste the results into the Editor.
l To perform any actions available for the object, such as creating, altering, dropping,
exporting, and generating reports or SQL, right-click the results in the data grid and
select an option.
Scenario
Your company creates several daily and weekly reports regarding
customer sales. You need to create a Database Diagram that can be
used as a template for these queries.
2. Click .
4. Right click the Diagram pane and clear Show Dependencies to hide the Referenced
Objects at the bottom of each table/view, as illustrated in the following:
The shipping and billing ADDRESS_ID foreign key relations are not needed in most
queries and should be hidden when building a query.
Toad for Data Analysts User Guide 19
Understand
7. Because it is against company policy to display sex and a home phone number in
reports, right click on each of these columns in the CONTACT table and select
Hide Column.
Tip:If you have a large number of columns you need to hide, you can right-click a
table and select Manage Hidden Columns to quickly select them from a list.
8. Click Add to Project from the wizard bar at the bottom of thewindow and enter
DBDiagram_Test asthe name for the file. This adds the file to the current project in
the Project Manager under a Diagrams folder.
9. Close the Database Diagram window and open the Project Manager window.
10. Expand the Diagrams folder and double-click DBDiagram_Test to reload the file in a
new Database Diagram window.
11. To share your project, hidden columns, and notes with colleagues, complete
the following:
a. Select Tools | Options | Environment |Network Share, and navigate to a
shared drive where you want to store the Project Manager file.
b. Select Database |Cache from the open Options window and set the
following options:
Object An Description
notation Cache
c. Provide the location of the Network Share and Object Annotation Cache
settings to colleagues who need to use this diagram.
2. Drag one or more tables from the Object Explorer, Object Search, or Project Manager
Toad for Data Analysts User Guide 20
Understand
window to the Diagram pane at the top of the Master Detail Browser. Press
CTRL+click to select multiple tables at once.
Notes:
l At least one parent table (table without any join arrows pointing to it) must be
added to the window or an error message displays when returning results.
3. Join Columns.
Note: Any columns included in a join are automatically included in the results.
5. Click (F9) to retrieve data for the parent table initially. To view data in a child
table, click + to the left of each row.
or
Click to retrieve data in the parent and child tables. If there is more than one child
table, a tab displays for each child table.
l Right-click the data grid and select Send To | option to add the data to a
report, chart, or pivot grid.
Tips:
l Click X on the table you want to remove in the Diagram pane to remove a table and
any conditions (e.g., join, where clause) associated with the table.
4
Query
Note: This procedure does not cover all of the possible steps of visually building a query. It
only covers the steps required to build a query for the scenario.
Scenario
Your company wants to improve its global sales, starting with
countries where it has a customer base but generally low sales. You
need to create a query that identifies countries with less than
$500,000 in sales for each of the last four fiscal years.
Note: This scenario uses the SH (Sales History) sample schema that
comes with Oracle 10g so you can follow the procedure.
3. Drag the following tables from the Object Explorer to the Diagram pane: TIMES,
SALES, CUSTOMERS, and COUNTRIES.
Tips:
l Select Query Builder |Arrange Tables (ALT+Q+A) to have Toad arrange the
tables in the Diagram pane.
l You can press CTRL and select a table, and then drag the table into the Editor
pane. Click the list to create statements.
l You can also press CTRL and select all of the tables in the Object
Explorer, and then drag them into the Diagram pane. Toad automatically
arranges the tables.
4. Add the following columns to the query by clicking each column:
Table Column
COUNTRIES COUNTRY_NAME
Toad for Data Analysts User Guide 22
Query
Table Column
TIMES FISCAL_YEAR
SALES AMOUNT_SOLD
Tips:
l To view details for a table in the Diagram, click (F4). If a table is not
selected, details for the last selected table display.
l To remove a column from the query, click or drag column off grid.
5. Complete the following steps to group the data and sum the sales:
a. Select the Group By field in the COUNTRY_NAME column, and then
click +. The Group By field is in the Criteria pane, which is below the
Diagram pane.
b. Select the Group By field in the FISCAL_YEAR column, and then click +.
Note: If you select a group by clause or aggregate function for a column, the
rest of the columns in the query must also have a group by clause or
aggregate function.
Note: The SH schema does not have current data. The 1998-2001 years
provide the best data for the purposes of this scenario.
7. Complete the following steps to select countries with less than $500,000 in sales:
a. Select the Having Condition field in the AMOUNT_SOLD column and click
. The Having Condition window displays.
b. On the Form tab, select < in the Operators field.
c. Select Sum in the Aggregate field.
d. Enter 500000 in the Constant field and click OK.
8. Select Ascending in the Sort field of the COUNTRY_NAME and FISCAL_
YEAR columns.
Toad for Data Analysts User Guide 23
Query
9. Click .
The query results display in the Results tab. See "View Result Sets" (page 38) for
more information.
10. To save the query, right-click the Query Builder tab and select Save File.
You can save a query and any results sets in a Toad editor file (.tef). This file format is
useful for building scripts that have large result sets that you do not want to continue
executing or for saving results when you have not finished building a script.
Note: A blue banner along the right side of the Diagram pane indicates that you are
in Cross-Connection Query mode.
2. Drag tables and views from the Object Explorer to the Diagram pane.
3. Complete the query in the same manner as you would a non-cross-connection query,
but note the following exceptions.
Note: A blue banner along the right side of the Editor pane indicates that you are in
Cross-Connection Query mode.
2. Compose the SQL statement in the same manner as you would a non-cross-connection
query, but note the following exceptions.
Naming tables and views To reference a table or view, you must use a cross-
connection fully-qualified name. The format for a cross-
connection fully-qualified name depends on the
database. The following is an example using the SQL
Server format:
<database connection
string>.<database>.<schema>.<table>
'sqlserverconn'.database.dbo.table
Note: For the database connection string, use the
connection string displayed in the Navigation Manager
window for each connection (or in the Name field in
Connection Properties).
Toad for Data Analysts User Guide 25
Query
Using alias names You must use alias names for tables and columns in a
cross-connection query.
Tips:
Consideration/Limitation Description
Toad Access database In the Base edition of Toad for Data Analysts, the
Query Builder uses the Access database installed with
Toad as a staging area for the query. Do not uninstall
this database if you need to create cross-connection
queries.
Consideration/Limitation Description
ODBC driver support An ODBC driver can be selected for a single connection
through each connection's Properties dialog or globally
through Tools | Options | Database.
Oracle Direct Connection You cannot use an Oracle Direct Connection in a cross-
connection query.
Oracle Long Data Type Cross-connection query does not support Oracle long
data types or Oracle LOBs.
General Description
Single statement The Query Builder only supports one statement at a time. If
support you add multiple statements to the Query tab, only the first
statement is used. If you make any changes to the statement
on the Diagram tab, the other statements are lost.
ODBC support You must use ANSI SQL for the query.
Non-ANSI joins When sending a query from the Editor to the Query Builder,
(Oracle only) Toad automatically uses ANSI joins. If you use Where clause
joins, click to disable ANSI joins. This converts the
statement to the correct join.
Where condition If you send a query that contains a Where condition from the
does not display in editor to the Query Builder, it displays in a Global Where
the Criteria grid after clause bubble on the Diagram pane instead of in the Where
sending it to the Condition field in the Criteria grid.
Query Builder from You can double-click the Global Where Clause bubble in
the Editor
the Diagram pane or can click to edit it.
You can also use the Where condition fields in the Criteria
grid to add new Where conditions. Although they display in
the grid, they are added to the Global Where clause in the
Query tab.
Where condition If you define a Where condition in the Criteria grid and edit
created in the any part of the query in the Query tab, the Where condition
Criteria grid of the is removed from the Criteria grid and placed in a Global
Diagram tab Where Clause bubble.
Toad for Data Analysts User Guide 28
Query
Having condition If you send a query that contains a Having condition from
does not display in the editor to the Query Builder, it displays in a Global
the Criteria grid after Having clause bubble on the Diagram pane instead of in the
sending it to the Having Condition field in the Criteria grid.
Query Builder from You can double-click the Global Having Clause bubble in
the Editor
the Diagram pane or can click to edit it.
You can also use the Having condition fields in the Criteria
grid to add new Having conditions. Although they display
in the grid, they are added to the Global Where clause in the
Query tab.
Having condition If you define a Having condition in the Criteria grid and edit
created in the any part of the query in the Query tab, the Having condition
Criteria grid of the is removed from the Criteria grid and placed in a Global
Diagram tab Having Clause bubble.
disappears You can double-click the Global Having Clause bubble in
the Diagram pane or can click to edit it.
Comments and code When reverse engineering a statement from the editor or the
regions removed after Query tab and switching to the Diagram tab, if the statement
making changes in contains a block comment or code region and you make a
the Diagram tab change in the Diagram tab, the comment or code region is
removed from the statement.
Same column cannot You cannot use the same column more than once in the
be used in the criteria grid. Even if you create a separate alias for the second
criteria grid use of the column, that column is created as a calculated
field
Execute with If the query in the Diagram tab is different than the query in
different query in the the Query tab, executing the query executes the SQL in the
Diagram and Query Query tab instead of the Diagram.
tabs
Save with different The Query Builder saves both the statement and diagram in
query in the Diagram the same file. The contents of the statement and diagram can
and Query tabs be different without losing changes.
Toad for Data Analysts User Guide 29
Query
1. Right-click a statement in the Editor, and select Send to Query Builder.See "About
Editing SQL" (page 33) for more information.
or
Click in the Query Builder to send a statement to the Editor. Skip the remaining
steps and continue to edit the query. See "About Editing SQL" (page 33) for more
information.
3. Select the Query tab and make any additional edits. Indicators for an edited statement
are as follows:
Inserted lines
Modified or removed lines
Modified characters
Use the toolbar in the lower-right corner of the Query tab to modify
the color used for each indicator.
Caution: If you manually enter or update the statement in the Query tab, you
must click to model the query in the Diagram tab. If you do not do this and
make additional changes in the Diagram tab, any changes you made in the Query
tab are lost.
Tip: If you have multiple statements in the Editor and you want to send only one to the
Query Builder, highlight the statement, then right-click it and select Send to Query Builder.
Tutorial:Build a Subquery
Scenario
Your database of customer information includes detailed information
for each contact you have within a customer. You need a report that
lists all of your customers that have a contact that resides in (or
covers) a specific region.
To build a subquery
2. Click .
3. Drag the CUSTOMER table to the Diagram pane.
4. Click these column names in the CUSTOMER table to add the columns to the query:
l CUSTOMER_ID
l CUSTOMER_NAME
5. To add a subquery:
a. Select the Where field in the CUSTOMER_ID column and click . The
Where Condition editor displays.
b. Select the INoperator from the list and click Subquery. A child Query Builder
Toad for Data Analysts User Guide 31
Query
c. Drag the following tables to the Diagram pane and select the
following columns:
ADDRESS REGION_ID
CONTACT CUSTOMER_ID
d. Select the Where field in the REGION_ID column and click . In the Where
Condition editor, select the equal to (=) comparison operator, select Constant,
and select a value of 1.
e. Deselect the checkbox in the Visible field in the REGION_ID column. This
will remove the REGION_ID column from the result set.
Use the lookup table to add a description to ID values to aid in selecting from ID columns
when building a query or subquery.
1. Click the subquery node in the Queries pane to return to the subquery.
2. In the ADDRESS table, right-click REGION_ID and select Find Lookup Table.
3. Follow the instructions in the Lookup Table dialog to specify the ID Column and the
Description Column.
Toad for Data Analysts User Guide 33
Query
4. After completing and closing the Lookup Table dialog, again select the Where field
in the REGION_ID column and click . Open the drop-down list to the right of
Constant. Notice that a description for each region now displays.
Notes:
l See "Editor Shortcut Keys" (page 35) for more information about keyboard shortcuts
used in the Editor.
l Toad has implemented a large script mode to improve performance when opening files
larger than 2 MB. By default, when you open a large file, some features such as word
wrap, syntax highlighting, and the Code Navigator are disabled in the Editor. When a
large script loads, a message indicates that you are in large script mode in the right
margin of the Editor. You can cancel large script mode by clearing the option in
Tools | Options |Editor |General.
To edit SQL
Note: You can query the worksheet from the Editor by entering a dollar sign ($)
followed by a cell range to limit the results similar to the following statement:
Select * from (MyWorksheet$A1:C10)
You can also query the entire worksheet by entering a dollar sign ($) after the
worksheet name; however, this returns empty rows and columns in the worksheet.
l Code completion
l Navigate code
Toad for Data Analysts User Guide 34
Query
l Code regions
l Code snippets
l SQL recall
l Add/remove application code
l Object lookup (Describe)
l Macros to record keystrokes
3. Click to format the code. See Format SQL for more information.
4. Select the block of code in the Editor, and click to validate the syntax.
Note:Toad undoes any changes to the object and data in the database after executing
the script (notice that the Result Sets tab is empty). To modify the object and data,
you need to execute the script.
5. Click to execute SQL on the current server or multiple servers at one time.
6. Select the block of code in the Editor and click to create a stored procedure.
Stored Procedure creation dialog automatically recognizes procedure body and
declared parameters.
Tips:
l Toad automatically saves a backup copy of any modified editor file in the
Application Data Directory to avoid losing your work. When you restart Toad after an
unexpected close, Toad checks the timestamp on the backup file against the original
file, and opens the file that has the latest timestamp. The document recovery option is
in Tools | Options | Environment | General. See General Environment Options for
more information.
l You can save the current connection, SQL script, executed results, filters, and group
execute connections/results (if enabled) in a Toad editor file (.tef). This file format is
useful for building scripts that have large result sets that you do not want to continue
executing or for saving results when you have not finished building a script.
l In the Editor toolbar, the execute SQL buttons are grouped under . The button
will retain the function of the last execute action for the active Editor window. If you
switch to another Editor window, the button will change to reflect the last action for
that window.
l If you copy and paste a SQL statement from one editor window to another, Toad
automatically rewrites the statement to match the syntax of the connection for the
second editor window.
Toad for Data Analysts User Guide 35
Query
Set options to display line numbers, line modifications, and Editor | General
general text formatting
Specify options to automatically replace typed text with the Editor | Auto-replace
correct substitution text
Caution! If you have some global access keys assigned, make sure that Toad shortcut
keys do not coincide with them. When using such duplicating shortcut keys in Toad, the
third party application commands, assigned globally, will be performed instead of ones
assigned by Toad.
Bookmark Description
Case Description
Clipboard Description
Comment Description
Cursor Description
Debugger Description
Toad for Data Analysts User Guide 37
Query
F7 Step into
F8 Step over
Delete Description
Indent Description
Macros Description
Miscellaneous Description
CTRL+DELETE Sets the column value for the current cell to Null in
the data grid
Troubleshoot Data
l If you cannot edit data, click the red icon in the lower left corner of the grid,
and then click OK on the window that displays. You do not need to edit fields in
this window.
l By default, auto commit is enabled and any row changes you make are automatically
submitted to the database. You can disable this option in Tools |Options
|Environment | Grid.
Toad for Data Analysts User Guide 39
Query
To... Do this...
Pin a result set so it is not overwritten Click the push pin beside the result set:
by a subsequent query in the Editor or
Query Builder.
Add column or group summary values Right-click the data and select Show
|Summary Footer Panel. Then, right-click
the Summary Footer Panel below the column
you want to add a summary total to and
select an option.
If you have grouped columns using the
Grouping panel (Show |Grouping Panel),
you can also add a summary total to grouped
records.
Display data in a report, pivot grid, or Right-click the data and select Send To
chart. |<option>.
Compare differences between two data Right-click the data and select Send To |
sets. Data Diff Viewer.
Display the data in a grid or card view; Right-click a record and select Show | Grid
grid view is useful for viewing View or Card View.
summary information at a glance; card
view is useful for viewing information
in greater detail.
Apply a summary function to the data Right-click below the column you want to
(Sum, Min, Max, Count, Avg). apply the summary function (but above the
Navigation toolbar) and select an option.
View a list of all existing values in a Right-click the column and select Show |
column, including the number of times Existing Values.
a value is used.
Toad for Data Analysts User Guide 40
Query
Notes:
l If you want to synchronize data, use Data Compare instead of the Data Diff Viewer.
l You cannot modify files in the Diff Viewer at this time.
To compare differences
1. Right-click data in the Editor's result set or Database Explorer's Data tab and select
Compare To | Set_number.
You can also save a result set and later use it as a historical comparison.
Tips:
l To switch the contents of the left pane to the right pane, and the contents of
the right pane to the left, click .
l You can also open files to compare by clicking beside the drop-down list
at the top of each pane.
Notes:
l Before you can export to Excel, the Primary Interop Assemblies (PIAs) for your
version of Excel must be installed.
l Use the Export wizard if you need to specify column delimiters and advanced field
options when exporting data.
Toad for Data Analysts User Guide 41
Query
1. Select the range of data to export or click any row in a data grid to export all data.
2. Right-click the selected range or data grid and select Quick Export.
CSV File Export data to a CSV file (comma separated value file).
The file is automatically saved under a default name in
the default export folder.
Excel Pivot Export data to an Excel pivot grid report. See the Excel
Table documentation for information on creating a Pivot
Table report with external data.
Excel Pivot Export data to an active cell for an Excel Pivot Table
Table at report. First open Excel and select a cell. Then select
active cell the Excel Pivot Table at active cell option.
Toad for Data Analysts User Guide 42
Query
Tip: To refresh data in a linked query report, click in Excel's External Data
toolbar. This executes the underlying query for the report. See "Share Excel
Linked Queries" (page 43) for more information about creating and using linked
queries.
Note: If the window containing data does not have the focus when you select a One
Click Export option, the following message displays: "Export did not find any results sets
to process".
Tip: You can specify a default export folder in Tools | Options |Environment
|OneClick Export.
Toad for Data Analysts User Guide 43
Query
Notes:
l Any user who opens an Excel linked query must have access to a user name and
password for the queried database to refresh the data. If a user does not have access to
the database, they can only see the original data in the spreadsheet.
l If the Excel linked query was created from an ODBC connection that uses a Data
Source Name (DSN), the DSN must also exist on the computer where the Excel file is
opened to refresh the data.
Scenario
You need to create an Excel linked query so that the Regional Sales
Manager, can track whether the Sales Representatives in his region
meet their monthly and quarterly goals. By providing a linked query,
you only have to create the query once, and then the Regional Sales
Manager can refresh the data at any time to view the latest sales
information.
4. Select the result set and click one of the following options from the toolbar:
1. Open the spreadsheet with the linked query in Excel. The original data from the
query displays.
2. In Excel, select Data | Refresh to update the original data with the current data.
3. If prompted, enter a user name and password to connect to the database and
refresh the data.
or
If the following error displays: "[Microsoft][ODBC Driver Manager] Data source name
not found and no default driver specified", you must specify the DSN used by the
query on your computer. Complete the following steps to resolve this issue:
(Excel 2003)
a. Click OK.
b. Select the Machine Data Source tab, and then click New.
c. Use the wizard to select a User Data Source and create a DSN that points to
the database.
d. Click OK to return to Excel and open an ODBC Driver Connect window.
e. Enter a user name and password to refresh the data.
5
Report
Note: This procedure does not cover all of the possible steps of creating a data report. It only
covers the steps required to create a report for the scenario.
Scenario
Your company wants to improve its global sales, starting with countries where it has a
customer base but averages low sales. You created a query that displays countries with
less than $500,000 in sales per fiscal year, but now you need to create a report to help
represent and evaluate the results. The data should be grouped per country and show the
total and average sales for each country. In addition, you want the report to look similar
to the rest of the company's documents, which use specific colors and fonts.
Note: This scenario uses the data generated in Visually Build a Query.
1. Right-click the data grid in the Results tab and select Send To | Data Report
Designer. The Toad Report Designer displays.
2. Select Standard Report and click Next.
3. Click to include all columns in the report and click Next.
Toad for Data Analysts User Guide 46
Report
4. Select COUNTRY_NAME and click , and then click Next. This groups the data by
the country name so that each country is listed as a heading and its sales per year
display below it.
Tip: You can create a secondary group by selecting another column and clicking
again. A secondary group is not appropriate for this scenario, but it would be if the
data included regions in each country or fiscal quarters. You would need to make the
region or fiscal quarter a secondary group for the data to be organized appropriately.
5. Select the Sumand Avg checkboxes for the SUM(SALES.AMOUNT) row, and
then click Next. These options calculate the sum and average sales amount for
each country.
Tip: The Outline and Align Left options are good choices if you grouped the data.
3. Select the following fields one at a time and make them wide enough to see the full
text: Sum (groupFooterBand1), Average (groupFooterBand1), and Grand Total
(reportFooterBand1).
4. Select the following fields one at a time and drag them to the one inch mark on the
ruler: Sum, Average, and Grand Total.
5. Right-click the COUNTRY NAME field (not the COUNTRY_NAME field on the right)
in groupHeaderBand1 and select Delete.
Note: The COUNTRY NAME field is a label that precedes the COUNTRY_NAME field
value. If you preview the report before you delete the COUNTRY NAME field, the
country displays as 'COUNTRY NAME Argentina'. It is clear that Argentina is the
country name, so this field is redundant.
6. Select the COUNTRY_NAME field and drag it to align with the report title.
7. Select the COUNTRY_NAME field and make it three inches wide to accommodate
long country names.
d. Select the Foreground Color field, and then select MidnightBlue in the
Web tab.
Note: All colors in this scenario are from the Web tab.
e. Select the Font field and click . The Font window displays.
f. Select 22 in the Size field and click OK.
2. Complete the following steps in the Styles Editor window to create and define four
new styles:
Toad for Data Analysts User Guide 48
Report
a. Click four times in the Styles Editor window to create four new styles.
b. Set the following properties for the new styles:
Name OddRow
Borders Bottom
Name EvenRow
Borders Bottom
Name TableHeading
Name CountryName
b. Select TableHeading in the Style field (under Styles) for the Fiscal Year and
Sales Amount fields in groupHeaderBand2.
Toad for Data Analysts User Guide 49
Report
Field Property
Tip: It is helpful to expand a band before adding controls to give you plenty
of room in which to work.
4. Click Preview.
5. To save the report, right-click the Data Report Designer tab and select Save File.
Manage Reports
To create a report
Tips:
l To add an existing Toad or Excel report to the Report Manager, right-click the Report
Manager window and select Add Existing Report.
l To send a Toad or Excel report via email or to a shared folder or other location, right-
click the report, select Send To, and then select an option.
l To share reports with other users, specify a shared network directory in Network Share
Options (Tools | Options |Environment |Network Share).
DB2 Reports
The following reports are available from the Reports Manager (Tools |Reports
|Reports Manager).
Activity Lists and describes activity reports that the Activity Monitor for
the current DB2 for LUW database uses. This report also lists the
switches required to gather data for a specific activity report. Toad
uses the AM_BASE_RPTS table function to generate this report.
ADMIN_LIST_ Displays information from the database history table for the DB2
HIST_V82 for LUW database partition to which Toad is currently connected.
Toad uses the ADMIN_LIST_HIST table function to generate this
report.
HEALTH_ Shows the current "health" status of all containers that tablespaces
CONT_HI in the current DB2 for LUW database use. Toad uses the
HEALTH_CONT_HI table function to generate this report.
HEALTH_ Shows a "health" history for all containers that the tablespaces in
CONT_HI_HIS the current DB2 for LUW database use. Toad uses the HEALTH_
CONT_HI_HIS table function to generate this report.
HEALTH_ Identifies the containers that tablespaces in the current DB2 for
CONT_INFO LUW database use and lists the highest current alert status for each
container. Toad uses the HEALTH_CONT_INFO table function to
generate this report.
HEALTH_DB_HI Shows the "health" status of the current DB2 for LUW database,
including its highest current alert status. Toad uses the HEALTH_
DB_HI table function to generate this report.
HEALTH_DB_ Shows the "health" history of the current DB2 for LUW database.
HI_HIS Toad uses the HEALTH_DB_HI_HIS table function to generate
this report.
HEALTH_DB_ Shows the "health" status of objects in the current DB2 for LUW
HIC database. Toad uses the HEALTH_DB_HIC table function to
generate this report.s
HEALTH_DB_ Displays a "health" history for objects in the current DB2 for LUW
HIC_HIS database. Toad uses the HEALTH_DB_HIC_HIS table function to
generate this report.
HEALTH_DB_ Shows the highest current alert status for the current DB2 for LUW
INFO database. Toad uses the HEALTH_DB_INFO table function to
generate this report.
HEALTH_DBM_ Shows the "health" status for the current DB2 for LUW instance.
HI Toad uses the HEALTH_DBM_HI table function to generate this
report.
HEALTH_DBM_ Shows a "health" history at the database manager level for the
HI_HIS current DB2 for LUW instance. Toad uses the HEALTH_DBM_
HI_HIS table function to generate this report.
HEALTH_DBM_ Shows the highest current alert status for the current DB2 for LUW
INFO instance. Toad uses the HEALTH_DBM_INFO table function to
generate this report.
HEALTH_TBS_ Shows the "health" status of all tablespaces in the current DB2 for
HI LUW database. Toad uses the HEALTH_TBS_HI table function to
generate this report.
Toad for Data Analysts User Guide 54
Report
HEALTH_TBS_ Shows a "health" history for tablespace in the current DB2 for
HI_HIS LUW database. Toad uses the HEALTH_TBS_HI_HIS table
function to generate this report.
HEALTH_TBS_ Shows the highest current alert status for each tablespace in the
INFO current DB2 for LUW database. Toad uses the HEALTH_TBS_
INFO table function to generate this report.
Index Statistics Displays statistics for the indexes under the current schema for the
DB2 for LUW database and flags those indexes that need
reorganization. Toad uses the REORGCHK_IX_STATS procedure
to generate this report.
Installed DB2 Lists the DB2 for LUW 9 products currently installed on your
Products system. Toad uses the ENV_GET_PROD_INFO table function to
generate this report. Products can include the following: RTCL
DB2 Run-Time Client CONSV DB2 Connect Server (any edition)
CONPE DB2 Connect Personal Edition
Installed DB2 Lists the DB2 for LUW 8 products currently installed on your
Products_V82 system. Toad uses the ENV_GET_PROD_INFO table function to
generate this report. Products can include the following:
l ADCL DB2Application Development Client
l ADMCL DB2Administration Client
l CONEE DB2Connect Enterprise Edition, DB2 Connect
Unlimited Edition, or DB2 Connect Application Server
Edition
l CONPE DB2Connect Personal Edition
l CUBE DB2Cube Views
l DLM DB2Data Links Manager
l ESE DB2Enterprise Server Edition
l EXP DB2Express Edition or DB2 Express Edition
processor option
l GSE DB2Spatial extender
l PE DB2Personal Edition
l QP DB2Query patroller
l RTCL DB2Run time client
l WM DB2Warehouse Manager
l WSUE DB2Workgroup Server Unlimited Edition
Toad for Data Analysts User Guide 55
Report
Instance Lists details about the current DB2 for LUW instance. Toad uses
Information_V82 the ENV_GET_INST_INFO table function to generate this report.
SNAP_GET_DB_ Lists information and statistics captured for the current DB2 for
V82 LUW 8 database. To generate this report, Toad uses the SNAP_
GET_DB table function to retrieve information from the database
and detail_log logical data groups.
SNAP_GET_ Lists statistics and information about the dynamic SQL statements
DYN_SQL_V82 executed against the current DB2 for LUW 8 database use. To
generate this report, Toad uses the SNAP_GET_DYN_SQL table
function to retrieve information from the dynsql logical data
group.
SNAP_GET_ Lists information and statistics about the tables in the current DB2
TAB_V82 for LUW database 8. To generate the report, Toad uses the SNAP_
GET_TAB table function to retrieve information from the table
logical data group.
SNAP_GET_ Lists information and statistics for the database partitions that
TBSP_PART_ make up each tablespace in the current DB2 for LUW 8 database.
V82 To generate this report, use the SNAP_GET_TBSP_PART table
function to retrieve information from the tablespace_nodeinfo
logical data group.
SNAP_GET_ Lists information and statistics for each tablespace in the current
TBSP_V82 DB2 for LUW 8 database. To generate the report, Toad uses the
SNAP_GET_TBSP table function to retrieve information from the
tablespace logical data group.
SNAPSHOT_ Lists the agents working for the various applications connected to
AGENT_V82 the current DB2 for LUW 8 database. To generate the report, Toad
uses the SNAPSHOT_AGENT function to retrieve information
from the application snapshot, especially from the agent logical
group.
Table Statistics Displays statistics for the tables under the current schema in the
Column View DB2 for LUW database and flags those tables that need
reorganization. Toad uses the REORGCHK_TB_STATS procedure
to generate this report.
Table Statistics Displays statistics for the tables under the current schema in the
DB2 for LUW database and flags those tables that need
reorganization. Toad uses the REORGCHK_TB_STATS procedure
to generate this report.
MySQL Reports
The following reports are available from the Reports Manager (Tools |Reports
|Reports Manager).
ODBC Reports
The following reports are available for the Toad Sample Database in the Reports Manager
(Tools |Reports |Reports Manager):
Customer Displays customer orders for contact IDs less than 10 from the Toad
orders sample database. It is an example of master detail display using a
single result set.
Customer list Displays a list of customers from the Toad sample database.
Items to order Displays items in stock that have a quantity of less than 50 and
should be reordered from the Toad sample database.
Oracle Reports
The following reports are available from the Reports Manager (Tools |Reports
|Reports Manager).
Cluster Reports
Toad for Data Analysts User Guide 57
Report
Other Reports
Invalid objects Displays any invalid objects for the selected schema and includes a
subtotal of all invalid objects for that owner.
Loads into Displays packages that have been loaded five or more times, into the
shared pool Oracle shared pool.
Note: You must have DBA privileges for this report.
Non-system Displays any objects in the SYSTEM tablespace that are not owned
objects in by SYSTEM.
SYSTEMtables
Oracle Displays the values for all parameters defined in the PFILE for the
initialization selected user.
parameters
Tablespaces Displays tablespaces that over 90% full, and do not have the
near capacity autoextend feature enabled.
Total shared Displays the number of times objects in the shared pool were
pool reload reloaded.
stats Note: You must have DBA privileges for this report.
User hit ratios Displays the buffer cache hit ratio users and includes consistent gets,
blocked gets, and physical reads.
User resource Displays values for resource usage such as CPU used and SQL*Net
usage roundtrips for each user.
Sequence reports
Sequences Displays the sequences that are within 10% of the maximum value.
Any sequences that do not have a maximum value set, or those that
cycle are excluded from the report.
Sequences Displays the sequences that are within 10% of the maximum value.
near max Any sequences that do not have a maximum value set, or those that
cycle are excluded from the report.
Arguments of Displays any parameters required for the selected stored procedure.
stand-alone
stored
programs
Object type Displays the body or source code for a selected object.
bodies
Object types Displays the type of objects owned by a user, including whether the
objects are valid and when they were created or last modified.
Stand-alone Displays the source code for a stored program, including the type of
stored program and the last time DDLwas generated.
programs
Stored object Displays a list of all stored programs including their source.
with source
Stored Displays the source for stored procedures for a selected owner.
procedures
Synonym Reports
Synonyms Displays information for each synonym, including the owner, table
owner and name, and the DB link.
Table Reports
Indexes Displays details for the index definition, storage parameters, and
columns included in the index.
Non-indexed Displays any tables that have not been indexed for the selected
tables database.
Toad for Data Analysts User Guide 59
Report
Tables Displays all columns for a selected table, including the maximum
&columns transactions, used/free blocks, free lists and groups, min/max extents,
and columns included in this index.
Tables Displays any indexes for a selected table, including the status,
&indexes uniqueness, and columns included in the index.
Trigger Reports
Triggers Displays triggers for a selected table, including the trigger event,
&columns status, WHEN clause, and columns associated with the trigger.
User-defined Reports
Sample Displays a sample user report based on a select * from dual query.
View Reports
Views & Displays all columns for a selected view, including the query and
columns columns included in the view.
DBA Reports
All jobs Displays all scheduled SQLServer jobs and the job owner, organized
by server.
Backup Displays the backup start date, type, and device used for the backup
history for a specified database for a set number of days.
Toad for Data Analysts User Guide 60
Report
Backup status Displays the database name, date of the last backup, days since the
last backup, and the type of backup performed.
Current lock Displays any locks on the server, including the database name, object
report or index name, type of lock, resource, mode, and status.
Database Displays any common options and their values for all the databases on
settings your server.
Database user Displays the user name, roles, objects, granted/denied status, and
details column permissions for each database.
Display errors Displays a log file without entries for log backups. This is useful
when you have a number of log backup entries and you need to locate
non-backup errors.
Drive space Displays space for all databases on the server, including free space,
usage space used, maximum size, and growth type.
Foreign key Displays tables in the order you can either populate or delete from
sequence them without violating any foreign key constraints. Objects with the
lowest wave number indicate that they can be deleted with the fewest
number of foreign key references. Objects with the highest wave
number should be populated first.
Index (SQLServer 2000 only) Displays all indexes for the current database
description sorted by table. Index information includes whether it is clustered,
unique, index keys, and the index size. run frequency, and the
maximum duration.
Job details (SQLServer 2000 only) Displays all SQLServer jobs, including
whether they are scheduled, enabled, start date and time,
Row count for Displays the number of rows for all tables on a server that contain a
tables with clustered index.
clustered
index
Total rows Displays the total number of rows and space used for each table or
and space view in the current database, including the reserved rows, unused
used rows, and index size. This report is sorted in descending order by
reserved rows.
User Displays users permissions, grouped by role name and object type.
permissions
Toad for Data Analysts User Guide 61
Report
Table Reports
Non-indexed Displays any tables that have not been indexed for the selected
tables database.
Table constraints Displays any check constraints for a selected table, including
whether the constraint is enabled, valid data, and affected
columns.
Table relationships Displays any foreign key constraints for a selected table,
including whether the constraint is enabled, referenced tables, and
referenced keys.
Tables and Displays all columns for a selected table, including the data type,
columns default value, whether it allows null values, and for SQLServer
2005 any extended properties.
Tables and indexes Displays any indexes for a selected table, including the name,
columns included in the index, and whether it is unique or
clustered.
User-defined Reports
Stored procedures Displays stored procedures for a selected database, including their
status, status, replication information, schema version, statistics,
and procedure text.
Toad for Data Analysts User Guide 62
Report
l Email reports and files, including Database Diagrams, Query Builder queries, SQL
scripts, and results for reports, queries, and scripts.
l Share reports and files in a central location such as the Toad shared folder.
You can use the following methods to publish and share information:
Automation Drag the Zip File activity to the workflow. Add reports and
files to the Zip file and specify a file name with a .zip
Toad for Data Analysts User Guide 63
Report
extension. The ZIP file can then be emailed with the Send
Email activity or copied with the Copy File activity.
Tips:
l To export a Toad report to a file that can be read by other applications, double-click a
report in the Reports Manager, click in the Report Preview window, select a file
format, and add the file to a project. Share or publish the file using the Project
Manager functions.
l To capture report results in a file, add the Toad Report automation activity. This
activity runs a Toad report and saves the results in a file format you select. Share or
publish the file using the Automation functions.
l To execute and save a query in a file, add the Select To File automation activity. This
activity runs a query or SQL script and exports the results to an Excel spreadsheet.
Share or publish the spreadsheet using the Automation functions.
6
Automate
Scenario
You need to create an Excel report that contains current regions and addresses and email
it to your manager every week.
Note:This scenario uses the Toad Sample(Access) database that ships with Toad for
Data Analysts.
2. Enter the following statements in the Editor and save them to a single file named
AutomationTest.sql:
Select * from region;
Compose Email Click Compose Email and enter your email address in the
To and the From fields.
Email Server In the Compose Email form, click Email Server Settings and
Settings enter your SMTP server address and the port number.
5. Click the Select To File database activity in the toolbox to add it to the
design window.
6. Click the File_1 activity and select Toad Sample Database in the connection field.
Toad for Data Analysts User Guide 65
Automate
7. Click the File_1 activity and enter the following in the Activity Input window:
8. Click the Send Email file activity in the toolbox to add it to the design window.
9. Click the Send Email activity and enter the following in the Activity Input window:
Email Click Email Server Settings and enter your SMTP server address
Server and port number.
Settings
12. Review the log and click the link to the Excel file generated to open the Excel
file in Toad.
Notice that the results of each SQL statement are in a different worksheet.
13. To schedule the automation script to run at a later time, click Schedule on the
wizard bar.
14. Complete the following fields:
Set Click this button and enter and confirm your O/S password.
password
Toad for Data Analysts User Guide 66
Automate
Schedule Description
Start time Select a time that is 2 minutes from the current time.
15. Check your email for confirmation of execution as well as thestatus of the job
manager window.
Automate Tasks
Use Automation to schedule a single script to run reports and queries, save results in Excel
spreadsheets, and distribute results to the business community via email. You can schedule
scripts that perform long-running tasks to run when database activity is light.
You can also use variables in automation scripts. With variables, you can update information
that may be different each time you run the script, such as the department name, revenue,
fiscal quarter, or product name. See "Use Variables in Automation" (page 83) for more
information.
For example, assume you are an analyst at Nick's Flicks movie rentals. You need to run
inventory and movie rental reports on a daily basis and distribute them to managers of the
inventory department. Using Toad, you create an automation script that runs the reports,
exports them to Excel spreadsheets, and emails the spreadsheets to the inventory department
everyday at 2:00 AM.
Troubleshooting:
l If Toad displays a "Variable must be initialized before referencing itself" error, you
need to initialize the variable. See "Use System Automation Activities" (page 79) for
more information.
l You must surround a variable name with the # sign (for example, #sleep#).
Note: This topic focuses on information that may be unfamiliar to you. It does not include all
step and field descriptions.
To automate tasks
1. Click Automate.
2. Select the Settings icon in the script design window to specify the script settings
before building your script. Use the Activity details pane in the bottom portion of the
Automation window to enter your settings. Review the following for additional
information:
Toad for Data Analysts User Guide 67
Automate
Activity
Input
Use relative Select to use a relative path that does not include the drive or
path to find full path for all activities in the script. This is useful if you
SQL files want to share your automation scripts with colleagues, use
them with version control, or place them on a shared network
folder.
Embed Select to embed the actual SQL from SQLfiles in the script.
SQL into This makes it easier to share the script with colleagues.
Automation
script
Truncate Select to overwrite the log file each time the script runs.
log
Run Mode Select Test mode to run your script in test mode using the
database connection specified under Test settings.
Select Production mode to run your script in production mode
using the database connection specified under Production
settings.
Note: The default connection is the currently active, open
connection.
Activity Info
3. To build your script, click an activity in the Toolbox, or drag an activity from the
Toolbox to the Automation script design window. Repeat to add additional activities
to your script.
Note: You must drag the activity to the , then release the mouse button after you
see the activity's icon replace the .
4. For each activity in your script, select the activity in the design window and then
Toad for Data Analysts User Guide 68
Automate
See the following topics for details about each activity and its properties:
Tip: You can save an activity and its properties as a template to reuse in other scripts.
Right-click the activity in the design window and select Save As Template. After
you create the first template, a Templates toolbox displays.
Note: Click Settings in the design window at any time to go back and review the
Automation script settings.
5. When you finish building your script, select one of the following actions from the
Automation toolbar or the Wizard bar:
Tips:
l Double-click an activity in the script design window to open the Activity Properties
pane in a format used in earlier versions of Toad.
l Right-click within the script design window and select Print Script to print the
script's workflow diagram.
Toad for Data Analysts User Guide 69
Automate
Note:When building an automation script, you must have the appropriate connections open
for database activities.
Tip: You can save an activity and its properties as a template to reuse in other scripts. Right-
click the activity in the design window and select Save As Template. After you create the
first template, a Templates toolbox displays.
Activity Description
Select to File Execute an existing SQL script or Query Builder query and export the
results to an Excel, HTML, or CSV file. You can then use additional
activities to add the exported result file to a zip file, attach the file to
an email, or copy the file.
Review the following for additional information:
l Row count variableEnter a name for the row count variable.
The value assigned to this variable equals the number of rows
returned from the activity. You can use this variable with the
If..Condition.. and While system activities. See "Use Variables
in Automation" (page 83) for more information on use cases for
this field.
l SQLManually enter SQL or select a SQL script or Query
Builder query to run. For SQL scripts, you can create a new
worksheet for the results of each SELECT statement in a script
by entering GO after each statement.
Note: To manually enter SQL in the text box, deselect Link
SQL file.
l Export fileClick the drop-down list to select the export file
type. Then, select the file location and enter the name. You can
use a variable in this field by entering the number sign before
Toad for Data Analysts User Guide 70
Automate
Activity Description
Select to Execute an existing SQL script or Query Builder query and save it
Editor with and any results sets in a Toad editor file (.tef).
Results This file format is useful for building scripts that have large result sets
that you do not want to continue executing or for saving results when
you have not finished building a script.
Review the following for additional information:
l Row count variableEnter a name for the row count variable.
The value assigned to this variable equals the number of rows
returned from the activity. You can use this variable with the
If..Condition.. and While system activities. See "Use Variables
in Automation" (page 83) for more information on use cases for
this field.
l SQLManually enter SQL or select a SQL script or Query
Builder query to run. For SQL scripts, you can create a new
worksheet for the results of each SELECT statement in a script
by entering GO after each statement.
l Editor FileSelect the file location and enter the name. You
can use a variable in this field by entering the number sign
before and after the variable (#VariableName#).
Toad for Data Analysts User Guide 71
Automate
Activity Description
Export Wizard Export data from databases, tables, views, or a query into a CSV,
Excel, or other file.
Review the following for additional information:
l Export templateYou can select an existing template, edit an
existing template, or create a new template.
l Use automation connectionSelect this option to use the
connection associated with the database activity. Clear the
checkbox to use the connection associated with the export
template.
Import Wizard Import data from a CSV, Excel, or other file into a new table or
append to an existing table.
Review the following for additional information:
l Import templateYou can select an existing template, edit an
existing template, or create a new template.
l Use automation connectionSelect this option to use the
connection associated with the database activity. Clear the
checkbox to use the connection associated with the import
template.
Toad Report Use this activity to open one or more Toad data reports and export the
contents as a PDF, HTML, Excel, CSV, RTF, or MHT file. You can
then add another activity to your script to zip the new file, attach it to
an email, or save it to a new location.
Review the following for additional information:
l Row count variableEnter a name for the row count variable.
The value assigned to this variable equals the number of rows
returned from the activity. You can use this variable with the
If..Condition.. and While system activities. See "Use Variables
in Automation" (page 83) for more information on use cases for
this field.
l Report filesSelect one or more Toad data reports from the
Project Manager or other location, or edit an existing report.
l Export fileSelect the file type and location and enter the
Toad for Data Analysts User Guide 72
Automate
Activity Description
Toad Pivot Refresh an existing pivot grid and export results to an Excel, HTML,
Grid or CVS file. You can then add another activity to your script to zip
the new file, attach it to an email, or copy it to a new location.
Review the following for additional information:
l Row count variableEnter a name for the row count variable.
The value assigned to this variable equals the number of rows
returned from the activity. You can use this variable with the
If..Condition.. and While system activities. See "Use Variables
in Automation" (page 83) for more information on use cases for
this field.
l Pivot fileSelect a Toad pivot file from the Project Manager
or other location, or edit an existing pivot file.
l Export fileSelect the file type and location and enter the
name. You can use a variable in this field by entering the
number sign before and after the variable (#VariableName#).
l SuffixSelect a suffix to append to the file name. The suffix
can be the date and time that the file was generated or the
content of a variable that you define with the Set Variable
system activity. See "Use System Automation Activities" (page
79) for more information.
Note: You can only use one variable per field or file name (a
suffix counts as one variable for a file name).
Clean Data Execute data cleansing to create a new data set by filtering an existing
data set or data source.
Review the following for additional information:
l Data cleansing creates a new, cleansed table and leaves the
source table intact. Implement a data hub repository or some
form of internal data store. Alternatively, you can specify a
schema or database to create, or alter and drop tables.
l Each data hub table needs a name and Test Representation
Language (TRL) representation. Groups of tables, data
Toad for Data Analysts User Guide 73
Automate
Activity Description
Notes:
l StatusSelect Enabled to include the activity in script execution. Select
Disabled to disable the activity, for example, when testing other activities. Or
right-click the activity in the design window and select/deselect Enabled.
l Stop on ErrorAllows you to select, for each activity, whether to stop or
continue execution if Toad encounters an error.
l Select the Log tab to review a script's execution log.
l Automation does not support positional parameters denoted by a question mark.
l For each activity, you can specify the database connection in the activity's
properties. The default connection is the currently active, open connection.
Tip: You can save an activity and its properties as a template to reuse in other scripts. Right-
click the activity in the design window and select Save As Template. After you create the
first template, a Templates toolbox displays.
Activity Description
Copy File Copy or move one or more files to a shared folder where they can
be accessed by your business community. You can copy or move
a file generated by other activities in the automation script and
overwrite an existing copy of a destination file.
Toad for Data Analysts User Guide 74
Automate
Activity Description
Delete File Delete one or more files from a specified location. You can use
this activity to delete files that are created earlier in the script.
Note: You can use an asterisk (*) in the FileName field as a
wildcard to select multiple files in the same directory to delete.
Zip Files Create a zip file and add files to it. Files generated with other
activities can be added to the zip file. You can then email the zip
file to colleagues.
Review the following for additional information:
l Archive nameSelect a location and name for the zip file.
You can use a variable in this field by entering the number
sign before and after the variable (#VariableName#).
l EncryptionSelect whether to create a zip file without
encryption (Standard) or to encrypt the zip file.
Note:If you encrypt the zip file, you must have a zip
utility that can support 128-bit or 256-bit decryption.
Toad for Data Analysts User Guide 75
Automate
Activity Description
Find and Replace This activity opens one or more files and performs a find and
replace within those files. You can write the results to a different
location and file name.
Review the following for additional information:
l Find/ReplaceYou can have multiple Find/Replace tasks
within one activity. You can specify a different set of
properties for each Find/Replace task.
l Source fileSelect the file in which to perform the find
and replace activity. To select multiple files for one
Find/Replace task, use standard wildcard characters in the
file name.
l FindEnter the content to find.
l Replace withSelect the type of replacement content: a
value, contents from a file, or a variable.
l Set valueEnter the replacement value, enter the
replacement variable, or select a file containing
replacement content.
You can use a variable in this field by entering the number
sign before and after the variable (#VariableName#). In the
following example, if variable X has a value of 10, the
updated file would display "Region 10" instead of
"Region".
Activity Description
Activity Description
l For the To, CC, Subject, and Body fields: You can use a
variable in this field by entering the number sign before
and after the variable (#VariableName#).
l You can only use one variable per field or file name (a
suffix counts as one variable for a file name).
Run Automation Run another automation script in your current automation script.
Script Review the following for additional information:
l Automation scriptSelect an automation script (.tas file).
Toad for Data Analysts User Guide 78
Automate
Activity Description
Compare Data Open a Toad data compare project and export the contents as a
PDF, HTML, Excel, CSV, RTF, or MHT file.
l Project fileSelect a Toad data compare project file.
l Report fileSelect a file location, file name, and file type
for the export file.
l SuffixSelect a suffix to append to the file name. The
suffix can be the date and time that the file was generated
or the content of a variable that you define with the Set
Variable system activity. See "Use System Automation
Activities" (page 79) for more information.
Visualize Data Open a Toad data visualization project, refresh the chart, and
export contents as a PDF, HTML, image, Excel, RTF, or MHT.
l Data Visualization documentSelect a Toad data
visualization file (.tdv).
l Output fileSelect a file location, file name, and file type
for the export file.
l SuffixSelect a suffix to append to the file name. The
suffix can be the date and time that the file was generated
or the content of a variable that you define with the Set
Variable system activity. See "Use System Automation
Activities" (page 79) for more information.
Notes:
l StatusSelect Enabled to include the activity in script execution. Select
Disabled to disable the activity, for example, when testing other activities. Or
right-click the activity in the design window and select/deselect Enabled.
l Stop on ErrorAllows you to select, for each activity, whether to stop or
continue execution if Toad encounters an error.
l Select the Log tab to review a script's execution log.
l Automation does not support positional parameters denoted by a question mark.
Toad for Data Analysts User Guide 79
Automate
Tip: You can save an activity and its properties as a template to reuse in other scripts. Right-
click the activity in the design window and select Save As Template. After you create the
first template, a Templates toolbox displays.
Activity Description
Run Program Run a program with optional command-line arguments. Review the
following for additional information:
l ProgramSelect a .bat or .exe file.
l ArgumentsEnter command-line arguments. You can also enter
a variable, such as #sleep# in this field.
Note:If you want to run a macro in Access, enter
databasename /x macroname in this field. For example, if you
have a macro that beeps and runs in your Northwind database,
you would enter Northwind 2007.accdb /x beep.
l Run DirectorySelect the directory to change to when running
the program.
l Return Code VariableEnter a name for the return code
variable. You can use this variable with the If..Condition
activity.
l VerbEnter verbs used when running the program, such as
"Print".
l Wait for program to exitSelect this option to pause if there is
an error. Select duration of wait time in minutes.
Note: If the script opens a command-line window, you must manually
close the window once the script completes.
Set Variable Add one or more variables to the script. When you execute the script,
Toad replaces the variable with the defined value. With this feature,
you can update information that may be different each time you run
the script, such as the department name, revenue, fiscal quarter, or
product name.
Review the following for additional information:
ValueSelect this option to specify a value for the variable or to build
a variable expression. Click to build an expression. Build your
expression by selecting from the list of variables, operators, and
functions. (Click a list name in the left pane to display the items in the
right pane. Double-click an item to add it.) Click Test to test the
expression. See the following link for more information on VBScript
functions: http://www.w3schools.com/VBscript/vbscript_ref_
Toad for Data Analysts User Guide 80
Automate
Activity Description
functions.asp
SQLSelect or enter a variable value, you can enter a SQL statement
to use as the variable. If you enter a statement, the value from the first
row and column returned in the query is used as the variable value.
This is useful if you need a variable with a date.
See "Use Variables in Automation" (page 83) for more information.
Note: You can only use one variable per field or file name (a suffix
counts as one variable for a file name).
While.. Execute activities while the variable condition is true. The activity
ends when the condition becomes false, or when it completes the
selected number of loops.
To use this activity you must define a variable in the automation script
with the Set Variable activity.
This activity can have one or more conditions. To delete a condition,
select it and press DELETE. To add a condition, right-click the
If..Condition.. activity and select Add Branch. If you have multiple
conditions, they do not have to be mutually exclusive. Multiple
branches can be true.
Review the following for additional information:
l Build condition expressionTo define a condition, enter the
variable name and expression in the field. Build your
expression by selecting from the list of variables, operators, and
functions. (Click a list name in the left pane to display the
Toad for Data Analysts User Guide 81
Automate
Activity Description
Loop dataset Execute activities on each row of a data table. The data table must be
the result set from an Execute Script activity that occurs previously in
the automation script. See "Use Database Automation Activities" (page
69) for more information.
You can reference a column in the data table by setting the value of an
initialized variable to 'DataTableName.ColumnName'. To initialize a
variable, your script must have two different Set Variable activities.
The first Set Variable activity defines the variable value with a
numeric value (such as 0 or 1.53), and the second defines it with the
column variable name.
For example, assume you want to perform a set of activities on each of
your company's products. You add the following activities and values:
l Execute ScriptExecute a script that returns product IDs. You
enter ProductIDTable in the Results variable field.
l Set VariableAdd activity to give the variable an initial value.
You enter ID in the Name field and 0 in the Value field.
l Loop datasetLoop based on the dataset from the Execute
Script activity. You enter ProductIDTable in the Data Table
field.
l Set VariableAdd a second variable activity to reference the
Product_ID column in the data table. You enter ID in the Name
field and ProductIDTable.Product_ID in the Value field. This
redefines the values of the ID variable to the values in the
Product_ID column.
Toad for Data Analysts User Guide 82
Automate
Activity Description
Pause Stops an activity for a set number of seconds before continuing. This is
useful, for example, if you are using parallel activities and need to
pause one branch while waiting for results or the complete execution
of another branch.
Group Use this activity to group and organize two or more activities together.
Activities
Parallel Run two or more activities in parallel. After adding a parallel activity
to the design pane, you can right-click it to add additional branches for
parallel activities.
Notes:
l StatusSelect Enabled to include the activity in script execution. Select
Disabled to disable the activity, for example, when testing other activities. Or
right-click the activity in the design window and select/deselect Enabled.
l Stop on ErrorAllows you to select, for each activity, whether to stop or
continue execution if Toad encounters an error.
l Select the Log tab to review a script's execution log.
l Automation does not support positional parameters denoted by a question mark.
Toad for Data Analysts User Guide 83
Automate
Note:You must surround a variable name with the # sign (for example, #sleep#).
Scenario
Your Sales Manager wants a separate sales report for each of the
company's products every week. He wants you to email the reports to
him after they are generated.
To provide the reports to the Sales Manager, you need to create the
product queries and the sales report. Then, you can use them in an
automation script to run the queries, generate reports, and email the
Sales Manager every week.
1. Use the Query Builder to create a query that returns the product IDs.
2. Save the query and name it ProductIDQuery.tsm.
Toad for Data Analysts User Guide 84
Automate
3. Use the Query Builder to create a query that returns the sales information for products
and enter the following search criteria in the specified columns:
12. Click the Set Variable activity and complete the following fields:
13. Click the Loop dataset activity and enter ProductIDTable in the Data Table field.
This loops activities on the content of the ProductIDQuery.tsm query.
14. Click the Set Variable activity to add a second variable and drag it into the Loop row.
15. Complete the following fields for the new Set Variable activity:
16. Click the Database Connection activity and drag it into the Loop row beneath the Set
Variable activity.
17. Click the Toad Report activity and drag it into the new Database Connection activity.
18. Complete the following fields in the Toad Report activity:
19. Click the Send Email activity and drag it beneath the Database Connection activity in
the Loop row.
20. Enter the following information and then complete the remaining required fields for
the Send Email activity:
Subject Enter Weekly sales report for product #ID#. When the
automation script runs, it replaces #ID# with the
variable value.
Add Attachments Select the file created in the Toad Report activity and
click Add.
21. Click Test to ensure that the script works. The following image displays the
automation script in the Design pane:
Toad for Data Analysts User Guide 86
Automate
If ProductIDQuery.tsm returns five product IDs, Toad creates a report and sends an
email for each one. If the first product ID is 101, the first email would have the
following properties:
Toad for Data Analysts User Guide 87
Automate
Attachments SalesForProduct101.xls
Body Attached is the weekly sales report for product 101. See
the attached file.
Scenario
Your company has a web site that customers use to order products.
The orders are automatically batched, and each order is recorded as a
row of data. When the batch is sent, it updates a column in the order
row.
You need to run a daily report to find orders that were submitted but
not batched. If there are any unbatched orders, you need to send an
email to yourself with a list of the unbatched orders. If there are no
unbatched orders, you need to send an email to yourself so you know
that all orders were batched successfully.
e. Click the Send Email activity and drag it beneath the Select to File activity.
f. Enter the following information and then complete the remaining required
fields for the Send Email activity:
7. Click Test to ensure that the script works. The following image displays the
automation script in the Design pane:
Toad for Data Analysts User Guide 89
Automate
If there are no unbatched orders, Toad executes the first condition and sends an email
with "No unbatched orders" in the subject . If there are unbatched orders, Toad
executes the second condition. If there are two unbatched orders and you test on
December 10, 2009, the email would have the following properties:
Attachments UnbatchedOrders_2009-12-10.xls
Body There were 2 unbatched orders. See the attached file for
more information.
1. With a script open in Automation, click Schedule in the Wizard bar. A Windows
Scheduler task is created for the script and a task properties window displays. See
Schedule Windows Tasks for more information.
2. Select scheduling options in the Schedule tab of the task properties window.
3. After the script executes, to view the script's execution log, select View | Output or
select the Log tab in the script's open Automation window.
Note: When you view the Toad Event Log in the Output window, all log content
moves to that window. As a result, the log is cleared.
1. Click Test in the Wizard bar. The script is compiled and executes immediately.
3. If you want to schedule the script, first resolve any problems that caused activities
to fail or disable failed activities. An activity can be disabled from its Activity
Info window.
Tip: To execute a script from the Project Manager, right-click the script and
select Execute.
Appendix: Contact Quest
View the Global Support Guide for a detailed explanation of support programs, online
services, contact information, policies and procedures. The guide is available at:
http://support.quest.com.
Toad Community
Get the latest product information, find helpful resources, and join a discussion with the Toad
for Data Analysts team and other community members. Join the Toad for Data Analysts
community at http://tda.inside.quest.com/index.jspa.
See our web site for regional and international office information.
Toad for Data Analysts User Guide 92
Contact Quest Support
reports tutorial 45
A
Database Diagram
activities, automation 66
tutorial 17
automation 66
Database Explorer
database activities 69
best method for locating objects 10
execute automation scripts 90
filter databases and objects 11
file activities 73
search for objects 16
system activities 79
database objects 10
variables 83
filter schemas 11
B
object explorer 10
build queries
search for 16
create cross-connection queries 23
databases
reverse engineer queries 26
automation activities 69
C
Diff Viewer, data 40
code
E
automating 66
Editor 33
shortcut keys 35
reverse engineer queries 26
view result sets 38
shortcut keys 35
connections
Excel
create ODBC 7
add to Report Manager 51
share for all session windows 9
share linked queries 43
understand 8
export
contact support 91
data with one click 40
cross-connection queries 23
F
D
files
data
automation activities 73
browse parent tables 19
compare differences 40
Toad for Data Analysts User Guide 94
Index
filter tutorial 21
H reports 51
I DB2 52
K ODBC 56
keyboard Oracle 56
L SQLServer 59
O script results 38
P shortcut keys 35
in Automation 83 subqueries
Q tutorial 30
tables
tutorials 45
subquery 30
variables
in Automation 83