728x90

DB2에서 오라클 호환모드를 사용할 때, PL/SQL에서 오라클 방식으로 VARCHAR ARRAY ( VARRAY )  타입의 데이터를 오라클 스타일로 초기화할 때 발생하는 오류에 대한 해결방법입니다. DB2에서 VARRAY 데이터 타입을 오라클 스타일로 초기화하려고 하면 함수로 인식해 SQL0440N 오류가 발생합니다.


Problem(Abstract)

A PL/SQL array constructor statement with the syntax as seen below, fails in DB2 with error SQL0440N 

For e.g.
v_List va1.t_Strings := va1.t_Strings('Harry', 'Ron', 'Hermione');
SQL0440N No authorized routine named routine-name of type routine-type having compatible arguments was found

Symptom

Error SQL0440N will be returned when a PL/SQL containing an array constructor is run in DB2.


Cause

DB2 does not support PL/SQL array constructor syntax, and therefore ends up trying to interpret the array constructor as a function call(routine).
However since it does not find a matching routine name corresponding to this, it ends up throwing the SQL0440N error.

Diagnosing the problem

If SQL0440N is returned when the PL/SQL statement is executed, then this issue can be confirmed by examining the PL/SQL to see if it uses an array constructor to initialize an array.

Resolving the problem

Workaround : 
Instead of using an array constructor to initialize the array, ie. instead of doing : 
v_List va1.t_Strings := va1.t_Strings('Harry', 'Ron', 'Hermione');

we can initialize the array as follows : 
v_List(1) := 'Harry';
v_List(2) := 'Ron';
v_List(3) := 'Hermione';


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

728x90
728x90

Question

How to move DB2 instance and databases from one filesystem to another

Cause

This is just to show all the overall steps needed to move the instance and databases. This is one of the ways.

Answer

First, need to take a full off-line db2 backup of the databases.

Then preserve all the instance level and database level configurations.

Specially, the dbm config, database config, registry settings.

db2cfexp could be used to preserve the instance level configurations,

http://www-01.ibm.com/support/knowledgecenter/api/content/SSEPGG_9.7.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002442.html

Then, drop the database and instance from current location.

Recreate instance in new location.

Update all the configurations as preserved earlier.

db2cfimp could be used to import back the instance level configurations,
http://www-01.ibm.com/support/knowledgecenter/api/content/SSEPGG_9.7.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002441.html

Then perform a redirect restore of the databases under new instance if the new container paths needs to be defined. Though the underline filesystem is changed, if the exact same paths as the source location are present in the destination location then regular restore should work fine.

Just to reiterate that the database level configurations will be propagated as part of backup/restore process and need not have to be taken care separately unless some new paths have to be redefined in the destination locations, example active log directory, archive path etc.


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

728x90
728x90

Problem(Abstract)

Creation of a new instance, by using 'db2icrt' command fails with,

DBI1295E The instance list could not be updated.

Symptom

'db2icrt' is being executed with the ROOT privileges.

'db2icrt' calls 'db2iset' to add the instance to the global registry. This fails, as can be seen in from the debug traces,


+ /db2test/software/ibm/db2/V10.1/instance/db2iset -a db2inst1
+ [ 255 -ne 0 ]
+ display_msg
/db2test/software/ibm/db2/V10.1/msg/en_US.iso88591/db2install.cat 295
DBI1295E The instance list could not updated.



Diagnosing the problem

If LD_LIBRARY_PATH is set in the '.profile' file of the ROOT user, it can be commented out, and 'db2icrt' should be executed again.



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

728x90
728x90

시스템

AIX 7100-02-02-1316 , "DB2 v10.5.0.3", "s140203"

AIX 7100-02-05-1415 , "DB2 v10.5.0.4", "special_32990


환경변수

(locale 관)

LANG=ko_KR.UTF-8

LC_COLLATE="ko_KR.UTF-8"

LC_CTYPE="ko_KR.UTF-8"

LC_MONETARY="ko_KR.UTF-8"

LC_NUMERIC="ko_KR.UTF-8"

LC_TIME="ko_KR.UTF-8"

LC_MESSAGES="ko_KR.UTF-8"

LC_ALL=


(terminal 관련)

TERM=xterm



