728x90
 

Question

I found some indexes marked invalid after rollforward, or a HADR standby database become switched to primary.
Why the indexes are marked as invalid, and how I can recover the invalid indexes.

Cause

Db2 does not write index build or rebuild log records by default, rather Db2 marks the index as invalid so that recovery task can trigger to rebuild the index.

Answer

"Index rebuilding" means index creation, index reorg, classic table reorg, and rebuilding index in this article.
 
Indexes can be marked as invalid when:
  • Index rebuilding is not logged ( LOGINDEXBUILD=NO), then index rebuilding replayed.
  • Index rebuilding is logged ( LOGINDEXBUILD=YES), then index rebuilding replayed but INDEXREC is set as ACCESS_NO_REDO or RESTART_NO_REDO.
  • Failed offline reorg, or such failed offline reorg is replayed.
  • db2dart runs with /MI option.

Indexes can be rebuilt when:
  • There are one or more indexes marked invalid when a database restarts. i,e. Run RESTART DB with INDEXREC=RESTART
  • Someone access an index marked as invalid.
  • Run classic REORG TABLE command
  • Run REORG INDEXES or REORG INDEX command
  • Run CREATE INDEX statement
  • Run LOAD command, and it uses REBUILD option as INDEXING MODE
  • Run IMPORT or LOAD command with REPLACE option
  • Run TRAUNCATE TABLE statement

We can list all the indexes marked as invalid by the following query:
db2 "select tabschema, tabname, indname, datapartitionid, index_partitioning from table(sysproc.admin_get_index_info('','','')) as t where index_requires_rebuild='Y'"

We can recover the indexes marked as invalid by ether of the following ways.
 
a) Run RESTART DATABASE command (in case db cfg INDEXREC is set as RESTART)
The restart database command rebuild all the indexes set as INDEX_REQUIRES_REBUILD=Y
db2 restart database <database_name>
b) Run reorg indexes
db2 reorg indexes all on table <table_name> allow no access

Note: 
You can set LOGINDEXBUILD as YES to prevent indexes to be marked as invalid.
So, this setting is highly recommended in HADR databases.
Example:
db2 connect to <database_name>
db2 update db cfg using LOGINDEXBUILD YES

 

https://www.ibm.com/support/pages/db2-causes-mark-index-invalid-and-how-recover-indexes

 

[Db2] The causes to mark index invalid, and how to recover the indexes.

[Db2] The causes to mark index invalid, and how to recover the indexes.

www.ibm.com

 

728x90
728x90


Question

I want to prevent SQL0964C  "The transaction log for the database is full" error.
How can I monitor applications that remain uncommitted for a long time or consume huge amount of transaction log space?

 

Answer

The combination of MON_GET_UNIT_OF_WORK and MON_GET_CONNECTION table functions can be used to achieve such purpose.

  1. Create a file (mon_transactions.sql) containing following SQL:
    SELECT
    con.application_handle,
    con.application_id,
    con.application_name,
    con.client_pid,
    uow.uow_start_time,
    uow.uow_log_space_used
    FROM
    table(mon_get_connection(cast(null as bigint), -1)) as con,
    table(mon_get_unit_of_work(null, -1)) as uow
    WHERE
    con.application_handle = uow.application_handle and
    uow.uow_log_space_used != 0
    ORDER BY uow.uow_start_time ;
  2. Connect to the database that you want to monitor using user ID that has DBADM authority.
    db2 connect to [database]
  3. Execute the monitoring SQL created in Step 1. 
    db2 -tvf mon_transactions.sql

[example output]

APPLICATION_HANDLE  APPLICATION_ID                APPLICATION_NAME CLIENT_PID  UOW_START_TIME             UOW_LOG_SPACE_USED
------------------ ------------------------------ ---------------- ----------  -------------------------- ------------------
             20136 192.168.1.1.49538.181224175700 db2bp                 10648  2018-12-25-09.59.43.450650              15593
             20201 *LOCAL.db2inst1.181214145300   db2bp                  8948  2018-12-25-10.27.51.465542              15436
2 record(s) selected.

 

 

The application with a very old UOW_START_TIME could cause SQL0964C error. If the UOW_LOG_SPACE_USED keeps increasing for a particular application, that application may also cause a log full situation.

Additional tips

