Running SQL statements

You can run and test SQL statements that you create.
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.

Restriction:
  • If an SQL statement contains host variables, you cannot run the statement in the SQL editor.
  • You cannot run a statement that is in an SQL Statements folder of a physical data model by using the statement's pop-up menu in the Data Project Explorer.

To run an SQL statement:

  1. Click a command or a toolbar button to start running the SQL statement:
    In the Data Project Explorer view
    • In the SQL Scripts folder of a data development project or a data design 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 builder
    • Click Run > Run SQL.
    • Click SQL > Run SQL.
    • Right-click in the SQL Source pane of the SQL 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 editor
    • Click Run > Run SQL.
    • Right-click in the SQL editor, and then click Run SQL on the pop-up menu.
  2. If you are running an SQL statement in a data design project, select a database connection in the Connection Selection wizard, and then click Finish. If the Finish button is not available, click Reconnect.
  3. If you are not connected to your database, specify your password in the Database Authorization window, and then click OK.
  4. 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.
The results are displayed in the Data Output view. It opens automatically if it is not already open.

If you have a connection to a database in this product and that connection is cancelled in some way from outside the workbench (for example, in DB2® by using the "force applications all" command), the fact that the connection has been dropped cannot be detected.

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 builder) does not work properly if the connection is dropped. To work around this problem, you must reconnect to the database.

Related concepts
Host variables in SQL statements in the SQL builder
Related reference
Data Output view

Feedback