위와 같은 환경에서 db2top을 실행했을 때 화면이 어그러지는 현상이 발생합니다.

환경변수 LANG을 en_US으로, TERM을 xterm, dtterm 등으로 설정했을 때 정상적으로 표시되었습니다.


IBM APAR에는 9.5버전에 대한 이슈만 나와있는데 10.5에서도 마찬가지인 것으로 보입니다.



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

http://db2commerce.com/2014/07/01/scrambled-output-from-db2top/

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

728x90
728x90

아래 내용은 DB2 10.5 환경의 UTF-8 코드셋 데이터베이스를 기준으로 합니다.

(eucKR 코드셋에서도 비슷하게 작동할 것으로 보입니다만 테스트가 필요합니다)

DB2에서 멀티바이트 문자에 LENGTH 함수를 사용하면 바이트 값을 리턴합니다.


UTF-8 인코딩에서 한글은 일반적으로 3바이트로 표현됩니다. (가 : ea b0 80)

DB2의 LENGTH 함수에서는 3을 리턴합니다.


10.5버전부터 LENGTH2, LENGTH4 와 같은 스칼라 함수를 지원합니다.


$ db2 "values length('가')"


1

-----------

          3


  1 record(s) selected.


$ db2 "values length2('가')"


1

-----------

          1


  1 record(s) selected.


$ db2 "values length4('가')"


1

-----------

          1


위와 같이 DB2의 LENGTH 함수 실행결과에서는 순수하게 바이트 길이를 표시해주고 length2 와 length4는 멀티바이트에 대응한 글자길이를 보여주게 됩니다.10.5 이전 버전에서는 character_length (또는 length) 함수에서 codeunits16, codeunits32 와 같은 인자값을 지정하여 사용했습니다. 유니코드의 경우 보통 3바이트로 표현하나 4바이트로 표현하는 문자도 아주 간혹 있어서 이같은 경우에는 codeunit32를 사용할 필요도 있습니다. 그러나 한글의 경우에는 4바이트로 표현하는 예는 없는 것 같습니다. 이에 대해 아시는 바가 있다면 알려주시기를 부탁드립니다.


참조. 오라클 작동방식 (11.2 버전 기준)

오라클의 경우 LENGTH 함수 실행결과 글자길이값을 보여줍니다. 오라클에서도 LENGTH2, LENGTH4 함수가 있는데 역시 DB2와 동일하게 작동합니다. 원래는 ORACLE함수이나 DB2에서도 호환성 측면에서 추가된 것으로 보입니다. 유니코드 캐릭터셋의 DB에서는 LENGTH4 함수가 LENGTH와 동일한 결과값을 보여줍니다. (기타 캐릭터셋에서는 확인이 필요합니다)


# export LANG=KO_KR.UTF-8

# export NLS_LANG=NLS_LANG=AMERICAN_AMERICA.AL32UTF8

# sqlplus scott/tiger


SQL> create table utftest (a varchar(100));


Table created.


SQL> insert into utftest values ('한?글');


1 row created.


SQL> select * from utftest;


A

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

한?글


SQL> select length(a) from utftest;


 LENGTH(A)

----------

         3


SQL> select length2(a) from utftest;


LENGTH2(A)

----------

         4


SQL>  select length4(a) from utftest;


LENGTH4(A)

----------

         3


SQL> insert into utftest values ('a한?글b');


1 row created.


SQL> select * from utftest;


A

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

한?글

a한?글b


SQL> select length(a) from utftest;


 LENGTH(A)

----------

         3

         5


SQL> select length2(a) from utftest;


LENGTH2(A)

----------

         4

         6


SQL> select length4(a) from utftest;


LENGTH4(A)

----------

         3

         5



참조

http://www.utf8-chartable.de/unicode-utf8-table.pl

http://www.ibm.com/developerworks/data/library/techarticle/dm-0705nair/

728x90
728x90


Problem(Abstract)

You have multiple tables in your database that have changed extensively and you are experiencing a performance degradation. Reorg and runstats are recommended on these tables. You can create reorg and runstats scripts to make DB2® performance tuning easy.

Resolving the problem

