SQL statement

An SQL statement that is run by the Java application in a project of your workspace.
The SQL statements that appear in the SQL Outline view can be in either of these locations in your application:
  • If you are developing a Java application that is in a project with data access development support enabled, the SQL statement is located in a Java class file or source file.
  • If you are developing a Java application that uses the pureQuery API, the SQL statement is located in the declaration of an annotated method in an interface.
  • If you are configuring a non-pureQuery API application to run SQL statements statically, or you are configuring an application to run a restricted set of SQL statements dynamically, the SQL statement is located in a Java class file or source file. If you have captured SQL statements for your application, the SQL statement is also located in a pureQueryXML file.
    The SQL Outline view shows all of the points where an application runs an SQL statement. Before you capture SQL statements, the view shows the code that the application uses to run SQL statements. For example, for an application called Department.java, the view might show these entries:
    • Line# 123: getSql()
    • Line# 124: executeQuery()
    • Line# 116: "SELECT " + getColumns2() + getTable()
    • Line# 108: "SELECT " + getColumns() + getTable()
    After you capture SQL statements for this application, the SQL Outline view shows the actual SQL statements that the application runs at those locations. When you then expand an SQL statement, the view shows two stack traces. The first is for the location in the code where the application defines the SQL statement, and the second is for the location in the code where the application runs the statement.

    If you captured SQL statements with the property sqlLiteralSubstitution set to ENABLE, statements that contained literal values appear in the view with parameter markers. For information about this property, see the following topics:

What happens when you select an SQL statement in the SQL Outline view
The SQL statement appears in the Properties view.
If you select the SQL statement when you are viewing the Java page, the Properties view also displays the line number at which the statement is located in the Java file.
What happens when you double-click an SQL statement in the SQL Outline view
If the source file exists in your project, the file opens in an editor in the workbench. The text cursor is positioned on the line where the SQL statement appears.
What options appear when you right-click one SQL statement in the SQL Outline view
Show in Source
If the source file exists in your project, the file opens in an editor in the workbench. The text cursor is positioned on the line where the SQL statement appears.
Run SQL
Runs the SQL statement against the connected DB2® database.
Show in SQL Editor
Opens the SQL statement in the SQL editor.
Export SQL to File
Lets you export the SQL statement to an .sql file.
Open Visual Explain
Opens Visual Explain so that you can examine the access plan for the SQL statement.
For more information about using Visual Explain, see Viewing the access plans for SQL statements.
Get Query Tuner Report
Generates recommendations for tuning the SQL statement, if your configuration meets these prerequisites:
  • If your project is associated with DB2 for Linux, UNIX, and Windows:
    • IBM® InfoSphere® Optim™ Query Tuner for DB2 for Linux, UNIX, and Windows must be installed into the same package group as IBM Data Studio.
    • IBM InfoSphere Optim Query Tuner for DB2 for Linux, UNIX, and Windows must be activated on the data server.
    • The data server must be configured for the query tuning client.
  • If your project is associated with DB2 for z/OS®:
    • IBM InfoSphere Optim Query Tuner for DB2 for z/OS must be installed into the same package group as IBM Data Studio.
    • IBM InfoSphere Optim Query Tuner for DB2 for z/OS must be activated on the data server.
    • The data server must be configured for the query tuning client
Open Query Tuner
Opens the Query Tuner editor, if your configuration meets these prerequisites:
  • If your project is associated with DB2 for Linux, UNIX, and Windows:
    • IBM InfoSphere Optim Query Tuner for DB2 for Linux, UNIX, and Windows must be installed into the same package group as IBM Data Studio.
    • IBM InfoSphere Optim Query Tuner for DB2 for Linux, UNIX, and Windows must be activated on the data server.
    • The data server must be configured for the query tuning client.
  • If your project is associated with DB2 for z/OS:
    • IBM InfoSphere Optim Query Tuner for DB2 for z/OS must be installed into the same package group as IBM Data Studio.
    • IBM InfoSphere Optim Query Tuner for DB2 for z/OS must be activated on the data server.
    • The data server must be configured for the query tuning client

See Tuning SQL statements for more information about this feature.

Generate pureQuery Code
Opens the Generate pureQuery Code from an SQL Statement wizard. Requires a Java project with pureQuery support enabled.
Find in pureQueryXML
Opens the pureQueryXML file in which the SQL statement is located and places the cursor at the beginning of the statement.
What options appear when you right-click a selection of two SQL statements in the SQL Outline view
Compare
Shows a comparison of the two statements.
Export SQL to File
Lets you export the SQL statements to an .sql file.
Show in SQL Editor
Opens the SQL statements in the SQL editor.
What options appear when you right-click a selection of two or more SQL statements in the SQL Outline view
Export SQL to File
Lets you export the SQL statements in an .sql file.
Show in SQL Editor
Opens the SQL statements in the SQL editor.

Feedback