"mon_req_metrics" database configuration parameter needs to be set as BASE (default) or EXTENDED in order to collect the metrics using the monitoring SQL. You can confirm the current value of database configuration parameters with the following command.

db2 get db cfg for [database]

 

 

728x90
728x90

데이터베이스 마이그레이션, 리스토어(RESTORE) 작업으로 인해 루틴이 INVALID 상태로 빠지는 경우가 있습니다. 아래에서 설명하는 sysproc.admin_revalidate_db_objects 프로시저를 사용해 오브젝트 별 또는 일괄로 루틴들을 재컴파일 할 수 있습니다.


Question

DB2 Package could be revalidated by either the REBIND or the BIND command, however it may not work for SQL routines, how to mark a routine to be VALID?

Cause

For some reasons, some packages or routines may be marked as INVALID. For package which is invalid, it will allow revalidation to occur implicitly when the package is first used, or to occur explicitly by either the REBIND or the BIND command.
The rebind_rouine_package function will rebind the package associate with the SQL procedure, it will mark the related package itself VALID as well.
-> 해당 루틴이 VALID인지는 syscat.routines 카탈로그 테이블을 참조하면 됩니다. 'N'이면 INVALID 상태입니다.

However it is not the case for routine, it could not mark the routine VALID by REBIND, BIND command, and the rebind_rouine_package function.


Answer

As REBIND validate the package only, for routine to be VALID, it needs to revalidate it implicitly by accessing it, or call function such as admin_revalidate_db_objects explicitly.


For example: call sysproc.admin_revalidate_db_objects('PROCEDURE','MY_SCHEMA','MY_PROCEDURE')
-> 특정 프로시저나 함수이름을 지정할 수 있고, 특정 스키마에 대한 일괄 수행을 하려면 NULL을 씁니다.

It is different to revalidate objects that are inside of a module,
If the routine is within one module, it needs to use the MODULE type with the name of a specific module in ADMIN_REVALIDATE_DB_OBJECTS call,
and all of the invalid objects include routines inside of that module will be revalidated.

Such as the routine SYSIBMADM.WRITE_BLOB could NOT be revalidated by:
call sysproc.admin_revalidate_db_objects('PROCEDURE','SYSIBMADM','WRITE_BLOB').

Instead, as it belongs to UTL_MAIL module, it needs to be revalidated by:
call sysproc.admin_revalidate_db_objects('MODULE','SYSIBMADM','UTL_MAIL').


https://www-01.ibm.com/support/docview.wss?uid=swg21472742

728x90
728x90

DB2 LUW 11버전이 출시되고, 업데이트가 이뤄지면서 이전과는 버전을 표기하는 방식이 바뀌었습니다.

아래 표와 링크에서 버전에서 나타내는 각 요소별 의미를 확인해보시기 바랍니다.

 

Element Example  Description
V - Version Number11.1.2.3
  • Indicates a separate IBM licensed program that usually has significant new code or capability
  • Contains major feature changes
  • Starts a new 5 year maintenance clock
  • Downloads found on Passport Advantage
R - Release Number11.1.2.3
  • Minor but significant feature change release
  • Starts a new 5 year maintenance clock
  • Downloads found on Passport Advantage
M - Modification Number11.1.2.3
  • Product refresh also referred to as a Mod Pack
  • Can include new functionality
  • Does not start a new maintenance clock
  • Downloads found on Fix Central
F - Fix Number11.1.2.3
  • Cumulative update of all available fixes and APARs
  • Does not start a new maintenance clock
  • Downloads found on Fix Central
iFix - Interim Fix11.1.2.3 iFix001
  • Tested and verified set of small number of key fixes and APARs, available to all
  • Subsequent iFixes are cumulative
  • Downloads found on Fix Central
  • Supported for the maintenance life of the Version.Release

 

출처 : https://www.ibm.com/developerworks/community/blogs/IMSupport/entry/All_about_ifixes_interim_fixes?lang=en

728x90
728x90

오라클 호환모드가 설정되어 있는 데이터베이스에서 트리거 생성시 오류가 발생하는 케이스에 대해 소개합니다.

DB2 인스턴스 계정에서 db2set 명령으로 오라클 호환모드 설정내역을 확인합니다.


$ db2set -all

[i] DB2_COMPATIBILITY_VECTOR=ORA

[i] DB2_SKIPINSERTED=on

[i] DB2_OPTPROFILE=yes

[i] DB2_EVALUNCOMMITTED=yes