To generate and run reorg and runstats scripts:

  1. Log in as the DB2 administrator, and connect to the database.

  2. To create a script for reorg table, run the following command on one line:
    db2 "list tables for all" | awk '{print $2"." $1}' | awk '/\w/ {print $0}' | sed '/^Schema.Table/d' | sed '/^record(s)./d' | sed 's/^/REORG TABLE /g' | sed 's/$/;/g' > /tmp/reorg_tbl.ddl

  3. To create a script for reorg index, run the following command on one line:
    db2 "list tables for all" | awk '{print $2"." $1}' | awk '/\w/ {print $0}' | sed '/^Schema.Table/d' | sed '/^record(s)./d' | sed 's/^/REORG INDEXES ALL FOR TABLE /g' | sed 's/$/;/g' > /tmp/reorg_idx.ddl

  4. To create a script for runstats, run the following command on one line:
    db2 "list tables for all" | awk '{print $2"." $1}' | awk '/\w/ {print $0}' | sed '/^Schema.Table/d' | sed '/^record(s)./d' | sed 's/^/RUNSTATS on TABLE /g' | sed 's/$/ WITH DISTRIBUTION AND DETAILED INDEXES ALL;/g' > /tmp/runstats_tbl.ddl

  5. Run reorg against tables and indexes, then runstats by entering the following lines:
    db2 -tvf /tmp/reorg_tbl.ddl
    db2 -tvf /tmp/reorg_idx.ddl
    db2 -tvf /tmp/runstats_tbl.ddl

  6. Ignore the following message if you receive it: 
    SQL2212N The specified table is a view. The Reorganize Table utility cannot be run against a view.

  7. To capture the message printed on screen, you can pipe the standard output into a file, such as with the following command:
    db2 -tvf /tmp/runstats_tbl.ddl > filename.log 2>&1

    NOTE: The commands in step 2, 3 and 4 will not run on windows system.


The following method can also be used to reorg all the tables in a database on Linux, Unix and Windows. 
  1. Log in as the DB2 administrator, and connect to the database.
  2. To create a script for reorg table, run the following command on one line:

    db2 -x "select 'REORG TABLE ' ||rtrim (tabschema)|| '.' || rtrim (tabname) || ' ;' from syscat.tables where tabschema not like 'SYS%' and type = 'T'" > reorg.out
  3. Run reorg against tables entering the following line:
    db2 -tvf reorg.out
    NOTE: The where clause in step 2 can be altered to include other tables in the reorg.out script. 
    It is recommended to runstats on any table that has been reorged. 
    Also, these commands may not work on all versions and levels of Unix and Linux.


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

728x90
728x90


Question

Is it possible to prevent incoming database-connection attempts from application layer/driver from automatically activating the database.

Cause

Often, during maintenance events, a database is deactivated and the database-instance is stopped but the application is not stopped and will continue to attempt to establish a connection to the database while the database is under maintenance, this is not a problem in itself.
Later after maintenance completes and the database-instance is restarted and the database is activated, the application's attempt to establish a database connection will be successful.

However, there is a timing window where, after maintenance completes and the database-instance is started but before the database is activated, an application's database connection attempt can come in and automatically start database activation before a DBA has explicitly activated it. Since database activation can sometimes take several minutes, the application might timeout before the activation completes, and rollback the database activation. If the number of application threads attempting to connect to the database is very large, they may repeatedly start database activation ahead of the DBA's request to explicitly activate the database, and repeatedly timeout and rollback the activation. 
This can cause a repeated loop of automatic database activation and timeout/rollback, while the DBA's explicit request to activate the database appears to hang.

Answer

In order to prevent this kind of phenomenon, we can temporarily pause application database connection attempts from reaching the database server and automatically starting database activation, so that the DBA's request to explicitly activate the database can complete.


There are two methods that can be used:

Method #1: use the db2trc -suspend option to pause incoming database connections from reaching the database server, and then un-pause them after the DBA has completed database activation. (note that this method does not actually perform a trace, so it does not have any performance impact).

1) db2trc on -debug DB2.SQLCC.sqlcctcpconnmgr_child.115 -suspend 
2) db2start 
3) db2 activate database <dbname>
4) db2trc off 


Method #2: use the 'db2start admin mode restricted access' command to quiesce the database in restricted mode during db2start, and then unquiesce after the database activation is complete.

1) db2start admin mode restricted access 
2) db2 activate database <dbname>
3) db2 unquiesce instance <instance name>


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

