Canceling a federated query

You can interrupt an application and cancel a running query. With this support, you can cancel a query on the remote data source application before it finishes, and propagate the query interrupt and cancellation to the remote data source.

About this task

Restrictions

Starting in Version 9.7, you can interrupt an application and cancel a running query on the Db2® data source only.

You can cancel federated SELECT statements, INSERT, UPDATE and DELETE statements, federated stored procedures, and statements in pass-through sessions.

A federated statement can contain multiple segments that access multiple data sources. If a segment accesses a data source that is not supported, for example, multiple query segments against the Sybase data source, you cannot cancel the statement.

You cannot cancel a federated query when ATQ (asynchronous table queue) is enabled.

About this task

When the federated server is running a federated SQL statement and is blocked waiting for results and for a response from the remote data source, the application on the federated server is in 'federated request pending' state. You can issue the LIST APPLICATIONS command to identify applications in ‘federated request pending' state.

When an application is in 'federated request pending' state, you can use Ctrl-C to interrupt and cancel an application or use the FORCE APPLICATION command to stop an application on the remote server.

Procedure

To cancel a federated query, use either of the following methods:

  • Press Ctrl-C to interrupt the application

    You can press Ctrl-C to interrupt the application and cancel the query running on the remote server. The current SQL statement on the federated server is interrupted and canceled, and local database consistency is maintained. The remote statement is also canceled. Both the outbound and inbound connections remain active.

  • Issue the FORCE APPLICATION command

    You can issue the FORCE APPLICATION command to stop an application. The application is stopped on the federated server and transaction consistency is maintained both locally and on the remote server. The inbound and outbound connections are closed and the remote portion of the application execution on the remote data source is canceled.