[i] DB2_SKIPDELETED=on

[i] DB2DBDFT=hansdb

[i] DB2COMM=TCPIP

[i] DB2AUTOSTART=NO



$ db2 "create table test (aa int, id char(20))"
DB20000I  The SQL command completed successfully.
$ db2 "create table test_his (aa int, id char(20))"
DB20000I  The SQL command completed successfully.

아래는 트리거 내용입니다.

$ cat create_trigger.sql
   CREATE OR REPLACE TRIGGER TRI1 NO CASCADE AFTER INSERT on TEST
      REFERENCING NEW AS N
      FOR EACH ROW
      BEGIN
             INSERT INTO TEST_HIS (aa,id) VALUES (N.aa, N.id);
      END
!

트리거를 생성하려고 하면 아래와 같이 SQL0206N 오류가 발생합니다.

$ db2 -td! -f create_trigger.sql
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0206N  "N.AA" is not valid in the context where it is used.  LINE NUMBER=5.
SQLSTATE=42703

오류 원인은 오라클 호환모드로 인한 것으로, 오라클 호환모드에서 위와 같이 TRIGGER 생성 구문을 사용하면 우선적으로 오라클 스타일로 해석되는 것 같습니다.
따라서 DB2 스타일로 인식되도록 FOR EACH ROW를 FOR EACH ROW MODE DB2SQL 로 바꿔줍니다.

CREATE TRIGGER TRI1 AFTER INSERT on TEST
      REFERENCING NEW AS N
      FOR EACH ROW MODE DB2SQL
      BEGIN
             INSERT INTO TEST_HIS VALUES (N.aa, N.id);--
      END
!


http://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000931.html


728x90
728x90

OS: CentOS 6.6

DBMS: IBM DB2 9.1.0.5


위의 환경에서 데이터베이스를 생성하고 JDBC 클라이언트 및 로컬에서 특정 사용자로 접속시도하면 오류가 발생했습니다.

지원되지 않는 패스워드 알고리즘으로 패스워드를 생성한 것이 원인이었습니다.


db2 커맨드로 접속시 발생한 오류

$ db2 connect to dbname user ??? using ???

SQL30082N  Security processing failed with reason "15" ("PROCESSING FAILURE").

SQLSTATE=08001


자바(jdbc)를 통한 연결 오류

com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException: [jcc][t4][2010][11246][4.16.53] Connection authorization failure occurred.  Reason: Local security service non-retryable error. ERRORCODE=-4214, SQLSTATE=28000


아래와 같이 authconfig를 사용하여 현재 설정된 패스워드 알고리즘 방식을 확인합니다.

CentOS 6.6에서는 기본이 sha512 알고리즘을 사용하는 모양입니다.


# authconfig --test | grep password

 shadow passwords are enabled

 password hashing algorithm is sha512 


아래와 같이 authconfig를 사용하여 현재 설정된 패스워드 알고리즘 방식을 확인합니다.

CentOS 6.6에서는 기본으로 sha512 알고리즘을 사용하는 모양입니다. DB2 9.1에서는 Crypt, MD5. SHA1 알고리즘만 지원한다고 합니다.

따라서 아래와 같이 설정하고 DB2 사용자 패스워드 재설정한 후에는 접속이 잘 이루어졌습니다.


# authconfig --passalgo=md5 --update


아래는 해당 내용에 대한 IBM문서입니다. 참고하시기 바랍니다.


SQL30082 RC=24 or RC=15 returned when connecting to database on Server when pwd_algorithm is Crypt, MD5, SHA1, SHA256, SHA512, Blowfish

Problem(Abstract)

A local or remote connection to a database using:

db2 connect to sample user <userid> using <password>

returns