728x90
728x90


Technote (troubleshooting)


Problem(Abstract)

While installing DB2 for Windows on or prior to 10.5 Fix Pack 3, 10.1 Fix Pack 3 and 9.7 Fix Pack 9 on Windows 8.1 and Windows 2012 R2, you might receive GUI related errors, errors related to shortcuts created during the installation, and errors pertaining to the db2prereqcheck tool.

Symptom

One of the following three error symptoms might be encountered during installation on Windows 8.1 & Windows 2012 R2.

1. GUI mode of Domain installation might fail with the "Windows installer has stopped working" error on "Select the installation type" Dialog.


2. GUI mode of Fix Pack update installation may fail with the following error:


3. Shortcuts created under All Apps for the default DB2 copy do not start on invocation immediately after installation.

4. With DB2 V10.1, the db2prereqcheck tool reports Windows 8.1 and Windows 2012 R2 as not supported platform:

Checking DB2 prerequisites for DB2 database version "10.1.0.3" on operating system "Windows"
OS is Windows "Server"
ERROR: Requirement not matched.
Requirement not matched for DB2 database "Server" . Version: "10.1.0.3".
Summary of prerequisites that are not met on the current system:
Requirement not matched for DB2 database "Server" . Version: "10.1.0.3".


Environment

Windows 8.1, Windows 2012 R2


Resolving the problem

For the currently available fix packs, choose the silent installation method using response files in the following scenarios as we do not have fully enabled GUI installs yet. This helps avoid the first two errors listed in the symptom section:
1. Domain installation
2. Fix Pack update installation

Further instructions on performing a silent installation using response files can be found in the "Related information" section below.

Also, if the shortcuts created under the All Apps directory for the DB2 copy do not start on invocation after the installation of DB2 for Windows either through the GUI or silent installation, log off and log back on again.

The db2prereqcheck tool reports Windows 8.1 and Windows 2012 R2 as not supported platforms for DB2.

These possible issues will be resolved in a future fix pack


728x90
728x90

Technote (troubleshooting)


Problem(Abstract)

When adding a security member for permissions or capabilities object, getting the error:
message CM-SYS-5092 

Symptom

CM-SYS-5092 
[jcc][10429][12554][3.63.75] A processing error occurred on the server
which resulted in an unrecoverable error. Please set deferPrepares
property to false and re-establish the connection. If the problem still
persists, please contact support. ERRORCODE=-4225, SQLSTATE=24514


Cause

DB2 issue with jdbc driver (type 4)

Environment

Content Store on database , server DB2 v9.7 FP5 (jdbc type 4)

Diagnosing the problem

In logs diagnose the error message ERRORCODE=-4225, SQLSTATE=24514
deferPrepares' is a DB2 property,
Please see the link below for more detail:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/c0010273.htm
DB2 Technote : http://www-01.ibm.com/support/docview.wss?uid=swg21168955

Resolving the problem

Set deferPrepares property to false and re-establish the connection. 
If the problem still persists, please contact DB2 support.



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

728x90
728x90

