Get IP Address of connected DB2 client

When DB2 agent (db2bp process) makes a connection for your CONNECT request, it stores the IP address of the client in the application ID as shown below: $ db2 list applications Auth Id Application Appl. Application Id DB # of Name Handle Name Agents...

How to know what is installed in DB2?

How do I know what is installed in DB2? Is there a way, I can determine about hidden components installed in DB2? How do I know which language packs are installed in DB2? Sometime, you might want to know answers about above questions. Normally, you will run db2level...

SQL PL function to convert int to hex

If you are converting from Sybase, you might run into issues for converting INT to HEX. In Sybase: 1> select inttohex(234) 2> go ——– 000000EA (1 row affected) In DB2: DB2 => values hex(234) 1 ——– EA000000 If you want the same exact...

DB2 SQL -1035 Error (SQL1035N) database is currently in use

Did you get this DB2 SQL1035N error if you were trying to take offline backup? The error is obvious as someone is connected to the database and you cannot take offline database backup. There are several solution that you can take to do offline backup when you get SQL...

Cursor Blocking in DB2

Did you ever wonder what is cursor blocking or row blocking in DB2? Cursor or Row blocking in DB2 is a way to fetch number of rows in a single operation. This can improve performance of the applications. There are 3 types of blocking which can be used for your...

Use DB2DCLGN in DB2

DB2 provides a tool db2dclgn that you can use effectively as an aid in your C/C++ or Java coding efforts. The example shown here is for embedded SQL in C. Create a table for demo CREATE TABLE “EXE”.”CUTION” ( “UT_UD” BIGINT NOT NULL...

Powerful Merge Capabilities on DB2

Did you ever know how powerful MERGE is in DB2? Let me demonstrate that to you through this simple example. Create a table $ db2 connect to sample $ db2 “create table fmtmerge (c1 int not null generated always as identity primary key, c2 decimal(13,4) not null,...

High performance INSERT in DB2 using column wise Arrays

The following program is an example of CLI and embedded SQL statements in the same C program to perform array inserts to achieve high performance. Why do you need to use a mixture of CLI and embedded SQL program? Sometimes, it is desirable from the coding perspective...

How to increment a column using DB2 MERGE?

Say for an example, you want to increment a column whenever a user logs in using an application for audit purpose. Normally in a single unit of work, DB2 will guarantee the data and there will not be an issue of concurrency if you use an INSERT and do an UPDATE upon...

How to use PREPARE in DB2?

If you are writing embedded SQL application using C/C++ or SQLJ application using Java, you will come across an issue about how to use DB2 PREPARE statement effectively in your application code. When I talk to Oracle or SQL Server DBA, they all seem to have an...

Preprocessing C/C++ for embedded SQL Statements

When you use embedded SQL in your C/C++ code, you first run PREP command to process all EXEC SQL statements in your source. The PREP step happens before C/C++ compiler is able to invoke its preprocessor that will include header files, expand trigraph and replace...

Solve Tomcat 5.5 install problem

I am trying to install Tomcat to test DB2 web services and I ran into several problems on my Fedora Core 5 server to start the Tomcat server. This is how I solved this. I found this problem widely reported but very few instructions to solve the problem. Install...

Convert Timestamp with Time Zone

If you are migrating other database data to db2 and encounter a timestamp like 2007-03-07 19:30:00+05, you will need to adjust the timestamp correctly if you are in a different time zone. I used this Java function to massage the timestamp properly so that I get the...

Determine fenced User-ID of a DB2 instance

When you create a DB2 instance in Unix, you have the option of specifying a fenced user-id different than instance owner. The purpose of fenced user id is to protect DB2 from untested or malicious code from the external stored procedures, user defined functions etc....

DB2 Load operation from client or Remote Load

Normally, you would run the DB2 LOAD on the DB2 server. But, when you try to run DB2 LOAD from a client, you need to take care of few things. A sample DB2 LOAD script that runs well on Server. SET CURRENT SCHEMA=”ADMIN”; LOAD FROM...

RPM for IBM_DB2 Extension for PHP

If you are planning to use PHP with DB2 Express-C on Linux, you will need PHP extension for the DB2. The same extension will also work for IBM Cloudscape or Apache Derby databases. [Note: The instructions here are for the Redhat Linux and you will need slight...