SQL30082N Security processing failed with reason "24" ("USERNAME AND/OR 
PASSWORD INVALID"). SQLSTATE=08001 

The error in db2diag.log is 
2011-01-01-17.21.43.367890-300 I1011620A272 LEVEL: Warning 
PID : 123456 TID : 1 
FUNCTION: DB2 Common, Security, Users and Groups, secLogMessage, probe:
20 
DATA #1 : String, 66 bytes 
Password validation for user db2inst1 failed with rc = -2146500507 

OR 

SQL30082N Security processing failed with Reason Code 15
"Security processing at the server failed " 

2011-10-19-14.05.06.682505-300 I2778202A437 LEVEL: Warning 
PID : 10813678 TID : 6958 PROC : db2sysc 0
INSTANCE: db2inst1 NODE : 000 DB : CMDB 
APPHDL : 0-117 
EDUID : 6958 EDUNAME: db2agent (CMDB) 0 
FUNCTION: DB2 UDB, bsu security, sqlexLogPluginMessage, probe:20 
DATA #1 : String with size, 67 bytes 
Password validation for user testuser failed with rc = -2029059891

Symptom

No connections can be made to the database when userid and password are provided. These connections fail with SQL30082N with Reason "24" or "15" returned.


Cause

DB2 Version 9.1 and Version 9.5 up to Fixpack 3 support the following encryption algorithms.

Crypt 
MD5 
SHA1

From DB2 Version 9.5 Fixpak 4 and versions beyond, the following algorithms are supported:

Crypt 
MD5 
SHA1 
SHA256 
SHA512 
Blowfish

For example, on AIX this is coded in the /etc/security/login.cfg file.

The error is received if you use the unsupported encryption algorithm and may show up in the db2diag log like this: 

2011-10-19-14.05.06.682321-300 I2777674A527 LEVEL: Severe
PID : 9633910 TID : 258 PROC : db2ckpwd 0
INSTANCE: db2inst1 NODE : 000
EDUID : 258 EDUNAME: db2sysc 0
FUNCTION: DB2 UDB, oper system services, sqloGetUserAttribByName, probe:50
MESSAGE : Unsupported password encryption algorithm in use! Configure the 
Operating System to use a supported algorithm.
DATA #1 : Hexdump, 4 bytes
0x07000000003F7F00 : 870F 00CD .... 

To check what encryption algorithm is being used the login.cfg file will contain something like:

usw:
shells = /bin/sh,/bin/bsh,/bin/csh,/bin/ksh,/bin/tsh,/bin/ksh93,/usr/bin
/sh,/usr/bin/bsh,/usr/bin/csh,/usr/bin/ksh,/usr/bin/tsh,/usr/bin/ksh93,/usr/sbin
/sliplogin,/usr/sbin/uucp/uucico,/usr/sbin/snappd,/bin/false
maxlogins = 32767
logintimeout = 60
pwd_algorithm = sha256
auth_type = STD_AUTH

OR the passwd.txt file will show something like this: 

root:
password = {sha256}06$SBysqAi4UQQ1nxC3$L55aKwmscvwxnKskkVrMk0HddbJyNkoE
v6HNXoLO.kH


Environment

ALL

Resolving the problem

Please use one of the supported encryption algorithms based on the version of DB2 that is being used.



http://m.blog.naver.com/june0313/50163164703

https://www-304.ibm.com/support/docview.wss?uid=swg21470246

https://www-304.ibm.com/support/docview.wss?uid=swg21416382

http://www-01.ibm.com/support/docview.wss?uid=swg21623221


728x90
728x90

SQL0727N 오류는 여러가지 원인으로 발생하는데 그중 하나의 예를 소개합니다.


1. 현상 : 테이블에 데이터 입력하는 프로시저 호출 불가

2. 원인 : 해당 테이블(또는 뷰에서 바라보는 테이블)의 트리거 inoperative 상태


테이블의 트리거가 inoperative 상태로 빠지면, 해당 테이블에 대해서 DML(INSERT, DELETE, UPDATE) 이 작동하지 않게됩니다.

아래와 같이 syscat.systrigger 테이블의 VALID 컬럼이 Y가 아닌 상태의 트리거가 있는지 확인합니다.


$ db2 "select substr(trigname,1,20) trigname,valid from syscat.triggers where valid <> 'Y'"


TRIGNAME             VALID

-------------------- -----

NEW_HIRED            N


이 상황에서 INSERT (DELETE, UPDATE) 를 실행하면 아래와 같이 오류가 발생합니다.

$ db2 "update employee set lastname='JEONG' where empno=200340"
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0727N  An error occurred during implicit system action type "3".
Information returned for the error includes SQLCODE "-204", SQLSTATE "42704"
and message tokens "DB2I105.COMPANY_STAT".  LINE NUMBER=2.  SQLSTATE=56098



참고사항)

이런 상태의 트리거는 CREATE TRIGGER문으로 작성하면 아래와 같이 Warning 메시지가 발생하면서 기존의 TRIGGER가 대체됩니다.


