Project

General

Profile

View the currently executing SQL statement » History » Version 4

chin-yeh, 11/08/2011 04:43 PM

1 1 chin-yeh
h1. View the currently executing SQL statement
2 2 chin-yeh
3
The *db2pd* utility can be used to troubleshoot the db2 active instance.
4
5
*Steps:*
6
# login as the owner of the db2 instance, e.g. *db2inst1*
7
# First, identify the list of *applications*:
8
<pre>
9
db2pd -db <<database alias name>> -applications
10
</pre>
11
# Based on the application command's output, filter out those applications with the *Status*, *UOW-WAITING* and *UOW-EXECUTING*
12
# Based on the filter-ed data, you can then identify the statement using the combination *L-AchID* and *L-StmtUID* columns.
13
# After obtained the value from *L-AchID* and *L-StmtUID*, execute the following command:
14
** Usage:
15
<pre>
16
db2pd -db store -applications -dyn | egrep '(<<L-AchID|>>|<<L-StmtUID>>)'
17
</pre>
18
** Example:
19
<pre>
20
db2pd -db store -applications -dyn | egrep '(123|4563)'
21
</pre>
22 4 chin-yeh
** Example (SQL may span multiple lines. Include the <code>-A</code> parameter to specify the *number of lines* to *grep after*):
23
<pre>
24
db2pd -db store -applications -dyn | egrep -A 15 '(123|4563)'
25
</pre>
26 2 chin-yeh
27
For more information about *db2pd* utility, see:
28
* http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.admin.trb.doc/doc/t0020807.html
29
* http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.admin.trb.doc/doc/c0054595.html