IBM Support

The 'db2level' failing with error code SQL1390C when DB2INSTANCE variable is not set.

Question & Answer


Question

There are some behavioral difference between the way db2level command of DB2 V9.1 and DB2 V9.5 works and the way the same command of DB2 V9.7 works. I have explained this below: I have 3 DB2 versions installed on a Windows 2003 system C:\Program Files\IBM\SQLLIB -> 9.5 C:\Program Files\IBM\SQLLIB_01 -> 9.1 C:\Program Files\IBM\SQLLIB_02 -> 9.7 The default DB2 instance on the system is DB2 which is a 9.5 instance. This is shown in the following env command ======================================================================== C:\Program Files\IBM\SQLLIB\BIN>env ALLUSERSPROFILE=C:\Documents and Settings\All Users APPDATA=C:\Documents and Settings\Administrator\Application Data CLASSPATH=.;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C: \PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj. zip;C:\PROGRA~1\ IBM\SQLLIB\java\db2jcc_license_cu.jar;C:\PROGRA~1\IBM\SQLLIB\bin;C: \PROGRA~1\IBM\SQLLIB\java\common.jar CLIENTNAME=XXXXXXX ClusterLog=C:\WINDOWS\Cluster\cluster.log CommonProgramFiles=C:\Program Files\Common Files COMPUTERNAME=XXXXX ComSpec=C:\WINDOWS\system32\cmd.exe DB2INSTANCE=DB2 FP_NO_HOST_CHECK=NO HOMEDRIVE=C: HOMEPATH=\Documents and Settings\Administrator C:\Program Files\IBM\SQLLIB\BIN> ========================================================================= So, with the DB2INSTANCE set to a 9.5 instance, I run the db2level command from 9.5 install directory, it shows the output properly: ========================================================================= C:\Program Files\IBM\SQLLIB\BIN>db2level DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL09053" with level identifier "06040107". Informational tokens are "DB2 v9.5.301.436", "s081210", "WR21427", and Fix Pack "3a". Product is installed at "C:\PROGRA~1\IBM\SQLLIB" with DB2 Copy Name "DB2COPY1". C:\Program Files\IBM\SQLLIB\BIN> ========================================================================= Same thing works fine even from the 9.1 install directory. Note that DB2INSTANCE is still set to a 9.5 instance i.e. DB2 ========================================================================= C:\Program Files\IBM\SQLLIB\BIN>cd ..\.. C:\Program Files\IBM>cd SQLLIB_01\BIN C:\Program Files\IBM\SQLLIB_01\BIN>db2level DB21085I Instance "DB2_01" uses "32" bits and DB2 code release "SQL09016" with level identifier "01070107". Informational tokens are "DB2 v9.1.600.703", "s081007", "WR21413", and Fix Pack "6". Product is installed at "C:\PROGRA~1\IBM\SQLLIB~1" with DB2 Copy Name "DB2COPY2". C:\Program Files\IBM\SQLLIB_01\BIN> ========================================================================= However, if I run the command from 9.7 install directory it fails if the DB2INSTANCE is set to 9.5 instance ========================================================================= C:\Program Files\IBM\SQLLIB_01\BIN>cd ..\.. C:\Program Files\IBM>cd SQLLIB_02\BIN C:\Program Files\IBM\SQLLIB_02\BIN>db2level SQL1390C The environment variable DB2INSTANCE is not defined or is invalid. C:\Program Files\IBM\SQLLIB_02\BIN> ========================================================================= So it looks like db2level command of 9.7 does not work when DB2INSTANCE variable is set to an instance other than 9.7.

Cause

DB2 working as designed.

Answer

DB2INSTDEF is the default instance variable that is specific to the current DB2 copy in use. Every DB2 copy has its own DB2INSTDEF profile registry variable. Instance names must be unique on the system; when an instance is created, the database manager scans through existing copies to ensure its uniqueness.

Use the following guidelines to set the default instance when using multiple DB2 copies:

  • If DB2INSTANCE is not set for a particular DB2 copy, then the value of DB2INSTDEF is used for that DB2 copy. This means:
  • If DB2INSTANCE=ABC and DB2INSTDEF=XYZ, ABC is the value that is used
  • If DB2INSTANCE is not set and DB2INSTDEF=XYZ, XYZ is used
  • If DB2INSTANCE is not set and DB2INSTDEF is not set, then any application or command that depends on a valid DB2INSTANCE will not work.

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.dbobj.doc/doc/t0023801.html

.........................................................................................

Here is a test that shows the error above and the use of the DB2INSTDEF variable.

D:\realv97\IBM\SQLLIB\BIN>db2set -all

[e] DB2PATH=D:\realv97\IBM\SQLLIB
[i] DB2INSTOWNER=XXXXX
[i] DB2PORTRANGE=60004:60007
[i] DB2INSTPROF=C:\DOCUMENTS AND SETTINGS\ALL USERS\APPLICATION DATA\IBM\DB2\DB2
COPY3
[i] DB2COMM=TCPIP
[g] DB2_EXTSECURITY=YES
[g] DB2SYSTEM=XXXXX
[g] DB2PATH=D:\realv97\IBM\SQLLIB
[g] DB2INSTDEF=DB2_03

D:\realv97\IBM\SQLLIB\BIN>db2level
DB21085I Instance "DB2_03" uses "32" bits and DB2 code release "SQL09071" with

level identifier "08020107".
Informational tokens are "DB2 v9.7.100.108", "s090906", "NT3297", and Fix Pack
"1".
Product is installed at "D:\realv97\IBM\SQLLIB" with DB2 Copy Name "DB2COPY3".


D:\realv97\IBM\SQLLIB\BIN>set DB2INSTANCE=DB2COPY2

D:\realv97\IBM\SQLLIB\BIN>db2level
DB21085I Instance "DB2_03" uses "32" bits and DB2 code release "SQL09071" with

level identifier "08020107".
Informational tokens are "DB2 v9.7.100.108", "s090906", "NT3297", and Fix Pack
"1".
Product is installed at "D:\realv97\IBM\SQLLIB" with DB2 Copy Name "DB2COPY3".

................

D:\realv97\IBM\SQLLIB\BIN>db2set DB2INSTDEF=

D:\realv97\IBM\SQLLIB\BIN>db2level
SQL1390C The environment variable DB2INSTANCE is not defined or is invalid.

D:\realv97\IBM\SQLLIB\BIN>db2set -all
[e] DB2PATH=D:\realv97\IBM\SQLLIB
[g] DB2_EXTSECURITY=YES
[g] DB2SYSTEM=XXXXX
[g] DB2PATH=D:\realv97\IBM\SQLLIB


.......................

D:\realv97\IBM\SQLLIB\BIN>db2set DB2INSTDEF=DB2_03

D:\realv97\IBM\SQLLIB\BIN>set DB2INSTANCE=DB2_02

D:\realv97\IBM\SQLLIB\BIN>db2level
DB21085I Instance "DB2_03" uses "32" bits and DB2 code release "SQL09071" with

level identifier "08020107".
Informational tokens are "DB2 v9.7.100.108", "s090906", "NT3297", and Fix Pack
"1".
Product is installed at "D:\realv97\IBM\SQLLIB" with DB2 Copy Name "DB2COPY3".


NOTE: The above scenario is consistent in DB2 UDB V8 , V9.1, V9.5, and V9.7

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"OTHER - Uncategorised","Platform":[{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1;8","Edition":"Enterprise Server;Express;Personal;Workgroup Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
23 June 2018

UID

swg21404033