SQL0280W  View, trigger or materialized query table "DB2I105.NEW_HIRED" has

replaced an existing inoperative view, trigger or materialized query table.

SQLSTATE=01595


이에 대해서는 IBM Knowledge Center에도 나와있습니다.

An inoperative trigger may be recreated by issuing a CREATE TRIGGER statement using the definition text of the inoperative trigger. This trigger definition text is stored in the TEXT column of the SYSCAT.TRIGGERS catalog view. Note that there is no need to explicitly drop the inoperative trigger in order to recreate it. Issuing a CREATE TRIGGER statement with the same trigger-name as an inoperative trigger will cause that inoperative trigger to be replaced with a warning (SQLSTATE 01595).
 
Inoperative triggers are indicated by an X in the VALID column of the SYSCAT.TRIGGERS catalog view.

뷰, 트리거 등의 오브젝트 상태도 주기적으로 체크하면 좋을 것 같습니다.


https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000931.html


728x90
728x90

Technote (troubleshooting)


Problem(Abstract)

SQL0805N error, Package.Nullid.SYSLH203 was not found. SQLSTATE=51002, returned when attempting to perform a DML statement on the database server from a remote client application.

Cause

The package, SYSLH203, doesn't exist on the database server.

Resolving the problem

Depending on the type of statement you are executing, DB2 will use a particular package on the server. By default, DB2 creates three packages for each type of package. In this case NULLID.SYSLH2yy is reserved for statements with CURSORHOLD on and isolation level Cursor Stability. The package SYSLH203 means that DB2 is looking for the 4th package (200 is first, 201 is second, etc) of this type, but it does not exist. You can create more packages on the server by connecting to the database and issuing the following bind command from the /sqllib/bnd directory:

db2 bind @db2cli.lst blocking all grant public sqlerror continue CLIPKG 5

Note: CLIPKG 5 will create 5 large packages, and will give you the package that your application is looking for, as well as one more in this case.



http://www-01.ibm.com/support/docview.wss?uid=swg21208123

728x90
728x90

Question

When a DB2 java application is executing a lot of concurrent SQL statements, it may hit the limit reporting "Out of Package Error Occurred" with the SQLCODE -805. If you encounter this error, You may ask what the limit is for the number of concurrent statements for a DB2 Java application and how to increase it.

Answer

When a DB2 Java application is running a dynamic SQL statement, it uses a dynamic section from DB2 CLI packages at DB2 server side to prepare/execute the statement. Please note that these DB2 CLI packages are exactly the same packages used by a CLI application.
By default, there are 3 large CLI packages (containing 385 sections) and 3 small CLI packages (containing 65 sections) bound at a DB2 database server. There are two sections from each package (both large and small) which are reserved for positioned update/delete statements and execute immediate statements. Therefore the total number of available sections for all other statements by default is (3 * 63) + (3 * 383) = 1338, which means by default a DB2 Java application can only run 1338 dynamic statements at one time.

When this limit is hit, the application will receive an error of "Out of Package Error Occurred" with SQLCODE -805, which means the DB2 server was running out of dynamic sections available from the CLI packages.

For example, running below Java application would hit the limit and report the error as below:


PreparedStatement pStmt = null;
for (int i=1; i<=1339; i++) {
pStmt = db.con.prepareStatement("insert into myt values (1, 'name1')");
pStmt.execute();
}


***** Out of Package Error Occurred (2014-05-14 22:20:32.431) *****

Exception stack trace:
com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSLH204 0X5359534C564C3031, DRIVER=3.64.106
com.ibm.db2.jcc.am.bd.a(bd.java:682)
com.ibm.db2.jcc.am.bd.a(bd.java:60)
com.ibm.db2.jcc.am.bd.a(bd.java:127)
com.ibm.db2.jcc.am.io.c(io.java:2706)
com.ibm.db2.jcc.t4.ab.p(ab.java:872)
com.ibm.db2.jcc.t4.ab.h(ab.java:144)
com.ibm.db2.jcc.t4.ab.b(ab.java:41)
com.ibm.db2.jcc.t4.p.a(p.java:32)
com.ibm.db2.jcc.t4.qb.i(qb.java:135)
com.ibm.db2.jcc.am.io.gb(io.java:2112)
com.ibm.db2.jcc.am.jo.rc(jo.java:3526)
com.ibm.db2.jcc.am.jo.b(jo.java:3976)
com.ibm.db2.jcc.am.jo.hc(jo.java:2732)
com.ibm.db2.jcc.am.jo.execute(jo.java:2715)
DbConn2.main(DbConn2.java:74)

