Opening and Running a Query

 

You can run a saved query, or write and run a new query. You can also run a query without opening i t, using the default options.

Fields and controls for the Query Options page

To open then run a query:

1.         In the SQL Queries branch of the desired connection in the DB2 Web Query Tool navigation tree, click the query that you want to run. A drop-down menu appears.

2.         On the drop-down menu, click Open. The Query Options page opens.

Note:     If you do not have read permission for the selected query, DB2 Web Query Tool attempts to run the query rather than open it if you have run permission.

3.         In the Settings section, select your Auto-Commit preference. The Auto-Commit preference determines when your changes are committed to the database

·       Select Off to prevent your changes from being automatically committed to the database. When this option is selected, commits will be made to the database manually.

Note:     If you select not to have your changes automatically committed, your database will be left in an uncommitted state. This can cause problems.

·       Select When Finished to have your changes committed to the database after all SQL statements have been run.

·       Select After Each Statement to have your changes committed to the database after each SQL statement is run.

4.         In the Name field, type the name that you want to use for the results set.

Tip:     DB2 Web Query Tool provides a default results set name. You can replace this name with one that you prefer.

5.         In the Max Rows field, type the maximum number of rows to return in the results set.

Tip:     To return all rows to the results set, type "0" in the Max Rows field.

6.         In the Timeout field, type a timeout limit.

7.         From the Action drop down list, select an action that specifies how LOBs will be retrieved from the database. The options are as follows:

·          Select Omit to omit the LOB from the result set.

·          Select Retrieve to have LOBs retrievable from the results set. When you select Retrieve, LOBs will appear as links in the results set. You can click the link to view a particular LOB and DB2 Web Query will retrieve that LOB for you from the DB2 table and show it in a viewer.

·          Select Embed to have the LOB data embedded in the results set

8.         In the Limit field, type the maximum size (in k) of a LOB that will be available in the results set. Any LOB that is larger than the specified limit will not be embedded.

9.         From the Type drop down list, specify the file type (extension) of LOBS that will be returned by your query.

·          Select None to have a MIME type of APPLICATION/OCTECT returned to the client.

·          Select Static to indicate that all LOB data in the table is of the same type and that the same extension should be applied to all LOBs. Specify the extension to apply to each LOB in the Ext/Column field.

·          Select Column to indicate LOB data is of different types and that the type of the LOB data is stored in a column that is referenced in the query. In the Ext/Column field, type the name of the column where the LOB type extension is stored.

If you specify None, the LOB data will be sent to your browser in binary format and DB2 Web Query will rely on the browser to determine the type of data.

10.      If you have SQL\PA installed on you system and your query has not been analyzed by SQL/PA, "Not Analyzed" will appear next to SQL/PA in the SQL/PA section. To analyze your query with SQL/PA, click Analyze in the SQL/PA section of the Settings section. SQL/PA analyzes one statement at a time. Therefore, if you have more than one SQL statement embedded in your query, you will see results in a cumulative format. To set your SQL/PA analysis options, click Analyze options.

Note:     If you do not have SQL/PA installed, "Not Installed" will appear next to SQL/PA in the SQL/PA section.

11.      Optional: Click Edit to edit the SQL query.

12.      If the query contains variables, click each variable that is displayed in the Parsed Query section to define its value.

13.      Type the value of the variable or select a value from the dropdown menu, if available.

·          Select Use to substitute the value specified for only that instance of the variable name.

·          Select All References to substitute the value specified for every instance of that variable name in the query.

·          Select Ignore to treat the variable as a string.

Tip:     When you click a lookup variable, a dropdown menu appears from which you can select a value for the variable. If the variable has multiple selection defined for it, you may be able to select multiple values for the variable by holding down the Control key.

14.       To run the query, click Next.

Note:     DB2 Web Query Tool does not validate SQL. Be certain to use correct SQL syntax, table names, and column names when writing your query.

DB2 Web Query Tool runs the query, and displays the Query Data page. You can now view the Query Data page. You can also specify how to display or export the query results.