Professional Documents
Culture Documents
Table of Contents
QUERY BUILDER OVERVIEW ................................................................................... 3
THE QUERY BUILDER CONTROL ................................................................................................. 3 SAVING FILES .............................................................................................................................. 4 DEFAULT SETTINGS..................................................................................................................... 4
Page 2 of 13
Page 3 of 13
Saving Files
Query Builder files are saved and can be identified with the *.tsm file extension. This xml format file contains all the information needed to restore the saved state including all the objects, joins, where conditions, positioning etc of the Query Builder control. The file save menu can be found by right-clicking on the Query Builder document tab or from the main menu under File Save File when a Query Builder document tab is selected.
Default Settings
The Query Builder options are accessible from the main menu under Tools Options Database Query Builder and from main menu under Query Builder Query Builder Settings when the Query Builder is open. From here you can choose to fully qualify object and column names and limit the number of objects added to the control. Checking Use fully qualified object names will fully qualify the object name with schema in the form of schema.table. Checking Use fully qualified column names will fully qualify the column name in the form of table.column, The default of limiting the maximum number of objects to 50 was selected to limit impact on the database and for optimal application responsiveness.
Page 4 of 13
Page 5 of 13
Formulas
Formulas can be applied to columns and calculated fields. Choose from the pre-defined list of functions and operators or free text the formula directly.
Subqueries
The query build allows you to add a sub query to the FROM clause. A sub query can be added by clicking on the Add Subquery toolbar button or from the context menu on the diagramming surface. Activating this option opens the Queries tree on the left side of the form and opens a sub query builder control. You add tables and views and create joins in the same way as you normally use the query builder.
When you are done creating the sub query, click the parent query in the Queries tree to go back to the original query. The first thing you will notice is a new table on the diagram surface with all the columns from the sub query. Use this new table as you would any other database object. You can nest sub queries and the Where Condition sub query works as it did before.
.
Page 6 of 13
Distinct Values
Date Ranges
When you open the Where Condition dialog for a column that has a Date data type, you will notice a new tab named Date Range. The Date Range tab allows you to select a plain text tag such as, Today, Last week, Last 30 days, and Current year. The tag you select is added to the where clause of your query and when executed it is substituted with a BETWEEN command using the appropriate date range. Date Range tags can also be used in the SQL Editor so you can create queries manually if you wish.
Page 7 of 13
Lookup Tables
A lookup table is an associative array which in the context of a database application creates a new table with defined relationships to the distinct values of the original table.
Page 8 of 13
Heterogeneous Queries
You can use the query builder to add tables and views from multiple databases and retrieve a combined result set. With a query builder open, you can change connections and still add tables from a different database. Once a table or view from a different database has been added to the query builder, a watermark is shown indicating you are working with a heterogeneous query. Note: The Query Builder uses the Microsoft Access database installed with Toad as a staging area for the query. You should not uninstall this database if you intend to create heterogeneous queries. The query engine uses an ODBC connection to connect to the database where the table resides even when connected via one of the .Net native providers.
Page 9 of 13
Query Limitations
Executing a heterogeneous query may take longer than a query run against a single database. ODBC data retrieval is naturally slowing than using a native database client connection. In addition, result sets from each database are retrieved and combined increasing the length of time to get a result set. Sub queries do not work with heterogeneous queries so all access points to add sub queries have been disabled. The only join types that work with heterogeneous queries are CROSS JOIN and INNER JOIN. All access points to change the join type have been disabled. You cannot create a heterogeneous query from a DB2 native client connection. You must first establish an ODBC connection to the DB2 database and then create the query. You cannot create a heterogeneous query between two or more Excel connections. Heterogeneous queries between Microsoft Access and Microsoft Excel are not supported. Result sets from a heterogeneous query cannot be edited.
Reverse Engineering
The Query Builder allows you to enter a SELECT statement in the Query tab and reverse engineer it into a visual representation on the Diagram tab.
Simply type or paste a SELECT statement into the editor on the Query tab and click on the Visualize SQL statement button to draw a diagram of the objects and relations in the SQL. The statement can contain calculated columns, WHERE, HAVING, GROUP BY, ORDER BY clauses, and sub SELECT statements. Edits made on the Diagram tab will cause the Query tab to be updated thus overwriting the entered SQL.
Page 10 of 13
Since a WHERE or HAVING clause can be entered that the Query Builder can not visually represent, the Global Clause objects are used to contain the logic of the clause. Reverse engineering a SELECT statement that contains a WHERE or HAVING clause produces a Global Where Clause or Global Having Clause object in the Diagram. The Global Clause can be edited by double clicking on the object or clicking the Global Where or Global Having buttons on the toolbar. Errors in the SELECT statement will be flagged in the editor and added to the Output window.
Page 11 of 13
Page 12 of 13
Web site: www.quest.com Please refer to our Web site for regional and international office information.
Page 13 of 13