473,795 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the current DB2 Version on v8 and higher.

I reviewed a similar post on an older version of DB2. I was wondering
if there was anything available now that is more precise in gathering
the db2 version for the new v8 calls.

I am running DB2 v8 FP9 and was wondering if anyone knows if there is
an existing API (or perhaps an easy way) to obtain the current DB2
version on the machine?

I have only found one way so far where you can use the statement as
follows:
"SELECT service_level, fixpack_num FROM TABLE
(sysproc.env_ge t_inst_info())
as INSTANCEINFO"

I can obtain values such as service_level = DB2 v8.1.1.88 and
fixpack_num
= 9.

These two fields combined tell me this is define "db2Version822" . I
need this
value in the new calls such as db2CfgGet().

This seems like a very tedious way to determine the predefined value as
it
took me some research to even relate the information in the system
table to
the DB2 defines.

Since DB2 now requires a version number to be passed in to these API
calls, does anyone know of a way to get the direct value? This could
be db2Version810 or SQL_REL8100 or even 8.1.0.0. Any of these would be
better than trying to determine which service level and fixpack relates
to the version.

FYI...here are the defines:

#define db2Version810 SQL_REL8100 //Version 8.1.0.0
#define db2Version812 SQL_REL8102 //Version 8.1.0.2
#define db2Version814 SQL_REL8104 //Version 8.1.0.4
#define db2Version820 SQL_REL8200 //Version 8.2.0.0
#define db2Version822 SQL_REL8202 //Version 8.2.0.2

Thanks

Jan 10 '06 #1
9 12686
shorti wrote:
I reviewed a similar post on an older version of DB2. I was wondering
if there was anything available now that is more precise in gathering
the db2 version for the new v8 calls.

I am running DB2 v8 FP9 and was wondering if anyone knows if there is
an existing API (or perhaps an easy way) to obtain the current DB2
version on the machine?

I have only found one way so far where you can use the statement as
follows:
"SELECT service_level, fixpack_num FROM TABLE
(sysproc.env_ge t_inst_info())
as INSTANCEINFO"

I can obtain values such as service_level = DB2 v8.1.1.88 and
fixpack_num
= 9.

These two fields combined tell me this is define "db2Version822" . I
need this
value in the new calls such as db2CfgGet().

This seems like a very tedious way to determine the predefined value as
it
took me some research to even relate the information in the system
table to
the DB2 defines.

Since DB2 now requires a version number to be passed in to these API
calls, does anyone know of a way to get the direct value? This could
be db2Version810 or SQL_REL8100 or even 8.1.0.0. Any of these would be
better than trying to determine which service level and fixpack relates
to the version.

FYI...here are the defines:

#define db2Version810 SQL_REL8100 //Version 8.1.0.0
#define db2Version812 SQL_REL8102 //Version 8.1.0.2
#define db2Version814 SQL_REL8104 //Version 8.1.0.4
#define db2Version820 SQL_REL8200 //Version 8.2.0.0
#define db2Version822 SQL_REL8202 //Version 8.2.0.2

Thanks


Is output of db2level command sufficient for you?

D:\Working>db2l evel
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08024" with
level identifier "03050106".
Informational tokens are "DB2 v8.1.11.958", "s060105", "WR21365", and FixPak
"11".
Product is installed at "D:\SQLLIB" .
Jan 10 '06 #2
db2level gives me the same information as the
sysproc.env_get _inst_info() stated above. The only difference is I can
use the select statement above to fetch the data into a host variable
so I can do a string compare or something similar. In your case, the
level is DB2 v8.1.11.958 with fixpak 11 is the same as which official
release listed above?? Is it the same as db2Version822 or is that now
a new level such as db2Version824? I would probably have to call DB2
to verify where that matches each time they came out with a new fixpak
or release level.

Many of the v8 API calls are expecting one of the db2Uint32 defines on
the list (db2Version810, db2Version812,d b2Version814, etc ). I would
think there would be an easier way to get the version since it is now
required but I cannot seem to find the information.

