728x90

Technote (FAQ)


Question

Can the sysmaster database be dropped manually?

Cause

Although it is not recommended to drop the System Monitoring Interface for Informix, yet under some circumstances a need might exist to drop the sysmaster database.

Answer

Steps:

  1. dbaccess sysmaster -
  2. delete from systables where tabid > 99 and partnum < '0x100000';
  3. delete from systables where tabname = 'sysdbspartn';
  4. close database;
  5. drop database sysmaster;



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

728x90
728x90

I believe that the answer you need is a user-defined aggregate, similar to this one:

CREATE FUNCTION gc_init(dummy VARCHAR(255)) RETURNING LVARCHAR;
    RETURN '';
END FUNCTION;
CREATE FUNCTION gc_iter(result LVARCHAR, value VARCHAR(255))
    RETURNING LVARCHAR;
    IF result = '' THEN
        RETURN TRIM(value);
    ELSE
        RETURN result || ',' || TRIM(value);
    END IF;
END FUNCTION;
CREATE FUNCTION gc_comb(partial1 LVARCHAR, partial2 LVARCHAR)
    RETURNING LVARCHAR;
    RETURN partial1 || ',' || partial2;
END FUNCTION;
CREATE FUNCTION gc_fini(final LVARCHAR) RETURNING LVARCHAR;
    RETURN final;
END FUNCTION;
CREATE AGGREGATE group_concat
    WITH (INIT = gc_init, ITER = gc_iter,
          COMBINE = gc_comb, FINAL = gc_fini);

Given a table of elements (called elements) with a column called name containing (funnily enough) the element name, and another column called atomic_number, this query produces this result:

SELECT group_concat(name) FROM elements WHERE atomic_number < 10;
Hydrogen,Helium,Lithium,Beryllium,Boron,Carbon,Nitrogen,Oxygen,Fluorine

Applied to the question, you should obtain the answer you need from:

SELECT id, group_concat(codes)
    FROM anonymous_table
    GROUP BY id;

CREATE TEMP TABLE anonymous_table
(
    id      INTEGER NOT NULL,
    codes   CHAR(4) NOT NULL,
    PRIMARY KEY (id, codes)
);
INSERT INTO anonymous_table VALUES(63592, 'PELL');
INSERT INTO anonymous_table VALUES(58640, 'SUBL');
INSERT INTO anonymous_table VALUES(58640, 'USBL');
INSERT INTO anonymous_table VALUES(73571, 'PELL');
INSERT INTO anonymous_table VALUES(73571, 'USBL');
INSERT INTO anonymous_table VALUES(73571, 'SUBL');
INSERT INTO anonymous_table VALUES(73572, 'USBL');
INSERT INTO anonymous_table VALUES(73572, 'PELL');
INSERT INTO anonymous_table VALUES(73572, 'SUBL');
SELECT id, group_concat(codes)
    FROM anonymous_table
    GROUP BY id
    ORDER BY id;

The output from that is:

58640 SUBL,USBL
63592 PELL
73571 PELL,SUBL,USBL
73572 PELL,SUBL,USBL

The extra set of data was added to test whether insert sequence affected the result; it appears not to do so (the codes are in sorted order; I'm not sure whether there's a way to alter - reverse - that order).


Note that this aggregate should be usable for any type that can be converted to VARCHAR(255), which means any numeric or temporal type. Long CHAR columns and blob types (BYTE, TEXT, BLOB, CLOB) are not handled.



http://stackoverflow.com/questions/715350/show-a-one-to-many-relationship-as-2-columns-1-unique-row-id-comma-separate?answertab=votes#tab-top

http://stackoverflow.com/questions/489081/group-concat-in-informix

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
728x90

data studio를 통해 인포믹스 액세스 플랜을 조회할 때 몇가지 시행착오에 대해 정리했습니다.

추적 파일 옵션을 켜고 파일 내용을 살펴본 것이 도움이 되었습니다.


1. 먼저 인포믹스 서버에 DRDA 프로토콜 연결 엔트리를 작성합니다. (drsoctop)

DRDA 프로토콜 연결이 아닌경우, 액세스 플랜을 조회하면 아래와 유사한 오류가 발생합니다.


[jcc][t4][2030][11211][3.68.61] 연결의 기본 소켓, 소켓 입력 스트림 또는 소켓 출력 스트림에 대한 조작 중에 통신 오류가 