Concurrently open statements:
1. SQL string: INSERT INTO MYT VALUES (1, 'NAME1')
Number of statements: 1339
********************

DB2 SQL Error: SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSLH204 0X5359534C564C3031, DRIVER=3.64.106


Then what to do if you encounter above errors?

1) firstly you need to check if you can modify the application to avoid running so many dynamic SQL statements at the same time. 

2) If you can't avoid it, you will need to increase the number of available sections by increasing the number of DB2 CLI packages. 

Please note that only the number of DB2 CLI large packages can be increased, not for small packages, and the maximum number of large packages you can increase to is 30, which also basically means the maximum available sections would be (3 * 63) + (30 * 383) = 11679.

3) To increase the number of large CLI packages, you can run DB2 bind command with CLIPKG option via the instance owner as following example:

cd ~/sqllib/bnd
db2 connect to SAMPLE

--CLPKG 10, means it will increase the number of large CLI packages to 10.
db2 "bind @db2cli.lst CLIPKG 10 grant public blocking all"

--You can then check the number of CLI large packages per isolation and cursor holdability, where you will see the number would be 10 now.

db2 "list packages for all"

db2 terminate


http://www-01.ibm.com/support/docview.wss?uid=swg21670200&myns=swgimgmt&mynp=OCSSEPGG&mync=E

728x90
728x90

Question

How to collect explain data / access plan for SQL stored procedures in DB2?

Answer

In both techniques outlined below, the explain tables need to be created. For more information on doing this task, see Explain Tables.

Technique 1: Obtain the explain plan when creating the stored procedure:

1) Turn on explain either:

  • Dynamically within the scope of the current session by issuing
    db2 "call SET_ROUTINE_OPTS('EXPLAIN ALL')" 
  • Or, globally at the instance level if the procedure is not being called within the current session
    db2set DB2_SQLROUTINE_PREPOPTS="EXPLAIN ALL"
    db2 terminate 
    db2stop 
    db2start 
2) Run the create statement for the SQL procedure that requires explaining. If one of the same name already exists, you may need to drop the procedure first or create a similar procedure under a different schema or name. 

3) The resulting explain data will be stored in the explain tables and can be extracted with a command such as the following: 
db2exfmt -d db_name -g TIC -w -1 -n % -s % -# 0 -o outputfilename

4) Disable explain by either issuing either one of these commands depending on how it was enabled. 
  • If it was turned on for the current session: 
    db2 "CALL SYSPROC.SET_ROUTINE_OPTS('')"
  • If it was turned on globally
    db2set DB2_SQLROUTINE_PREPOPTS=
    db2 terminate 
    db2stop 
    db2start

Technique 2: Obtain the explain plan from the package without needing to re-create the procedure: 

Assuming the explain tables under a schema called EXPLAIN_SCHEMA, do the following: 

1) Call the stored procedure 

2) Using a unique portion of the SQL statement from the body of the stored procedure logic you are interested in obtaining the explain for, use the following SQL statement to obtain the executable_id. This is an example if the SQL statement contains "INSERT INTO SYSIBM.SYSDUMMY1". Note: The query is case-sensitive.

db2 "SELECT executable_id FROM TABLE(MON_GET_PKG_CACHE_STMT (NULL, NULL,NULL, -1)) AS T where stmt_text like '%INSERT INTO SYSIBM.SYSDUMMY1%'"

3) With the executable_id returned in step 2 (For example: x'0100000000000000581E00000000000002000000010020140109134503816499'), make the following call. Also replace EXPLAIN_SCHEMA with your actual explain schema.

db2 "call EXPLAIN_FROM_SECTION(x'0100000000000000581E00000000000002000000010020140109134503816499', 'M', NULL, 0, 'EXPLAIN_SCHEMA', ?, ?, ?, ?, ?)"

This will populate the explain tables under the schema you specified

4) Run this command to extract the explain plan:
db2exfmt -d <db name> -g TIC -w -1 -n % -s % -# 0 -o exfmt.out



http://www-01.ibm.com/support/docview.wss?uid=swg21279292

728x90

+ Recent posts