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...

Where is DB2 9 installed on Linux?

Few things have changed in DB2 9. For example, IBM does not use RPM to install the software any more on Linux platforms. This change might upset many who rely upon rpm-qa to query about DB2 software. If some one has installed DB2 9 for you on Linux, how would know the...

RegEx DB2 Java UDF with CLOB

1. How to implement Java UDF using CLOB for DB2GENERAL parameter passing? When you use DB2GENERAL parameter passing in the declaration of the SQL UDF, DB2 will use the legacy driver to map the data types between Java and DB2. If you need to pass CLOB as a parameter in...

PHP, Eclipse and DB2 on Windows Platform

This is How I did: Eclipse, PHP and DB2 on Windows Platform After working in Microsoft .Net technologies for few years, I made up my mind to explore PHP world. In fact, this site is hosted using Drupal framework which is in PHP and I did not know anything about PHP to...

Update statistics

Did you know that you can run DB2 REORGCHK command to update the statistics on the tables? Normally, you would run RUNSTATS command against each table to update the statistics. Consider using REORGCHK as shown below: To update all the user and system tables use:...

Victor Chang’s Whitepaper on Row Compression

Victor Chang and others have published a white paper on row compression on DB2 9. At a high level, authors have achieved significantly better performance running DSS queries in a compressed database using only half as many disks as the uncompressed database. They have...

DB2 Table space containers on SAN

David Sciaraffa explains that DB2 9 uses autonomic algorithm to determine the number of prefetchers (IO_SERVERS) and page-cleaners (IO_CLEANERS) to determine the optimum values and they are described here: Prefetchers: IO_SERVERS Page Cleaners: IO_CLEANERS...