P. 1
Getting Started With DB2 Express v9.7 p4

Getting Started With DB2 Express v9.7 p4

|Views: 8|Likes:
Published by ndbelman

More info:

Published by: ndbelman on Apr 20, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/05/2014

pdf

text

original

Call Level Interface (CLI) was originally developed by the X/Open Company and the SQL
Access Group. It was a specification for a callable SQL interface with the purpose of
developing portable C/C++ applications regardless of the RDBMS vendor. Based on a
preliminary draft of X/Open Call Level Interface, Microsoft developed Open Database
Connectivity (ODBC), and later on, the ISO CLI International Standard accepted most of
the X/Open Call Level Interface specification. DB2 CLI is based on both: ODBC and the
International Standard for SQL/CLI as shown in Figure 14.3.

Chapter 14 - Introduction to DB2 Application Development 247

Figure 14.3 - DB2 CLI is based on ODBC and ISO CLI International standard

DB2 CLI conforms to ODBC 3.51 and can be used as the ODBC Driver when loaded by an
ODBC Driver Manager. Figure 14.4 can help you picture DB2 CLI support for ODBC.

Figure 14.4 - DB2 CLI conforms to ODBC 3.51

CLI/ODBC has the following characteristics:

The code is easily portable between several RDBMS vendors
Unlike embedded SQL, there is no need for a precompiler or host variables
It runs dynamic SQL
It is very popular

To run a CLI/ODBC application all you need is the DB2 CLI driver. This driver is installed
from either of the following clients and drivers which can be downloaded and used for free
from www.ibm.com/db2/express:

IBM Data Server Client

248 Getting Started with DB2 Express-C

IBM Data Server Runtime Client
IBM Data Server Driver for ODBC and CLI

To develop a CLI/ODBC application you need the DB2 CLI driver and also the appropriate
libraries. These can be found only on the IBM Data Server Client.

Let's take a look at the following example so you understand better how you can set up the
DB2 CLI driver for your applications. Figure 14.5 depicts three different machines, one in
Indonesia, the other one in Brazil, and the other one in Canada.

Figure 14.5 - DB2 CLI/ODBC sample scenario

The figure shows two cases:

On the left let’s say the machine in Indonesia is running an ODBC application which could
work with any RDBMS such as Oracle, Microsoft SQL Server or DB2. An ODBC Driver
Manager will load the appropriate ODBC driver depending on the database that is being
accessed. In the case where the application accesses a DB2 database in Canada, the
connection needs to go through a DB2 Client which has the components to connect
remotely.

On the right side, let’s say a CLI application is running in a machine in Brazil. It’s a CLI
application because it may be using some specific functions not available in ODBC, and
also because the application will only work for a DB2 database. The CLI application will go
through the DB2 CLI Driver. The application can connect to the local DB2 database in
Brazil. When it needs to connect to the remote database in Canada, it will go through a
DB2 client.

Chapter 14 - Introduction to DB2 Application Development 249

One last point to be made in this section is a comparison between a CLI/ODBC application
and an embedded SQL C dynamic application. Figure 14.6 illustrates this comparison.

Figure 14.6 - CLI/ODBC application versus Embedded SQL C dynamic application

As shown in Figure 14.6, the only difference between CLI/ODBC vs. Embedded SQL C
dynamic SQL is that for CLI/ODBC your code is portable and can access other RDBMS
simply by changing the connection string, while in the embedded SQL C dynamic version,
you may be coding specific elements for DB2. Of course the other difference is the way the
different functions for PREPARE, and EXECUTE are invoked.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->