Jan 11 '06 #3
One thought from a coworker was, since the defines for the db2 Version
are placed in the db2ApiDf. h and sql.h, scan the header file for the
last db2Version and use it with the assumption that the most current
level must be what is on the machine otherwise it would not exist in
the header. I look at this as being potentially dangerous as I cannot
control the accuracy of the file. It is a possibility though.

Jan 11 '06 #4
shorti wrote:
One thought from a coworker was, since the defines for the db2 Version
are placed in the db2ApiDf. h and sql.h, scan the header file for the
last db2Version and use it with the assumption that the most current
level must be what is on the machine otherwise it would not exist in
the header. I look at this as being potentially dangerous as I cannot
control the accuracy of the file. It is a possibility though.


Now that will be rather troublesome!!! The db2Version that you specify for
the API calls identifies the data structures send to the function. If the
structure changes and you specify a newer db2Version, you will have the
older structure as prepared by your code being interpreted as the newer
one. Then you have "garbage in - garbage out".

I guess the basic question is here: what exactly do you need the version
information for. Do you have to deal with different DB2 versions? If yes,
can't you stick with the oldest one like db2Version80 or so? Or are there
any changes to the APIs in db2Version82 that you like to exploit?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 11 '06 #5
shorti wrote:
One thought from a coworker was, since the defines for the db2 Version
are placed in the db2ApiDf. h and sql.h, scan the header file for the
last db2Version and use it with the assumption that the most current
level must be what is on the machine otherwise it would not exist in
the header. I look at this as being potentially dangerous as I cannot
control the accuracy of the file. It is a possibility though.

Hmm.. why would one want to auto-fill-in these values?
The reason behind them is that it allows IBM to evolve the API without
breaking existing apps.
There is nothing wrong with being on connecting to DB2 V8.2 and using
the V8.1 API level.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 11 '06 #6
Version 8 has new API calls that require the db2Uint32 db2Version
number. I need the current db2Version number to pass into these calls.
One example I noted above was db2CfgGet ( db2Uint32 versionNumber,
void *pParmStruct, struct sqlca *pSqlca);

The format for this db2Version number is 8010000 for v8.1. db2level
will give me a release level of DB2 8.1.1.88 with fixpak 9. This
equates to db2Version number 8020200. I Only know this from the many
hours of research I have done to figure it out.

Jan above gave an example of a release newer than mine: "DB2
v8.1.11.958", Fixpak "11". So what db2Version is that?

Is this also part of db2Version number 8020200 or is this in some new
db2Version...pe rhaps 80204000? I would have to call DB2 every time
there was a new release to determine what to set my global to.

The reason I would want to update the global each time there was a db2
version change is to take advantage of the changes in the new release
or perhaps pick up a fix that I am using in my code. Also, I would
have to make sure I dont use functionality if the machine has a
downlevel version of db2 on it.

Here is an example: Prior to fixpack 7 you could not update the
database configuration parameter STMTHEAP while online to the database.
I added code to do this now. If I hard coded to version 8.1 instead
of 8.2 my call the db2CfgSet fails. With the correct version of db2 it
works. In the future I want to take advantage of new functionality
without having to change the hard coded value. Also, if a machine has
downlevel db2 code I want to have code in place to eliminate new
functionality so it wont fail. In this example, if I know this machine
is at version 8.1 I do not want to attempt to adjust the setting to
STMTHEAP so it wont fail and take a customer down.

