66

How to check db2 version on Z/OS using only SQL commands?

Thanks, Melita

gizmo
  • 7,989
  • 6
  • 23
  • 22

15 Answers15

65

You can try the following query:

SELECT service_level, fixpack_num FROM TABLE
  (sysproc.env_get_inst_info())
  as INSTANCEINFO

It works on LUW, so I can't guarantee that it'll work on z/OS, but it's worth a shot.

CanSpice
  • 34,814
  • 10
  • 72
  • 86
23

There is also the env_inst_info admin view. As with CanSpice I can only vouch for LUW, but there should at least be a similar view available for Z/OS.

SELECT * FROM SYSIBMADM.ENV_INST_INFO
Christian Maslen
  • 1,100
  • 9
  • 13
  • 1
    For me, it is SYSIBMADM.ENV_SYS_INFO. Since I cannot find the table you provided, I just look at the tables under SYSIBMADM that looks like it. Thanks for this answer I found mine. – Jin Ginusuke Sep 16 '20 at 07:54
22
SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1
bugs
  • 237
  • 2
  • 3
  • 3
    This returns a value like 'DSN090100'. To see what that means checkout the link in [@Michael Sharek's answer](http://stackoverflow.com/a/3825610/152061). – Brad Cupit Mar 20 '13 at 14:23
  • 2
    Link in answer referenced above currently redirects [here](http://pic.dhe.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db2z9.doc.sqlref/src/tpc/db2z_refs2builtinsessionvars.htm). Adding for future reference, in case IBM deprecates the original link. – transistor1 Jun 18 '13 at 16:50
  • 3
    I have `SQL0440N No authorized routine named "GETVARIABLE" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884` on this – bbozo Feb 25 '16 at 16:22
10

I used

SELECT * FROM TABLE(SYSPROC.ENV_GET_INST_INFO()); 

from tyranitar and that worked on Z/OS. Here's what I got:

SERVICE_LEVEL
DB2 v9.7.0.6

I'd vote up if I could! Thanks!!

apesa
  • 12,163
  • 6
  • 38
  • 43
CCRDad
  • 125
  • 1
  • 4
  • 11
    This will *not* work on z/OS. You are running on DB2 for Linux, UNIX or Windows to get this result. – Ian Bjorhovde Jul 22 '13 at 19:24
  • 1
    Works for me! I get: |INST_NAME|IS_INST_PARTITIONABLE|NUM_DBPARTITIONS|INST_PTR_SIZE|RELEASE_NUM|SERVICE_LEVEL|BLD_LEVEL|PTF|FIXPACK_NUM|NUM_MEMBERS |xxx|0|1|64|060A010E|DB2 v10.5.0.9|s170908|IP24025|9|1 – Frans Dec 15 '18 at 10:55
  • I confirm that this is not working on z/OS for me too. – Rahul Khimasia Dec 03 '19 at 16:29
9

There is a typo in your SQL. Fixed version is below:

SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1;

I ran this on the IBM Mainframe under Z/OS in QMF and got the following results. We are currently running DB2 Version 8 and upgrading to Ver 10.

DSN08015  -- Format seems to be DSNVVMMM
-- PPP IS PRODUCT STRING 'DSN'
-- VV IS VERSION NUMBER E.G. 08
-- MMM IS MAINTENANCE LEVEL E.G. 015
rogerdeuce
  • 1,471
  • 6
  • 31
  • 48
Shariq A
  • 91
  • 1
  • 1
8

Both worked for me.

SELECT * FROM TABLE(SYSPROC.ENV_GET_INST_INFO());

or

SELECT * FROM SYSIBMADM.ENV_INST_INFO;
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
ramit girdhar
  • 2,272
  • 1
  • 25
  • 26
7

To find out the fixpak information using command prompt: db2level

To find out the version and license information using command prompt: db2licm -l

C:\Users\Administrator>db2level
DB21085I  This instance or install (instance name, where applicable: "DB2")
uses "64" bits and DB2 code release "SQL10051" with level identifier
"0602010E".
Informational tokens are "DB2 v10.5.100.63", "s130816", "IP23521", and Fix Pack

"1".
Product is installed at "C:\SQLLIB" with DB2 Copy Name "DB2COPY1".


C:\Users\Administrator>db2licm -l
Product name:                     "IBM Data Server Client"
Product identifier:               "db2client"
Version information:              "10.5"
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Ramesh John
  • 98
  • 1
  • 4
4

You can query for the built-in session variables with SQL. To identify the version of DB2 on z/OS, you need the SYSIBM.VERSION variable. This will return the PRDID - the product identifier. You can look up the human-readable version in the Knowledge Center.

SELECT GETVARIABLE('SYSIBM.VERSION')
FROM SYSIBM.SYSDUMMY1;

-- for example, the above returns DSN10015
-- DSN10015 identifies DB2 10 in new-function mode (see second link above)
orbanbalage
  • 187
  • 1
  • 9
3

Try the first or the second:

SELECT * FROM TABLE(SYSPROC.ENV_GET_INST_INFO());
SELECT * FROM TABLE(SYSPROC.ENV_GET_PROD_INFO());
SELECT * FROM TABLE(SYSPROC.ENV_GET_SYS_INFO());
Alberto
  • 2,881
  • 7
  • 35
  • 66
2

In z/OS while on version 10, use of CURRENT APPLICATION COMPATIBILITY is not allowed. You will have to resort to:

SELECT GETVARIABLE('SYSIBM.VERSION') AS VERSION,
       GETVARIABLE('SYSIBM.NEWFUN')  AS COMPATIBILITY
FROM SYSIBM.SYSDUMMY1;

Here is a link to all the variables available: https://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/sqlref/src/tpc/db2z_refs2builtinsessionvars.html#db2z_refs2builtinsessionvars

Darek
  • 4,687
  • 31
  • 47
1

Another one in v11:

select CURRENT APPLICATION COMPATIBILITY from sysibm.sysdummy1

Result:

V11R1

It's not the current version, but the current configured level for the application.

double-beep
  • 5,031
  • 17
  • 33
  • 41
0

For DB2:

"SELECT * FROM SYSIBMADM.ENV_INST_INFO" - SERVICE_LEVEL
Matteo Baldi
  • 5,613
  • 10
  • 39
  • 51
0

In AIX you can try:

db2level

Example output:

db2level
DB21085I  This instance or install (instance name, where applicable:
"db2inst1") uses "64" bits and DB2 code release "SQL09077" with level
identifier "08080107".
Informational tokens are "DB2 v9.7.0.7", "s121002", "IP23367", and Fix Pack
"7".
Product is installed at "/db2_09_07".
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Doug
  • 1
0

db2ls command will display the db2level along with the install path and install date.

To determine the specific product installed:

db2ls -p -q -b <installpath>

on db2ls command.

The following will appear:

Install Path       Level   Fix Pack   Special Install Number   Install Date    Installer UID
--------------------------------------------------------------------------------------------
/opt/ibm/db2/V9.7  9.7.0.7        7                      Thu Aug  1 12:25:53 2013 CDT     0

visit IBM Website

Suliman Farzat
  • 1,197
  • 11
  • 12
-1
SELECT GETVARIABLE(('SYSIBM.VERSION')
 FROM SYSIBM.SYSDUMMY1;
-- PPP IS PRODUCT STRING 'DSN'
-- VV IS VERSION NUMBER E.G., 10, 11
-- M IS MAINTENANCE LEVEL E.G. 5

-DISPLAY GROUP
 THIS WILL DISPLAY THE LEVEL CM, ENFM, N
Minar Mahmud
  • 2,577
  • 6
  • 20
  • 32