Notes:
The sample programs come with the DB2 SDK. You can use the sample programs as templates to create your own applications. The file extensions for each supported language, as well as for programs categorized by group, are given in the following tables:
The following tables document the sample programs by type:
Notes:
Table 2. Sample File Extensions by Language
Language | Directory | Embedded SQL Programs | Non-embedded SQL Programs |
---|---|---|---|
C |
samples/c samples/cli (CLI programs) | .sqc | .c |
C++ | samples/cpp |
.sqC (UNIX) .sqx (Windows & OS/2) |
.C (UNIX) .cxx (Windows & OS/2) |
COBOL |
samples/cobol samples/cobol_mf | .sqb | .cbl |
Fortran | samples/fortran | .sqf |
.f (UNIX) .for (OS/2) |
JAVA | samples/java | .sqlj | .java |
REXX | samples/rexx | .cmd | .cmd |
Table 3. Sample File Extensions by Program Group
Sample Group | Directory | File Extension |
---|---|---|
CLP | samples/clp | .db2 |
OLE |
samples\ole\msvb (Visual Basic) samples\ole\msvc (Visual C++) |
.bas .vbp (Visual Basic) .cpp (Visual C++) |
OLE DB | samples\oledb | .db2 |
ADO, RDO, MTS |
samples\ADO\VB (Visual Basic) samples\ADO\VC (Visual C++) samples\RDO samples\MTS |
.bas .frm .vbp (Visual Basic) .cpp .dsp .dsw (Visual C++) |
User Exit | samples/c |
.cad (OS/2) .cadsm (UNIX & Windows) .cdisk (UNIX & Windows) .ctape (UNIX) |
Note: |
|
You can find the sample programs in the samples subdirectory of the directory where DB2 has been installed. There is a subdirectory for each supported language. The following examples show you how to locate the samples written in C or C++ on each supported platform.
You can find the C source code for embedded SQL and DB2 API programs in sqllib/samples/c under your database instance directory; the C source code for DB2 CLI programs is in sqllib/samples/cli. For additional information about the programs in the samples tables, refer to the README file in the appropriate samples subdirectory under your DB2 instance. The README file will contain any additional samples that are not listed in this book.
You can find the C source code for embedded SQL and DB2 API programs in %DB2PATH%\samples\c under the DB2 install directory; the C source code for DB2 CLI programs is in %DB2PATH%\samples\cli. The variable %DB2PATH% determines where DB2 is installed. Depending on the drive where DB2 is installed, %DB2PATH% will point to drive:\sqllib. For additional information about the sample programs in the samples tables, refer to the README file in the appropriate %DB2PATH%\samples subdirectory. The README file will contain any additional samples that are not listed in this book.
The sample programs directory is typically read-only on most platforms. Before you alter or build the sample programs, copy them to your working directory.
Note: | The sample programs that are shipped with DB2 Universal Database have
dependencies on the English version of the sample database and the
associated table and column names. If the sample database
has been translated into another national language on your version of DB2
Universal Database, you need to update the name of the sample
database, and the names of the tables and the columns coded in the supplied
sample programs, to the names used in the translated sample
database. Otherwise, you will experience problems running the sample
programs as shipped.
Currently, the sample database is translated into the following languages:
|
Table 4. DB2 API Sample Programs with No Embedded SQL
Sample Program | Included APIs |
---|---|
backrest
C: backrest.c |
|
checkerr
COBOL: checkerr.cbl |
|
cli_info
C: cli_info.c |
|
client
C: client.c
C++: client.C
COBOL: client.cbl |
|
d_dbconf
C: d_dbconf.c
COBOL: d_dbconf.cbl |
|
d_dbmcon
C: d_dbmcon.c
COBOL: d_dbmcon.cbl |
|
db_udcs
C: db_udcs.c
COBOL: db_udcs.cbl |
|
db2mon
C: db2mon.c |
|
dbcat
C: dbcat.c
COBOL: dbcat.cbl |
|
dbcmt
C: dbcmt.c
COBOL: dbcmt.cbl |
|
dbconf
C: dbconf.c
COBOL: dbconf.cbl |
|
dbinst
C: dbinst.c
COBOL: dbinst.cbl |
|
dbmconf
C: dbmconf.c
COBOL: dbmconf.cbl |
|
dbsnap
C: dbsnap.c
COBOL: dbsnap.cbl |
|
dbstart
C: dbstart.c
COBOL: dbstart.cbl |
|
dbstop
C: dbstop.c
COBOL: dbstop.cbl |
|
dcscat
C: dcscat.c
COBOL: dcscat.cbl |
|
dmscont
C: dmscont.c |
|
ebcdicdb
C: ebcdicdb.c
COBOL: ebcdicdb.cbl |
|
migrate
C: migrate.c
COBOL: migrate.cbl |
|
monreset
C: monreset.c
COBOL: monreset.cbl |
|
monsz
C: monsz.c
COBOL: monsz.cbl |
|
nodecat
C: nodecat.c
COBOL: nodecat.cbl |
|
regder
C: regder.c
COBOL: regder.cbl |
|
restart
C: restart.c
COBOL: restart.cbl |
|
setact
C: setact.c
COBOL: setact.cbl |
|
setrundg
C: setrundg.c |
|
sws
C: sws.c
COBOL: sws.cbl |
|
util
C: util.c
C++: util.C |
|
Table 5. DB2 API Embedded SQL Sample Programs
Sample Program | Included APIs |
---|---|
asynrlog
C: asynrlog.sqc |
|
bindfile
C: bindfile.sqc |
|
dbauth
C: dbauth.sqc
COBOL: dbauth.sqb |
|
dbstat
C: dbstat.sqc
COBOL: dbstat.sqb |
|
expsamp
C: expsamp.sqc
COBOL: expsamp.sqb |
|
impexp
C: impexp.sqc
COBOL: impexp.sqb |
|
loadqry
C: loadqry.sqc |
|
makeapi
C: makeapi.sqc |
|
qload
C: qload.sqc
COBOL: qload.sqb |
|
rebind
C: rebind.sqc
COBOL: rebind.sqb |
|
rechist
C: rechist.sqc |
|
tabscont
C: tabscont.sqc
COBOL: tabscont.sqb |
|
tabspace
C: tabspace.sqc
COBOL: tabspace.sqb |
|
tload
C: tload.sqc
COBOL: tload.sqb |
|
tspace
C: tspace.sqc
COBOL: tspace.sqb |
|
Table 6. Embedded SQL Sample programs with No DB2 APIs
Sample Program Name | Program Description |
---|---|
adhoc | Demonstrates dynamic SQL and the SQLDA structure to process SQL commands
interactively. SQL commands are input by the user, and output
corresponding to the SQL command is returned.
C: adhoc.sqc |
advsql | Demonstrates the use of advanced SQL expressions like CASE, CAST, and
scalar full selects.
C: advsql.sqc ; COBOL: advsql.sqb |
blobfile | Demonstrates the manipulation of a Binary Large Object (BLOB), by reading
a BLOB value from the sample database and placing it in a file. The
contents of this file can be displayed using an external viewer.
C: blobfile.sqc |
calludf | Demonstrates calling user-defined functions (UDFs) created by the
udf program, and stored on the server to accesss tables in the
sample database.
C: calludf.sqc ; C++: calludf.sqC |
columns | Demonstrates the use of a cursor that is processed using dynamic
SQL. This program lists all the entries in the system table,
SYSIBM.SYSTABLES, under a desired schema name.
C: columns.sqc |
cursor | Demonstrates the use of a cursor using static SQL.
C: cursor.sqc ; C++: cursor.sqC ; COBOL: cursor.sqb |
delet | Demonstrates static SQL to delete items from a database. |
dynamic | Demonstrates the use of a cursor using dynamic SQL.
C: dynamic.sqc ; COBOL: dynamic.sqb |
fillcli | Demonstrates the client-side of a stored procedure that uses the SQLDA to
pass information specifying which table the stored procedure populates with
random data.
C: fillcli.sqc ; C++: fillcli.sqC |
fillsrv | Demonstrates the server-side of a stored procedure example that uses the
SQLDA to receive information from the client specifying the table that the
stored procedure populates with random data.
C: fillsrv.sqc ; C++: fillsrv.sqC |
inpcli | Demonstrates stored procedures using either the SQLDA structure or host
variables. This is the client program of a client/server
example. (The server program is called inpsrv.) The
program fills the SQLDA with information, and passes it to the server program
for further processing. The SQLCA status is returned to the client
program. This program shows the invocation of stored procedures using
an embedded SQL CALL statement.
C: inpcli.sqc ; C++: inpcli.sqC ; COBOL: inpcli.sqb |
inpsrv | Demonstrates stored procedures using the SQLDA structure. This is
the server program of a client/server example. (The client program is
called inpcli.) The program creates a table
(PRESIDENTS) in the sample database with the information
received in the SQLDA. The server program does all the database
processing and returns the SQLCA status to the client program.
C: inpsrv.sqc ; C++: inpsrv.sqC ; COBOL: inpsrv.sqb |
joinsql | Demonstrates using advanced SQL join expressions.
C: joinsql.sqc ; COBOL: joinsql.sqb |
largevol | Demonstrates parallel query processing in a partitioned environment, and
the use of an NFS file system to automate the merging of the result
sets. Only available on AIX.
C: largevol.sqc |
lobeval | Demonstrates the use of LOB locators and defers the evaluation of the
actual LOB data.
C: lobeval.sqc ; COBOL: lobeval.sqb |
lobfile | Demonstrates the use of LOB file handles.
C: lobfile.sqc ; COBOL: lobfile.sqb |
lobloc | Demonstrates the use of LOB locators.
C: lobloc.sqc ; COBOL: lobloc.sqb |
lobval | Demonstrates the use of LOBs.
C: lobval.sqc |
openftch | Demonstrates fetching, updating, and deleting of rows using static
SQL.
C: openftch.sqc ; COBOL: openftch.sqb |
outcli | Demonstrates stored procedures using a host variable. This is the
client program of a client/server example. (The server program is
called outsrv.) This program declares a single OUT variable to hold the
value returned from the server program. This program demonstrates the
use of the CREATE PROCEDURE statement to register a stored procedure and shows
the invocation of stored procedures using an embedded SQL CALL
statement.
C: outcli.sqc ; C++: outcli.sqC ; COBOL: outcli.sqb |
outsrv | Demonstrates stored procedures using host variables. This is the
server program of a client/server example. (The client program is
called outcli.) The program sets the value of the function parameter to
the median SALARY of the employees in the STAFF table of the sample
database. The server does all the database processing (finding the
median). The server program returns the host variable and the SQLCA
status to the client program.
C: outsrv.sqc ; C++: outsrv.sqC ; COBOL: outsrv.sqb |
recursql | Demonstrates the use of advanced SQL recursive queries.
C: recursql.sqc |
sampudf | Demonstrates User-Defined Types (UDTs) and User-Defined Functions (UDFs)
implemented to modify table entries. All UDFs declared in this program
are sourced UDFs.
C: sampudf.sqc |
static | Demonstrates static SQL to retrieve information.
C: static.sqc ; C++: static.sqC ; COBOL: static.sqb |
tabsql | Demonstrates the use of advanced SQL table expressions.
C: tabsql.sqc ; COBOL: tabsql.sqb |
tblcli | Demonstrates a call to a table function (client-side) to display weather
information for a number of cities.
C: tblcli.sqc |
thdsrver | Demonstrates the use of POSIX threads APIs for thread creation and
management. The program maintains a pool of contexts. A
generate_work function is executed from main, and creates dynamic SQL
statements that are executed by worker threads. When a context becomes
available, a thread is created and dispatched to do the specified work.
The work generated consists of statements to delete entries from either the
STAFF or EMPLOYEE tables of the sample database. This
program is only available on UNIX platforms.
C: thdsrver.sqc ; C++: thdsrver.sqC |
trigsql | Demonstrates using advanced SQL triggers and constraints.
C: trigsql.sqc ; COBOL: trigsql.sqb |
updat | Demonstrates static SQL to update a database. |
varinp | Demonstrates variable input to Embedded Dynamic SQL statement calls using
parameter markers.
C: varinp.sqc ; COBOL: varinp.sqb |
Table 7. User-Defined Function Sample programs
Sample Program Name | Program Description |
---|---|
DB2Udf.java
| A Java UDF that demonstrates several tasks, including integer division, manipulation of Character Large Objects (CLOBs), and the use of Java instance variables. |
tblsrv.c
| Demonstrates a table function (server-side) that processes weather information for a number of cities. |
udf.c
| Creates a library of User-Defined Functions (UDFs) made specifically for the sample database tables, but can be used with tables of compatible column types. |
UDFsrv.java
| Demonstrates the use of Java User-Defined Functions (UDFs). |
Table 8. Sample CLI Programs in DB2 Universal Database
Sample Program Name | Program Description | ||
---|---|---|---|
Utility files used by most CLI samples | |||
samputil.c
| Utility functions used by most samples | ||
samputil.h
| Header file for samputil.c, included by most samples | ||
General CLI Samples | |||
adhoc.c
| Interactive SQL with formatted output (was typical.c) | ||
async.c
| Run a function asynchronously (based on fetch.c) | ||
basiccon.c
| Basic connection | ||
browser.c
| List columns, foreign keys, index columns or stats for a table | ||
calludf.c
| Register and call a UDF | ||
colpriv.c
| List column Privileges | ||
columns.c
| List all columns for table search string | ||
compnd.c
| Compound SQL example | ||
datasour.c
| List all available data sources | ||
descrptr.c
| Example of descriptor usage | ||
drivrcon.c
| Rewrite of basiccon.c using SQLDriverConnect | ||
duowcon.c
| Multiple DUOW Connect type 2, syncpoint 1 (one phase commit) | ||
embedded.c
| Show equivalent DB2 CLI calls, for embedded SQL (in comments) | ||
fetch.c
| Simple example of a fetch sequence | ||
getattrs.c
| List some common environment, connection and statement options/attributes | ||
getcurs.c
| Show use of SQLGetCursor, and positioned update | ||
getdata.c
| Rewrite of fetch.c using SQLGetData instead of SQLBindCol | ||
getfuncs.c
| List all supported functions | ||
getfuncs.h
| Header file for getfuncs.c | ||
getinfo.c
| Use SQLGetInfo to get driver version and other information | ||
getsqlca.c
| Rewrite of adhoc.c to use prepare/execute and show cost estimate | ||
lookres.c
| Extract string from the resume clob field using locators | ||
mixed.sqc
| CLI sample with functions written using embedded SQL (Note: This file must be precompiled ) | ||
multicon.c
| Multiple connections | ||
native.c
| Simple example of calling SQLNativeSql, and SQLNumParams | ||
prepare.c
| Rewrite of fetch.c, using prepare/execute instead of execdirect | ||
proccols.c
| List procedure parameters using SQLProcedureColumns | ||
procs.c
| List procedures using SQLProcedures | ||
sfetch.c
| Scrollable cursor example (based on xfetch.c) | ||
setcolat.c
| Set column attributes (using SQLSetColAttributes) | ||
setcurs.c
| Rewrite of getcurs.c using SQLSetCurs for positioned update | ||
seteattr.c
| Set environment attribute (SQL_ATTR_OUTPUT_NTS) | ||
tables.c
| List all tables | ||
typeinfo.c
| Display type information for all types for current data source | ||
xfetch.c | Extended Fetch, multiple rows per fetch | ||
BLOB Samples | |||
picin.c
| Loads graphic BLOBS into the emp_photo table directly from a file using SQLBindParamToFile | ||
picin2.c
| Loads graphic BLOBS into the emp_photo table using SQLPutData | ||
showpic.c
| Extracts BLOB picture to file (using SQLBindColToFile), then displays the graphic. | ||
showpic2.c
| Extracts BLOB picture to file using piecewise output, then displays the graphic. | ||
Stored Procedure Samples | |||
clicall.c
| Defines a CLI function which is used in the embedded SQL sample mrspcli3.sqc | ||
inpcli.c
| Call embedded input stored procedure samples/c/inpsrv | ||
inpcli2.c
| Call CLI input stored procedure inpsrv2 | ||
inpsrv2.c
| CLI input stored procedure (rewrite of embedded sample inpsrv.sqc) | ||
mrspcli.c
| CLI program that calls mrspsrv.c | ||
mrspcli2.c
| CLI program that calls mrspsrv2.sqc | ||
mrspcli3.sqc
| An embedded SQL program that calls mrspsrv2.sqc using clicall.c | ||
mrspsrv.c
| Stored procedure that returns a multi-row result set | ||
mrspsrv2.sqc
| An embedded SQL stored procedure that returns a multi-row result set | ||
outcli.c
| Call embedded output stored procedure samples/c/inpsrv | ||
outcli2.c
| Call CLI output stored procedure inpsrv2 | ||
outsrv2.c
| CLI output stored procedure (rewrite of embedded sample inpsrv.sqc) | ||
Samples using ORDER tables created by create.c (Run in the following order) | |||
create.c
| Creates all tables for the order scenario | ||
custin.c
| Inserts customers into the customer table (array insert) | ||
prodin.c
| Inserts products into the products table (array insert) | ||
prodpart.c
| Inserts parts into the prod_parts table (array insert) | ||
ordin.c
| Inserts orders into the ord_line, ord_cust tables (array insert) | ||
ordrep.c
| Generates order report using multiple result sets | ||
partrep.c
| Generates exploding parts report (recursive SQL Query) | ||
order.c
| UDF library code (declares a 'price' UDF) | ||
order.exp | Used to build order libary | ||
Samples unchanged from DB2 Version 2 | |||
v2sutil.c
| samputil.c using old v2 functions | ||
v2sutil.h
| samputil.h using old v2 functions | ||
v2fetch.c
| fetch.c using old v2 functions | ||
v2xfetch.c
| xfetch.c using old v2 functions | ||
|
Table 9. Java Database Connectivity (JDBC) Sample Programs
Sample Program Name | Program Description |
---|---|
BasicCon.java
| Basic connection. |
Browser.java
| List columns, foreign keys, index columns or stats for a table |
ColPriv.java
| List column Privileges |
Columns.java
| List all columns for table search string. |
DB2Appl.java
| A JDBC application that queries the sample database using the invoking user's privileges. |
DB2Applt.java
| A JDBC applet that queries the database using the JDBC applet driver. It uses the user name, password, server, and port number parameters specified in DB2Applt.html . |
DB2Applt.html
| An HTML file that embeds the applet sample program, DB2Applt . It needs to be customized with server and user information. |
DB2SpCli.java
| A Java client application that calls the JDBC stored procedure, DB2Stp . |
DB2Stp.java
| A Java stored procedure that updates the EMPLOYEE table on the server, and returns new salary and payroll information to the client. |
DB2UdCli.java
| A Java client application that calls the Java user-defined function, DB2Udf . |
Dynamic.java
| Demonstrates a cursor using dynamic SQL. |
Embedded.java
| Create, populate, list data from and drop a table. |
GetAttrs.java
| List some common environment, connection and statement options/attributes. |
GetData.java
| Simple querying and displaying of data from database. |
Inpcli.java
| A Java client application that calls the JDBC stored procedure, Inpsrv . |
Inpsrv.java
| A Java stored procedure demonstrating the SQLDA structure. It creates a PRESIDENTS table in the sample database with information received from the SQLDA, and returns the SQLCA status to the client application, Inpcli . |
JavaSample.java
| Creates the table, JAVA_SAMPLE, adds data, displays data, and deletes the table. |
JobChange.java
| Uses a statement and a prepared statement to query the database and update information at the same time (does the same as getcurs.c and setcurs.c but cannot do both ways therefore above method is used). |
LookRes.java
| Extract string from the resume clob field by converting the entire clob into a string, and searching for the desired substring. |
MRSPcli.java
| This is the client program that calls the server program MRSPsrv. The program demonstrates multiple result sets being returned from a Java stored procedure. |
MRSPsrv.java
| This is the server program that is called by the client program, MRSPcli. The program demonstrates multiple result sets being returned from a Java stored procedure. |
MultiCon.java
| Multiple connections. |
Outcli.java
| A Java client application that calls the SQLJ stored procedure, Outsrv . |
PicIn.java
| Loads graphic BLOBS into the emp_photo using the setBinaryStream method. |
PluginEx.java
| A Java program that adds new menu items and toolbar buttons to the DB2 Web Control Center. |
Prepare.java
| Rewrite of Simple.java, using a prepared statement. |
ProcCols.java
| List procedure parameters using getProcedureColumns under DatabaseMetaData. |
Procs.java
| List procedures using DatabaseMetaData.getProcedures. |
ShowPic.java
| Extracts BLOB picture to file using the getBinaryStream method. The file is read using the InputStream.read method. |
Simple.java
| Shows basic connecting querying and displaying the result set. (JDBC version of CLI sample fetch.c). |
StpCli.java
| A Java client application that calls the SQLJ stored procedure, Stp . |
Tables.java
| List all tables that match user defined search pattern. |
Tools.java
| Demonstrates a toolkit for Java programs written as DB2 samples. |
TypeInfo.java
| Display type information for all types for current data source. |
UDFcli.java
| A JDBC client application that calls functions in the Java user-defined function library, UDFsrv . |
UsingThreads.java
| Shows how to use threads to run an SQL statement asynchronously (JDBC version of CLI sample async.c). |
Varinp.java
| Demonstrates variable input to Embedded Dynamic SQL statement calls using parameter markers. |
Samples using ORDER tables created by Create.java (Run in the following order). | |
Create.java
| Creates all tables for the order scenario. |
CustIn.java
| Inserts customers into the customer table (array insert). |
ProdIn.java
| Inserts products into the products table (array insert). |
ProdPart.java
| Inserts parts into the prod_parts table (array insert). |
OrdIn.java
| Inserts orders into the ord_line, ord_cust tables (array insert). |
OrdRep.java
| Generates a customer order report and uses the user defined function 'price' defined in order.c. |
PartRep.java
| Generates exploding parts report (recursive SQL Query). |
DropJava.java
| Removes the new tables created for the ORDER scenario. |
Table 10. Embedded SQL for Java (SQLJ) Sample Programs
Sample Program Name | Program Description |
---|---|
App.sqlj
| Uses static SQL to retrieve and update data from the EMPLOYEE table of the sample database. |
Applt.sqlj
| An applet that queries the database using the JDBC applet driver. It uses the user name, password, server, and port number parameters specified in Applt.html . |
Applt.html
| An HTML file that embeds the applet sample program, Applt . It needs to be customized with server and user information. |
Cursor.sqlj
| Demonstrates an iterator using static SQL. |
OpF_Curs.sqlj
| Class file for the Openftch program. |
Openftch.sqlj
| Demonstrates fetching, updating, and deleting rows using static SQL. |
Outsrv.sqlj
| Demonstrates a stored procedure using the SQLDA structure. It fills the SQLDA with the median salary of the employees in the STAFF table of the sample database. After the database processing (finding the median), the stored procedure returns the filled SQLDA and the SQLCA status to the JDBC client application, Outcli . |
Static.sqlj
| Uses static SQL to retrieve information. |
Stp.sqlj
| A stored procedure that updates the EMPLOYEE table on the server, and returns new salary and payroll information to the JDBC client program, StpCli . |
UDFclie.sqlj
| A client application that calls functions from the Java user-defined function library, UDFsrv . |
Updat.sqlj
| Uses static SQL to update a database. |
Table 11. ADO, RDO, and MTS Sample Programs
Sample Program Name | Program Description |
---|---|
Bank.vbp | An RDO program to create and maintain data for bank branches, with the ability to perform transactions on customer accounts. The program can use any database specified by the user as it contains the DDL to create the necessary tables for the application to store data. |
Blob.vbp | This ADO program demonstrates retrieving BLOB data. It retrieves and displays pictures from the emp_photo table of the sample database. The program can also replace an image in the emp_photo table with one from a local file. |
BLOBAccess.dsw | This sample demonstrates highlighting ADO/Blob access using Microsoft
Visual C++. It is similar to the Visual Basic sample,
Blob.vbp. The BLOB sample has two main
functions:
|
Connect.vbp | This ADO program will create a connection object, and establish a connection, to the sample database. Once completed, the program will disconnect and exit. |
Commit.vbp | This application demonstrates the use of autocommit/manual-commit features of ADO. The program queries the EMPLOYEE table of the sample database for employee number and name. The user has an option of connecting to the database in either autocommit or manual-commit mode. In the autocommit mode, all of the changes that a user makes on a record are updated automatically in the database. In the manual-commit mode, the user needs to begin a transaction before he/she can make any changes. The changes made since the beginning of a transaction can be undone by performing a rollback. The changes can be saved permanently by committing the transaction. Exiting the program automatically rolls back the changes. |
db2com.vbp | This Visual Basic project demonstrates updating a database using the
Microsoft Transaction Server. It creates a server DLL used by the
client program, db2mts.vbp, and has four class
modules:
|
db2mts.vbp | This is a Visual Basic project for a client program that uses the Microsoft Transaction Server to call the server DLL created from db2com.vbp. |
Select-Update.vbp | This ADO program performs the same functions as Connect.vbp, but also provides a GUI interface. With this interface, the user can view, update, and delete data stored in the ORG table of the sample database. |
Sample.vbp | This Visual Basic project uses Keyset cursors via ADO to provide a graphical user interface to all data in the sample database. |
VarCHAR.dsp | A Visual C++ program that uses ADO to access VarChar data as textfields. It provides a graphical user interface to allow users to view and update data in the ORG table of the sample database. |
Table 12. Object Linking and Embedding (OLE) Sample Programs
Sample Program Name | Program Description |
---|---|
sales.vbp | Demonstrates rollup queries on a Microsoft Excel sales spreadsheet (implemented in Visual Basic). |
names.vbp | Queries a Lotus Notes address book (implemented in Visual Basic). |
inbox.vbp | Queries Microsoft Exchange inbox e-mail messages through OLE/Messaging (implemented in Visual Basic). |
invoice.vbp | An OLE automation user-defined function that sends Microsoft Word invoice documents as e-mail attachments (implemented in Visual Basic). |
ccounter | A counter OLE automation user-defined function (implemented in Visual C++). |
salarysrv.vbp | An OLE automation stored procedure that calculates the median salary of the STAFF table of the sample database (implemented in Visual Basic). |
salaryclt | A client program that invokes the median salary OLE automation stored procedure salarysrv (implemented in Visual Basic and in Visual C++). |
Table 13. Object Linking and Embedding Database (OLE DB) Table Functions
Sample Program Name | Program Description |
---|---|
jet.db2 | Microsoft.Jet.OLEDB.3.51 Provider |
mapi.db2 | INTERSOLV Connect OLE DB for MAPI |
msdaora.db2 | Microsoft OLE DB Provider for Oracle |
msdasql.db2 | Microsoft OLE DB Provider for ODBC Drivers |
msidxs.db2 | Microsoft OLE DB Index Server Provider |
notes.db2 | INTERSOLV Connect OLE DB for Notes |
sampprov.db2 | Microsoft OLE DB Sample Provider |
sqloledb.db2 | Microsoft OLE DB Provider for SQL Server |
Table 14. Command Line Processor (CLP) Sample Programs.
Sample File Name | File Description |
---|---|
const.db2 | Creates a table with a CHECK CONSTRAINT clause. |
cte.db2 | Demonstrates a common table expression. The equivalent sample program demonstrating this advanced SQL statement is tabsql. |
flt.db2 | Demonstrates a recursive query. The equivalent sample program demonstrating this advanced SQL statement is recursql. |
join.db2 | Demonstrates an outer join of tables. The equivalent sample program demonstrating this advanced SQL statement is joinsql. |
stock.db2 | Demonstrates the use of triggers. The equivalent sample program demonstrating this advanced SQL statement is trigsql. |
testdata.db2 | Uses DB2 built-in functions such as RAND() and TRANSLATE() to populate a table with randomly generated test data. |
thaisort.db2 | This script is particularly for Thai users. Thai sorting is by phonetic order requiring pre-sorting/swapping of the leading vowel and its consonant, as well as post-sorting in order to view the data in the correct sort order. The file implements Thai sorting by creating UDF functions presort and postsort, and creating a table; then it calls the functions against the table to sort the table data. To run this program, you first have to build the user-defined function program, udf, from the C source file, udf.c. |
Table 15. Log Management User Exit Sample Programs.
Sample File Name | File Description |
---|---|
db2uext2.cadsm | This is a sample User Exit utilizing ADSTAR DSM ( ADSM ) APIs to archive and retrieve database log files. The sample provides an audit trail of calls (stored in a separate file for each option) including a timestamp and parameters received. It also provides an error trail of calls in error including a timestamp and an error isolation string for problem determination. These options can be disabled. The file must be renamed db2uext2.c and compiled as a C program. Available on UNIX and Windows 32-bit operating systems. The OS/2 version is db2uexit.cad. |
db2uexit.cad | This is the OS/2 version of db2uext2.cadsm. The file must be renamed db2uexit.c and compiled as a C program. |
db2uext2.cdisk | This is a sample User Exit utilizing the system copy command for the particular platform on which it ships. The program archives and retrieves database log files, and provides an audit trail of calls (stored in a separate file for each option) including a timestamp and parameters received. It also provides an error trail of calls in error including a timestamp and an error isolation string for problem determination. These options can be disabled. The file must be renamed db2uext2.c and compiled as a C program. Available on UNIX and Windows 32-bit operating systems. |
db2uext2.ctape | This is a sample User Exit utilizing system tape commands for the particular UNIX platform on which it ships. The program archives and retrieves database log files. All limitations of the system tape commands are limitations of this user exit. The sample provides an audit trail of calls (stored in a separate file for each option) including a timestamp and parameters received. It also provides an error trail of calls in error including a timestamp and an error isolation string for problem determination. These options can be disabled. The file must be renamed db2uext2.c and compiled as a C program. Available on UNIX platforms only. |