Jan 11 '06 #7
shorti wrote:
The reason I would want to update the global each time there was a db2
version change is to take advantage of the changes in the new release
or perhaps pick up a fix that I am using in my code.
But the version passed to the API functions doesn't have anything to do with
DB2 fixes. It only defines which version of the data structures are being
passed to DB2 so that it can do the right thing. If you change the version
in your code, you have to verify that none of the data structures have
changed. If you keep everything as it is, you don't have to change the
version - regardless of the current version of the DB2 server you are
using.
Here is an example: Prior to fixpack 7 you could not update the
database configuration parameter STMTHEAP while online to the database.
I added code to do this now. If I hard coded to version 8.1 instead
of 8.2 my call the db2CfgSet fails.
No. The call fails if you're connected to an 8.1 DB2 server that doesn't
allow such an update. When you are connected to a 8.2 server using
db2Version81, the call will succeed. The db2Version for the APIs and the
actual version/release of the database server are two different things.
With the correct version of db2 it
works. In the future I want to take advantage of new functionality
without having to change the hard coded value. Also, if a machine has
downlevel db2 code I want to have code in place to eliminate new
functionality so it wont fail. In this example, if I know this machine
is at version 8.1 I do not want to attempt to adjust the setting to
STMTHEAP so it wont fail and take a customer down.


What about intercepting the error messages? After all, you do need error
handling anyways...

And why do you think it would "take a customer down"?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 12 '06 #8
>Here is an example: Prior to fixpack 7 you could not update the
database configuration parameter STMTHEAP while online to the database.
I added code to do this now. If I hard coded to version 8.1 instead
of 8.2 my call the db2CfgSet fails.
No. The call fails if you're connected to an 8.1 DB2 server that doesn't
allow such an update. When you are connected to a 8.2 server using
db2Version81 , the call will succeed. The db2Version for the APIs and the
actual version/release of the database server are two different things.
Then DB2 has a problem. I am running db2Version822. I call to bump
the STMTHEAP parameter if I received a certain SQLCODE. In my test
function I set the db2 version to db2Versoin810 because it was in the
example in the DB2 Info Center description of the function and I did
not change it to the true version because I am still trying to
determine how to easily get the current version (and is the reason for
this post).

The call failed and I could not update the setting. I opened a pmr
with DB2 thinking it was broken (I forgot I had the db2Version set
wrong in the call). After a couple of discussions with DB2 support we
found the problem. I changed the version to db2Version822, which is
the correct version that contained the change, and it works. If you
are telling me it should have worked no matter which version I passed
in then db2 has a bug. However, I dont see the purpose of requiring
the caller to pass in the db2Version if DB2 does not intend to use it.
What about intercepting the error messages? After all, you do need error
handling anyways...


I have plenty of error handling. If fact, this very function is all
about error handling. If I get an SQL error from any command this
function does various things to deal with it. Why provoke an error
when I can avoid it? If I know the call wont work because I am on the
wrong db2 version then why make the call? I am error handling so I
should be smart enough to know I cannot perform that action. If I do
not verify the version I am using then I am suddenly the cause of the
error.

'Taking the customer down'...There is much more to this then I have
time to really explain. Whenever you do something you are not suppose
to you could potentially hit a problem that brings down the
machine....this is the worse case of course. But, even in the simplest
case you can create problems unnecessarily. For instance, many of the
database and Database Manager configures will not take affect unless
you start and stop the database instance. To do this all processes are
forced off the database. This sounds simple but how do those processes
recover? Do they spin and wait for you to allow them to reconnect? Do
they error on that database operation and keep trying the next
operation in thier queue? When will the database become available?
At any rate, if the processes cannot connect to the database to do work
your customer is down. Let me say, changing the STMTHEAP would not be
an example where I would do a force stop but some of the settings, like
out of memory, would be. If I know there is a way to cure the problem
without doing this then I want to attempt it.

The point of this post is not how I can avoid giving the API calls the
true version but how can I get the correct version so I can determine
the best course of recovery. I realize there may not be many using the
new API calls because they are running existing code with the old APIs
that have already been established. This is new developement and we
are trying to utilize the new API calls...though some days I have to
resist the urge to just go back to the old!

Last, I am not a DB2 expert. In fact, DB2 is very new to me so if I am
missing some point I appreciate the patience and explanation. I am not
really sure what the purpose is for the addition of the version in
these calls other then in case someone wants to use older functionality
even if they are running new code. I would think anything new would be
an improvement to the old but what do I know!?

