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 , "UT_ALLOC_ACCT_UD" BIGINT ,...

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

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