Error description

  • when there are applications in rollback or commit state, db2 get
    snapshot for locks on <db2_name> may receive sql1042c error.
    E.g.
    $ db2 get snapshot for locks on sample
    SQL1042C  An unexpected system error occurred.  SQLSTATE=58004
    Some other utility which relies on the service of monitor
    component could also be affected, e.g db2top. In db2top, using
    'U' option to collect lock information may also cause db2top
    exited with sql1042c error.
    The following records could be found in db2diag.log if turning
    on the database manager configuration parameter DIAGLEVEL to 4:
    2013-03-12-03.43.12.074851-240 I243248E595           LEVEL: Info
    PID     : 19365                TID : 46913030187328  KTID :
    xxxxxx
    PROC    : db2sysc
    INSTANCE: db2inst1             NODE : 000            DB   :
    SAMPLE
    APPHDL  : 0-21                 APPID:
    *LOCAL.db2inst1.130312073953
    AUTHID  : DB2INST1             HOSTNAME: host123
    EDUID   : 41                   EDUNAME: db2agent (instance)
    FUNCTION: DB2 UDB, database monitor, sqm_snap_appl_locks,
    probe:10
    DATA #1 : <preformatted>
    Snapshot cannot obtain lock information for application with app
    handle 13. Application in commit/rollback.
    The following records could be found in db2 trace:
    | | | | sqm___sqm_write_lock_waits entry [eduid 224497 eduname
    db2agent]
    | | | | sqm___sqm_write_lock_waits exit
    | | | sqm_snap_appl_locks data [probe 10]
    | | | sqm_snap_appl_locks exit [rc = 0x000004D2 = 1234]
    | | sqm___sqm_snap_db_locks exit [rc = 0x000004D2 = 1234]
    | | sqm___sqm_free_dbcb_list entry [eduid 224497 eduname
    db2agent]
    | | sqm___sqm_free_dbcb_list exit
    | sqm___sqlmonssagnt exit [rc = 0x000004D2 = 1234]
    | sqlm_buffer_postprocess entry [eduid 224497 eduname db2agent]
    | sqlm_buffer_postprocess data [probe 1]
    | sqlm_buffer_postprocess data [probe 2]
    | sqlm_buffer_postprocess exit
    | sqm___sqlmfree entry [eduid 224497 eduname db2agent]
    | sqm___sqlmfree exit [rc = 0xFFFFFFFF = -1]
      sqm___sqlmonssbackend exit [rc = 0xFFFFFFFF = -1]
    

Local fix

  • using db2pd -locks -db <db_name> to collect lock information
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * ALL                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * when there are applications in rollback or commit state, db2 *
    * get                                                          *
    * snapshot for locks on <db2_name> may receive sql1042c error. *
    *                                                              *
    *                                                              *
    *                                                              *
    * E.g.                                                         *
    *                                                              *
    *                                                              *
    *                                                              *
    * $ db2 get snapshot for locks on sample                       *
    *                                                              *
    * SQL1042C  An unexpected system error occurred.               *
    * SQLSTATE=58004                                               *
    *                                                              *
    *                                                              *
    * Some other utility which relies on the service of monitor    *
    *                                                              *
    * component could also be affected, e.g db2top. In db2top,     *
    * using                                                        *
    * 'U' option to collect lock information may also cause db2top *
    *                                                              *
    * exited with sql1042c error.                                  *
    *                                                              *
    *                                                              *
    *                                                              *
    * The following records could be found in db2 trace:           *
    *                                                              *
    *                                                              *
    *                                                              *
    * | | | | sqm___sqm_write_lock_waits entry [eduid 224497       *
    * eduname                                                      *
    * db2agent]                                                    *
    *                                                              *
    * | | | | sqm___sqm_write_lock_waits exit                      *
    *                                                              *
    * | | | sqm_snap_appl_locks data [probe 10]                    *
    *                                                              *
    * | | | sqm_snap_appl_locks exit [rc = 0x000004D2 = 1234]      *
    *                                                              *
    * | | sqm___sqm_snap_db_locks exit [rc = 0x000004D2 = 1234]    *
    *                                                              *
    * | | sqm___sqm_free_dbcb_list entry [eduid 224497 eduname     *
    *                                                              *
    * db2agent]                                                    *
    *                                                              *
    * | | sqm___sqm_free_dbcb_list exit                            *
    *                                                              *
    * | sqm___sqlmonssagnt exit [rc = 0x000004D2 = 1234]           *
    *                                                              *
    * | sqlm_buffer_postprocess entry [eduid 224497 eduname        *
    * db2agent]                                                    *
    * | sqlm_buffer_postprocess data [probe 1]                     *
    *                                                              *
    * | sqlm_buffer_postprocess data [probe 2]                     *
    *                                                              *
    * | sqlm_buffer_postprocess exit                               *
    *                                                              *
    * | sqm___sqlmfree entry [eduid 224497 eduname db2agent]       *
    *                                                              *
    * | sqm___sqlmfree exit [rc = 0xFFFFFFFF = -1]                 *
    *                                                              *
    * sqm___sqlmonssbackend exit [rc = 0xFFFFFFFF = -1]            *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to DB2 db2_v97fp6                                    *
    ****************************************************************
    

Problem conclusion

  • The fix will be included in DB2 db2_v97fp6
    

Temporary fix

  • using db2pd -locks -db <db_name> to collect lock information
    


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

728x90

+ Recent posts