Jan 12 '06 #9
shorti wrote:
No. The call fails if you're connected to an 8.1 DB2 server that doesn't
allow such an update. When you are connected to a 8.2 server using
db2Version8 1, the call will succeed. The db2Version for the APIs and the
actual version/release of the database server are two different things.
Then DB2 has a problem. I am running db2Version822. I call to bump
the STMTHEAP parameter if I received a certain SQLCODE. In my test
function I set the db2 version to db2Versoin810 because it was in the
example in the DB2 Info Center description of the function and I did
not change it to the true version because I am still trying to
determine how to easily get the current version (and is the reason for
this post).


As I said, this won't be necessary.
The call failed and I could not update the setting. I opened a pmr
with DB2 thinking it was broken (I forgot I had the db2Version set
wrong in the call). After a couple of discussions with DB2 support we
found the problem. I changed the version to db2Version822, which is
the correct version that contained the change, and it works. If you
are telling me it should have worked no matter which version I passed
in then db2 has a bug. However, I dont see the purpose of requiring
the caller to pass in the db2Version if DB2 does not intend to use it.
You _did_ not set a wrong version by using "db2Version810" . And as was
explained before, the version information tells DB2 which data structure
you are providing so that it knows how to take it apart and get the proper
values. That way the structure can change without impacting your
application - which is apparently exactly what you need. There is no point
in interpreting the version number in any other way.

If I got your above description right, then you're doing pretty much this:
---------------------------- snip ----------------------------------
#include <stdio.h>
#include <db2ApiDf.h>

int main()
{
struct db2Cfg cfg;
struct db2CfgParam param;
struct sqlca sqlca;
sqlint32 stmtHeapSize = 2048;

memset(&cfg, 0x00, sizeof cfg);
memset(&param, 0x00, sizeof param);
memset(&sqlca, 0x00, sizeof sqlca);

cfg.numItems = 1;
param.token = SQLF_DBTN_STMT_ HEAP;
param.ptrvalue = &stmtHeapSiz e;
param.flags = 0;
cfg.paramArray = &param;
cfg.flags = db2CfgDatabase | db2CfgImmediate ;
cfg.dbname = "TEST";

int rc = db2CfgSet(
db2Version810,
&cfg,
&sqlca);
printf("rc = %d\n", rc);
printf("sqlcode = %d\n", sqlca.sqlcode);
}
---------------------------- snip ----------------------------------

This works quite well for me against a DB2 V8.2.3 server (DB2 v8.1.2.96).
So I would still say that there is some particular problem in your
environment (maybe your code?) but DB2 does work as was stated here before,
i.e. you can (and should) match the version number with the data structures
you are providing.
I have plenty of error handling. If fact, this very function is all
about error handling. If I get an SQL error from any command this
function does various things to deal with it. Why provoke an error
when I can avoid it? If I know the call wont work because I am on the
wrong db2 version then why make the call?
Because it will be the exception that the call won't work. Otherwise you
would need a matrix that says which version of DB2 did not support a
particular configuration parameter.
For instance, many of the
database and Database Manager configures will not take affect unless
you start and stop the database instance. To do this all processes are
forced off the database. This sounds simple but how do those processes
recover?
A few comments:
(1) You only need to restart the instance if the configuration parameter
could be set successfully, and
(2) many parameters can be set on the fly and take effect on the fly.
(3) Database configuration parameters do _not_ require an instance restart.
You might have to deactivate/activate the database unless you're changing
an online parameter.
(4) An application should be able to deal with outages anyway.
Last, I am not a DB2 expert. In fact, DB2 is very new to me so if I am
missing some point I appreciate the patience and explanation. I am not
really sure what the purpose is for the addition of the version in
these calls other then in case someone wants to use older functionality
even if they are running new code. I would think anything new would be
an improvement to the old but what do I know!?


Let me try again. Let's say DB2 V8.1 has an API "db2SomethingIm portant",
which takes a data structure like this as input:

struct params {
int value1;
int value2;
};

Now some new logic is added in DB2 V9.1, which has an impact on
"SomethingImpor tant". In particular, another parameter can be specified in
the parameter structure:

