Running SQL statements

You can run and test SQL statements that you create.

About this task

Important: When you run an INSERT, UPDATE, or DELETE statement, you can modify the database.

If an SQL statement contains host variables, you are prompted to substitute a value of the appropriate type for each host variable.

Procedure

To run an SQL statement:

  1. Click a command or a toolbar button to start running the SQL statement:
    Interface Procedure
    In the Data Project Explorer view
    • In the SQL Scripts folder of a data project, right-click an SQL statement, and then click Run SQL on the pop-up menu.
    When the SQL statement is open in the SQL Query Builder
    • Click Run > Run SQL.
    • Click SQL > Run SQL.
    • Right-click in the SQL Source pane of the SQL Query Builder, and then click Run SQL on the pop-up menu.
    • On the main toolbar, click Run the SQL Statement.
    When the SQL statement is open in the SQL and XQuery editor
    • In the top border of the editor, click Run SQL.
    • Click Run > Run SQL.
    • Right-click in the SQL and XQuery editor, and then click Run SQL on the pop-up menu.
  2. If you are not connected to your database, specify your password in the Database Authorization window, and then click OK.
  3. If the statement contains one or more host variables, specify values in the Specify Variable Values window:
    1. In each row of the table that contains a host variable, double-click the cell under the Value heading, and then enter a value for the host variable.
    2. Click Finish.

Results

The results are displayed in the SQL Results view. It opens automatically if it is not already open.

What to do next

Some tasks that you perform depend on an active connection to your database. Any task that requires an active connection to the database (such as running an SQL statement in the SQL Query Builder) does not work properly if the connection is dropped. To work around this problem, you must reconnect to the database.




© Copyright IBM Corporation 2010, 2017.