Then try to access table SYSIBM.SYSDUMMYE
( By default that table is created in V8 Compatibility mode ).
If it exists, you are in V8.
Next access SYSIBM.SYSTABLES
if NAME and CREATOR are both VARCHAR(128), then that DB2 is V8 NFM,
otherwise NAME is VARCHAR(18) and CREATOR is CHAR(8)
Another approach:
Try any SQL, that's valid in V8 NFM only.
e.g.
SELECT IBMREQD, ( SELECT IBMREQD FROM SYSIBM.SYSDUMMY1 )
FROM SYSIBM.SYSDUMMY1
If you receive an syntax error, that DB2 is V7,
if you receive SQLCODE -4700, that DB2 is V8 CM,
if execution is successfull, that DB2 is V8 NFM.
( caution: that does not work, if you are INSTALL SYSADM. Those users do not get SQLCODE -4700, but may execute that statements in V8 CM )