struct newParams {
int value1;
int value2;
int newValue;
};

How would DB2 V9 be able to distinguish whether a pointer to the new
structure is given or a pointer to the old one? Three options:
(1) Don't support the additional parameter in the API - not a really good
idea as DB2 would be stuck again with the problems of (current) the old
API.
(2) Use a new function with a different name. Not so great either because
it clutters the API in the long run, given that the old variations need to
be kept araund for backwards compatibility.
(3) Use a number that describes which version of the structure was provided
by the application. If the number is V8, then the new attribute is not
there and will not be accessed. If it is V9, then it is there and DB2 can
use it.

Option (3) was chosen by the DB2 development. Now, you see that setting the
newest version is a particular bad idea if the structure provided doesn't
match it as DB2 would attempt to access the "newValue" attribute which is
not there if your code does not set it up. Basically, you would hit either
a segmentation violation or DB2 would read another memory area, resulting
in bogus values. The second will probably cause even more harm as it is
not as easily noticable.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 16 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2757
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example, a module change its interface or its implementation in a fundamental way (an example: wxPython). This, I think, can be resolved by allowing an user to explicitly say what version of a module it wants (sush as version numbers in Linux shared...
72
5446
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools (dreamweaver and the like), they are all at the lowest level of programming (something like assembly as oposed to C++ etc.). These tools create "brain-dead" developers that constantly have to plough through tons of tags to do the simplest thing. ...
8
4550
by: R. Smits | last post by:
I've have got this script, the only thing I want to be changed is the first part. It has to detect IE version 6 instead of just "Microsoft Internet Explorer". Can somebody help me out? I tried "Microsoft Internet Explorer 6" but that doesn't work. <SCRIPT LANGUAGE="Javascript"> <!-- bName = navigator.appName; if (bName =="Microsoft Internet Explorer") { document.write('<link media="screen" rel="STYLESHEET" type="text/css"
2
5840
by: david | last post by:
I'm developing a Visual C++ database application which will be delivered to customers. Some customers install Access 97 on their computers, others install Acess 2000 or higher versions. In my application, I need to create a MDB file, according to the Access version installed on the customers' computers so that they can use Access to open the created MDB file without errors such as "Unrecognized file format". More specificly, my...
12
2984
by: Bill Hanna | last post by:
C is inadequate for embedded systems for the following reasons: 1) Direct addressing of memory mapped I/O is not supported simply and easily. You have to find work-arounds that are compiler dependent. You have to create macros , use casting and use indirect addressing (pointers) to read or write to memory mapped I/O. 2) C does not support real time interrupts. The interrupt vectoring is compiler dependent.
8
3986
by: Salad | last post by:
I designed a small app and I wanted to do a BrowseFolder (see http://www.mvps.org/access/api/api0002.htm), basically do a file open diaglog and select a directory/folder. The problem is that you can't specify the starting folder. Stephan Leban provided a neat solution that does allow me to browse using a starting folder. I am using A97 and it works fine. However, I put it onto a system that uses AccessXP. And it chokes on...
3
3463
by: melnhed | last post by:
---Report the current filtered records from a Form--- Hello All, I've seen this topic discussed before, but the solution described then doesn't work in my particular case. My Config: Access 2002 front-end using SQL Server 2000 (MSDE actually) via ADP/ADE Access Data Project.
5
1688
by: jroozee | last post by:
I am developing in VS '03. I have all of the current framework versions installed on my PC, 1.1, 2.0, and 3.0. How can I make sure the code I am developing in is using the 3.0 framework version? Or do I need to be using the latest version of Visual Studio to do so? Thanks,
5
8451
by: muriwai | last post by:
Hi, I have a C# assembly project under Visual Stuio 2008 Pro on Windows Server 2008. I converted the project from VS 2005. The project references COM->Microsoft CDO for Windows 2000 Library 1.0, which adds two entries under References called CDO and ADODB. When I compile the solution, I get the following: Error 1 Assembly 'Interop.CDO, Version=1.0.0.0, Culture=neutral,
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.