발생했습니다. 오류 위치: Reply.fill() - insufficient data (-1). 메시지: 충분하지 않은 데이터. ERRORCODE=-4499, SQLSTATE=08001



2. Smart blob dbspace가 필요합니다.

원격에서 액세스 플랜을 조회할 때 XML형식의 데이터를 출력하는데 이를 위해 smart blob dbspace가 필요한 모양입니다. 


Invalid default sbspace name (sbspace).. SQLCODE=-9814, SQLSTATE=IX000, DRIVER=3.68.61

IDS_SBPSACE_NOT_CREATED: no message found for the key



3. Data Studio가 한글 환경일때 EXTDIRECTIVES, OPTIMLEVEL 등의 변수값을 영어로 수정해야 합니다.

한글 환경에서는 액세스 플랜 출력에 필요한 일부 변수값이 한글인 경우가 있습니다.

드롭다운 메뉴이기는 하지만 직접 입력하여 수정이 가능합니다.


COLLATION : en_us.8859-1 (한글의 경우 ko_kr.ksc, ko_kr.cp949, ko_kr.utf8)

EXTDIRECTIVES : on/OFF

OPTIMLEVEL : LOW/HIGH


변수가 한글 또는 잘못된 값인 경우 아래와 유사한 오류가 발생합니다.

Invalid values specified for the OPTIMLEVEL environment variable. SQLCODE: -26041, SQLSTATE: IX000



1. IBM Informix Developer’s Handbook (redbook)

2. Use EXPLAIN_SQL with any tool (Fernando Nunes)

3. http://informix-technology.blogspot.kr/2012/12/execution-plans-on-client-planos-de.html

728x90
728x90

Question

How do you rebuild sysadmin database manually without having to restart IDS?

Answer

Run these steps to rebuild sysadmin database manually:

cd $INFORMIXDIR/etc/sysadmin;
dbaccess - db_uninstall.sql;
dbaccess - db_create.sql;
dbaccess sysadmin db_install.sql;
dbaccess sysadmin sch_tasks.sql;
dbaccess sysadmin sch_aus.sql;
dbaccess sysadmin sch_sqlcap.sql;
dbaccess sysadmin start.sql;


Note: db_uninstall.sql will correctly return errors 329/111 and 349 if the sysadmin database does not exist. Ignore these errors and continue.


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

728x90
728x90

Technote (troubleshooting)


Problem(Abstract)

You are installing IDS. You noticed that there are several Java errors. You run the following command:

java -version 

JVMJ9VM011W Unable to load j9jit23: 
/home/informix/IDS_JRE/bin/libj9jit23.so: cannot restore segment prot 
after reloc: Permission denied 
JVMJ9VM011W Unable to load jclscar_23: 
/home/informix/IDS_JRE/bin/libjclscar_23.so: cannot restore segment prot 
after reloc: Permission denied 
Could not create the Java virtual machine.

Cause

SELinux is turned on


Resolving the problem

Turn off SELinux



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

728x90
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

Question

Remove Shared Memory Segments

Answer

Directions for removing shared memory segments are as follows: (must be root)

  1. Get your SERVERNUM from the onconfig
  2. Convert that to hex and add it to 5256 in hex
  3. ipcs -m |grep 5256+SERVERNUM(in hex)
  4. The ID is the second column in the output. Write down each of the ID numbers.
  5. Take the list of IDs and run ipcrm -m ID for each ID.

so an example is as follows: 

1. onstat -c |grep SERVERNUM 
SERVERNUM 60 # Unique id corresponding to a Dynamic Server Instance 

2. 0x5256 + 0x3c = 0x5292 

3. ipcs -m |grep 5292 
m 121 0x52924801 --rw-rw---- root informix 
m 122 0x52924802 --rw-rw---- root informix 
m 123 0x52924803 --rw-rw-rw- root informix 

4. ipcrm -m 121 
ipcrm -m 122 
ipcrm -m 123 

5. this command will confirm the segment has been removed 
ipcs -m |grep 5292


http://www-01.ibm.com/support/knowledgecenter/api/content/SSGU8G_11.50.0/com.ibm.admin.doc/ids_admin_1218.htm

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


728x90

+ Recent posts