Creating a Query

 

You can write a new SQL query with DB2 Web Query Tool. You can then save or run the query. You can also create a query that calls stored procedures.

Fields and Controls for the Edit Query screen

To create a new SQL query:

5.         In the desired connection branch of the DB2 Web Query Tool navigation tree, click SQL Queries.

The Queries menu appears.

6.         From the drop-down menu, select New.

The Edit Query page opens.

7.         In the Enter an SQL Statement field, type an SQL statement. You can include multiple statements in a single query, as well as comments and variables. You can also use lookup variables, which refer to other queries or results to produce a drop-down menu of substitution values.

DB2 Web Query Tool supports the following comment formats: --comment, //comment.

DB2 Web Query Tool supports the following variable formats: [variable], :variable, ?, and &variable.

Tip:     Use a semi colon to separate multiple statements in a query.

8.         Click Next. The Query Options screen opens.

9.         In the Result Name field, type the name of the results set.

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

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

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

11.      In the Timeout field, type a time-out limit.

12.      From the Action drop down list, select an action to perform when a LOB is encountered. 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. LOBs in the results set will be viewable by clicking on a link. The LOB will appear in a viewer.

13.      In the Limit field, type the maximum size of a LOB that will be available in the results set.

14.      From the Type drop down list, select the type of LOBs to be included. Select Static and specify the file extension in the Ext./Column field to indicate that only LOBs with the specified extension will be shown. Select Column and type the name of the column, without the alias identifiers, that contains the information on the type of LOBS that will be shown in the Ext./Column field to indicate that only LOBs of the type specified in the specified column will be shown.

15.      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.

16.      Optional: To edit the query click Edit SQL.

17.      To run the query click Next.

Note:     You can also save the query by clicking Save.