Showing posts with label db2. Show all posts
Showing posts with label db2. Show all posts

Thursday, November 29, 2012

Changing DB2 codepage

While executing sql command in IBM db2 control center editor, I was getting error

SQL0332N Character conversion from the source code page "" to the target code page "" is not supported. SQLSTATE=57017

Searching for this, I found that I need t change the code page of the client to be the same as the table I am selecting from

To do this:

Open a command prompt

Go to C:\Program Files\IBM\SQLLIB\BIN\ or just make sure it exists in the windows %PATH%

Type db2set db2codepage=1208 then press enter

In my case the target codepage was 1208, it needs to be checked first before setting it

Wednesday, July 25, 2012

Comparing DB2 objects

I had a task to compare 2 db2 schemas, one that we have, and the other one from the client DB

This process can be done manually, by generating script for both databases and comparing the generated script file with any text comparison tools, notepad++ can do this, of course this is not efficient and repeating costs time and effort

It can also be done by tools, I had some db2 tool from IBM, IBM Data Studio, I started looking into it, found it very interesting

You can select any object from the database source explorer, and do right click then select Compare with –> Each other

I was able to do that while selecting 2 tables, or 2 schemas, or 2 databases, seems that you can compare between any objects in the database

2012-07-25_13-55-00

The results also looks very nice, organized, detailed

2012-07-25_14-04-07

This was perfect, except that you can only export the results as XML, no other options, hope this comes in next releases.

You can download the tool from IBM web site http://www.ibm.com/developerworks/downloads/im/data/

Then you will be able to compare db2 schemas, compare tables, compare 2 db2 databases, etc.. very easily

Wednesday, April 18, 2012

Creating Trigger in DB2 Control Center

to create trigger in DB2 Control Center,

Open Control Center

Open the Database to display the database objects

Right click on triggers and select create

Screenshot-2012-04-18_15.50.44

Select the schema, table name

Select the time and operation

Screenshot-2012-04-18_15.50.20

Select triggered action tab

Enter the name for old row, name for new row

Enter the When conditions, and the required script to be executed after Begin Atomic

Screenshot-2012-04-18_15.51.05

Click Ok

Monday, March 19, 2012

Installing Toad for DB2 64 bit while DB2 32 bit client exists

I had to install both 32 bit and 64 bit from DB2 runtime client, I needed to install Toad while I have these clients
Trying to install the Toad 32 bit or the 64 bit, both was giving an error that I can’t install Toad while there is different OS DB2 client existing, so I was stuck.
image
The Toad for DB2 installer has detected an existing 64-bit DB2 envirnoment on your computer. This installation for DB2 includes a 32-bit DB2 client. However, DB2 does not allow both 32-bit and 64-bit DB2 environments to exist on the same computer.
I thought of trying something, it is naïve but it worked Smile, I opened registry, looked for the keys
HKEY_LOCAL_MACHINE\SOFTWARE\IBM
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\IBM
Just renamed the IBM in each key to something else, just removed the last M, to be IB
After that I started the 64 bit Toad setup, and it passed the check for any installed IBM software, after the check was passed, I returned the keys back as it was, just in case the Toad setup is going to write anything to the same Key.
Of course there is another more safe option, to uninstall the DB2 clients, and install Toad, then installing back the clients.

IBM DB2: using db2 providers for .NET

I was creating a tool to automate test data creation on db2 database, at the beginning I faced lot’ s of issues to be able to use the IBM DB2 .NET drivers. I have 64 bit OS, when I installed 32 bit client, can be downloaded from here, using the IBM.Data.DB2 was giving initialization errors, even if the target for my tool is x86, it was giving problems

errors I was getting:

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

I then removed the 32  bit version and installed the 64 bit version, can be downloaded from here , this also was giving errors since the target is x86, I guess it was looking for the 32 bit DB2 dlls.

error I was getting

Could not load file or assembly 'IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Finally, I kept both the the 32 bit and the 64 bit, this worked perfectly, and set the target to x86, when I deployed my application to my colleagues having them installed 32 bit IBM Data Server Driver Package on their 32 bit operating systems, it worked perfectly.