DB2 Cross Platform Function and Variable Compatibility

db2db2-luwdb2-midrangedb2-zos

Is there a db2 function/procedure/variable that can be used to determine what platform a data source origins from? sysibm.sysdummy1 exists, so I assume that this is Db2, but some of the SQL does not look right according to LUW syntax. Is there an easy way to figure out via SQL what platform a data source origins from?

Best Answer

It's a very open-ended question, as there is no sure-fire method to determine the server version and platform. You'll need to apply some heuristics.

In Db2 for LUW (and only LUW) since v 10.1 there's a system view dbmcfg that can return the server version:

select value from sysibmadm.dbmcfg where name = 'release'

so if it succeeds you'll be sure it's Db2 for LUW of certain release level. Similarly, since v 9.7 you can query sysibmadm.env_inst_info (or first search for it in syscat.tables).

Another indicator of Db2 for LUW is the presence of some Oracle-compatible views since v.9.7, e.g. syspublic.dual or sysibmadm.all_objects.

A good indicator of Db2 for z/OS would be the presence of mainframe-specific catalog tables, e.g. sysibm.locations or sysibm.syscopy, which go back to v9 at least.

The presence of catalog views in the QSYS and QSYS2 schemas, e.g. QSYS2.TABLES, will indicate Db2 for i (AS/400).

Neither Db2 for z/OS nor Db2 for i have the SYSCAT schema views.