README file for C Samples
DB2 Universal Database for HP-UX
================================
Last update : April 2000. 

The following is a table of sample programs that are supplied with DB2.
                                                     
These programming examples are for the "C" programming language, and can be
found in the "sqllib/samples/c" directory.  Copy these files to your working 
directory prior to building the sample programs.

WARNING: Some of these samples will change your database manager
         configuration.  Execute the samples in a test instance only.

For more information on programming in C, see the
  -  "Programming in C and C++" section of the Application Development Guide
  
For more information on Building C Applications, see the:
  - "Building C Applications" section of the Application Building Guide.

For more information on the SQL language see the SQL Reference.

For the latest information on programming, compiling, and running DB2 
applications, refer to the DB2 application development website at 
  - http:// www.software.ibm.com/data/db2/udb/ad 

   +============================================+                        
+==|How to build the SAMPLE programs using make |=============================+
|  +============================================+                             |
|  Before building the sample programs, you require:                          |
|                                                                             |
|    - Your environment initialized to a valid db2 instance.                  |
|    - The sample database (created with the db2sampl commmand).              |
|    - The database manager started (with the db2start command).              |
|    - Write permission to the the "sqllib/function" directory of             |
|      the database instance prior to building stored procedures and          |
|      user-defined functions such as:                                        |
|                                                                             |
|         spserver                                                            |
|         udf                                                                 |
|                                                                             |
|  Using the makefile in this directory, you can build any of the supplied    |
|  sample programs in one step by entering the following command:             |
|                                                                             |
|     make <prog_name>  (eg. make adhoc)                                      |
|                                                                             |
|  You can also use the makefile to build all the supplied sample programs    |
|  in one step by entering the following command:                             |
|                                                                             |
|     make all                                                                |
|                                                                             |
|  To remove the intermediate files, enter:                                   |
|                                                                             |
|    make clean                                                               |
|                                                                             | 
|  To remove all intermediate files and the resulting executables, enter:     |
|                                                                             |
|    make cleanall                                                            |
|                                                                             | 
|  Although the makefile is easier to use, it may be more difficult to        | 
|  understand, so script files are also included, as described below.         |
+=============================================================================+ 
                                                    
   .----------------------------------------------.
.--|How to build the SAMPLE programs using SCRIPTs|---------------------------.
|  '----------------------------------------------'                           |
| To compile the following programs, you need to invoke the proper build      |
| scripts. The supplied scripts are listed near the end of this README file.  |
| For detailed information on these scripts, and for additional setup         |
| information, see the book "Application Building Guide".                     |
'-----------------------------------------------------------------------------'

Table Legend:
=============
  NOTES:  CLI    A client application, which calls a stored procedure or 
                 declares and calls a user-defined function on the server.
          DDB    Requires a default database designated by environment
                 variable DB2DBDFT.
          IPX    Runs only on a machine using IPX communications protocol.
          MPP    Designed to run specifically in a partitioned database 
                 environment.
          SRV    You must run this sample locally on the server.
          STP    A stored procedure, which must be stored on the server,
                 and must be called by a corresponding client application.
          UDF    A library of user-defined functions. The library must be 
                 stored on the server, and the functions are declared
                 and called by a corresponding client application.

-------------+------+---------------------------------------------------
 SAMPLE      |NOTES | PROGRAM DESCRIPTION
 PROGRAM     |      |
 NAME        |      |
-------------+------+--------------------------------------------------
 adhoc.sqc   |      |This is an interactive shell for SQL statements, 
             |      |displaying the result sets and simple transaction
             |      |management.
-------------+------+--------------------------------------------------
 advsql.sqc  |      |Demonstrates the use of advanced SQL statements.
-------------+------+--------------------------------------------------
 asynrlog.sqc|      |This program demonstrates the use of a sqlurlog API:
             |      |    ASYNCHRONOUS LOG READ
-------------+------+--------------------------------------------------
 autocfg.sqc |      |Demonstrates the use of the following APIs:
             |      |    db2AutoConfig -- Autoconfig 
             |      |    Autoconfig Free Memory 
             |      |    Update Database Configuration 
             |      |    Update Database Manager Configuration 
             |      |    Set Client 
             |      |    SQLCA Message 
-------------+------+--------------------------------------------------
 backrest.c  | SRV  |This program demonstrates how to use BACKUP & RESTORE APIs:
             |      |     BACKUP DATABASE
             |      |     RESTORE DATABASE
             |      |     ROLL FORWARD DATABASE
-------------+------+--------------------------------------------------
 blobfile.sqc|      |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 which can be displayed using an
             |      |external viewer.
-------------+------+--------------------------------------------------
 calludf.sqc | CLI  |Uses the library of User-defined Functions (UDF)
             |      |created by "udf" for the SAMPLE database tables.
-------------+------+--------------------------------------------------
 cli_info.c  |      |Demonstrates using CLIENT INFORMATION APIs to set 
             |      |and query client information.  
-------------+------+--------------------------------------------------
 client.c    |      |Demonstrates the use of the following APIs:
             |      |     SET CLIENT
             |      |     QUERY CLIENT
-------------+------+--------------------------------------------------
 columns.sqc |      |Demonstrates the use of a cursor.  This cursor is
             |      |processed using dynamic SQL.  Lists all the entries
             |      |in the system table sysibm.systables that do not have
             |      |the value "STAFF" in the "name" column.
-------------+------+--------------------------------------------------
 cursor.sqc  |      |Demonstrates the use of a "CURSOR" using static
             |      |SQL.
-------------+------+--------------------------------------------------
 d_dbconf.c  |      |Demonstrates the use of the following API:
             |      |     GET DATABASE CONFIGURATION DEFAULTS
-------------+------+--------------------------------------------------
 d_dbmcon.c  |      |Demonstrates the use of the following API:
             |      |     GET DATABASE MANAGER CONFIGURATION DEFAULTS
-------------+------+--------------------------------------------------
 db_udcs.c   |      |Demonstrates the use of the following APIs to
             |      |simulate the collating behavior of a DB2 for
             |      |MVS/ESA CCSID 500 (EBCDIC International)
             |      |collating sequence:
             |      |     CREATE DATABASE
             |      |     DROP DATABASE
-------------+------+--------------------------------------------------
 dbauth.sqc  |      |Demonstrates the use of the following API:
             |      |     GET AUTHORIZATIONS
-------------+------+--------------------------------------------------
 dbcat.c     |      |Demonstrates the use of the following APIs:
             |      |     CATALOG DATABASE
             |      |     CLOSE DATABASE DIRECTORY SCAN
             |      |     GET NEXT DATABASE DIRECTORY ENTRY
             |      |     OPEN DATABASE DIRECTORY SCAN
             |      |     UNCATALOG DATABASE
-------------+------+--------------------------------------------------
 dbcmt.c     |      |Demonstrates the use of the following API:
             |      |     CHANGE DATABASE COMMENT
-------------+------+--------------------------------------------------
 dbconf.c    |      |Demonstrates the use of the following APIs:
             |      |     CREATE DATABASE
             |      |     DROP DATABASE
             |      |     GET DATABASE CONFIGURATION
             |      |     RESET DATABASE CONFIGURATION
             |      |     UPDATE DATABASE CONFIGURATION
-------------+------+--------------------------------------------------
 dbinst.c    |      |Demonstrates the use of the following APIs:
             |      |     ATTACH TO INSTANCE
             |      |     DETACH FROM INSTANCE
             |      |     GET INSTANCE
-------------+------+--------------------------------------------------
 dbmconf.c   |      |Demonstrates the use of the following APIs:
             |      |     GET DATABASE MANAGER CONFIGURATION
             |      |     RESET DATABASE MANAGER CONFIGURATION
             |      |     UPDATE DATABASE MANAGER CONFIGURATION
-------------+------+--------------------------------------------------
 dbsnap.c    |      |Demonstrates the use of the following API:
             |      |     DATABASE MONITOR SNAPSHOT
-------------+------+--------------------------------------------------
 dbstat.sqc  |      |Demonstrates the use of the following APIs:
             |      |     REORGANIZE TABLE
             |      |     RUN STATISTICS
-------------+------+--------------------------------------------------
 dbstart.c   | SRV  |Demonstrates the use of the following API:
             |      |     START DATABASE MANAGER
-------------+------+--------------------------------------------------
 dbstop.c    | SRV  |Demonstrates the use of the following APIs:
             |      |     FORCE USERS
             |      |     STOP DATABASE MANAGER
-------------+------+--------------------------------------------------
 db2mon.c    |      |Demonstrates how to use the Database System 
             |      |Monitor APIs, and how to process the output data
             |      |buffer returned from the snapshot API.
-------------+------+--------------------------------------------------
db2uext2.cadsm|     |Each provides a sample log management user exit.
db2uext2.cdisk|     |Note that you must rename the extensions of the  
db2uext2.ctape|     |files to .c before you can build and run them.
              |     |These samples are not included in the makefile.
-------------+------+--------------------------------------------------
 dcscat.c    |      |Demonstrates the use of the following APIs:
             |      |     ADD DCS DIRECTORY ENTRY
             |      |     CLOSE DCS DIRECTORY SCAN
             |      |     GET DCS DIRECTORY ENTRY FOR DATABASE
             |      |     GET DCS DIRECTORY ENTRIES
             |      |     OPEN DCS DIRECTORY SCAN
             |      |     UNCATALOG DCS DIRECTORY ENTRY
-------------+------+--------------------------------------------------
 delet.sqc   |      |Demonstrates the use of static SQL to delete items 
             |      |from a database.
-------------+------+--------------------------------------------------
 dmscont.c   |      |Demonstrates the use of the following APIs to
             |      |create a database with more than one database
             |      |managed storage (DMS) container:
             |      |     CREATE DATABASE
             |      |     DROP DATABASE
-------------+------+--------------------------------------------------
 dynamic.sqc |      |Demonstrates the use of a cursor using dynamic SQL.
-------------+------+--------------------------------------------------
 ebcdicdb.c  |      |Demonstrates the use of the following APIs to
             |      |simulate the collating behavior of a DB2 for
             |      |MVS/ESA CCSID 037 (EBCDIC US English)
             |      |collating sequence:
             |      |     CREATE DATABASE
             |      |     DROP DATABASE
-------------+------+---------------------------------------------------
 expsamp.sqc |      |Demonstrates the use of the following APIs:
             |      |     EXPORT
             |      |     IMPORT
             |      |in conjunction with a DRDA database.
-------------+------+--------------------------------------------------
 impexp.sqc  |      |Demonstrates the use of the following APIs:
             |      |     EXPORT
             |      |     IMPORT
-------------+------+--------------------------------------------------
 joinsql.sqc |      |Demonstrates the use of advanced SQL join expressions.
-------------+------+--------------------------------------------------
 lnaddrbk.c  |      |The two table functions read "Person" documents from 
             |      |Lotus Notes Address Book NSF databases. The table 
             |      |functions return ~50 fields from person documents as 
             |      |table function output columns.
-------------+------+--------------------------------------------------
 loadqry.sqc |      |Demonstrates use of APIs to query the current status 
             |      |of any LOAD invoked on a table.
-------------+------+--------------------------------------------------
 lobeval.sqc |      |Demonstrates the use of deferring the evaluation
             |      |of a LOB within a database.
 ------------+------+--------------------------------------------------
 lobfile.sqc |      |Demonstrates the use of LOB file handles.
-------------+------+--------------------------------------------------
 lobloc.sqc  |      |Demonstrates the use of LOB locators.
-------------+------+--------------------------------------------------
 lobval.sqc  |      |Demonstrates the use of LOBs.
-------------+------+--------------------------------------------------
 makeapi.sqc | SRV  |Demonstrates the use of the following APIs:
             |      |     BIND
             |      |     PRECOMPILE PROGRAM
             |      |     START DATABASE MANAGER
             |      |     STOP DATABASE MANAGER
-------------+------+--------------------------------------------------
 makepmap.c  | MPP  |Creates a partition map to redistribute data, 
             |      |based on user input.
             |      |See the file makemap.README for more information.
             |      |NOTE: This sample program is designed to be run
             |      |      in a partitioned database environment only.
-------------+------+--------------------------------------------------
 migrate.c   |      |Demonstrates the use of the following API:
             |      |     MIGRATE DATABASE
-------------+------+--------------------------------------------------
 monreset.c  |      |Demonstrates the use of the follwing API:
             |      |     RESET DATABASE SYSTEM MONITOR DATA AREAS
-------------+------+--------------------------------------------------
 monsz.c     |      |Demonstrates the use of the following APIs:
             |      |     ESTIMATE DATABASE SYSTEM MONITOR BUFFER SIZE
             |      |     DATABASE SYSTEM MONITOR SNAPSHOT
-------------+------+--------------------------------------------------
 nodecat.c   |      |Demonstrates the use of the following APIs:
             |      |     CATALOG NODE
             |      |     CLOSE NODE DIRECTORY SCAN
             |      |     GET NEXT NODE DIRECTORY ENTRY
             |      |     OPEN NODE DIRECTORY SCAN
             |      |     UNCATALOG NODE
-------------+------+--------------------------------------------------
 openftch.sqc|      |Demonstrates the use of static SQL to fetch rows 
             |      |and then UPDATE or DELETE them.
-------------+------+--------------------------------------------------
 rebind.sqc  |      |Demonstrates the use of the REBIND API
-------------+------+--------------------------------------------------
 rechist.sqc | SRV  |Demonstrates the use of the following APIs:
             | DDB  |     CLOSE RECOVERY HISTORY FILE SCAN
             |      |     GET NEXT RECOVERY HISTORY FILE ENTRY
             |      |     OPEN RECOVER HISTORY FILE SCAN
             |      |     PRUNE RECOVERY HISTORY FILE ENTRY
             |      |     UPDATE RECOVERY HISTORY FILE ENTRY
-------------+------+--------------------------------------------------
 recursql.sqc|      |Demonstrates the use of advanced SQL recursive queries.
-------------+------+--------------------------------------------------
 restart.c   | SRV  |Demonstrates the use of the following API:
             |      |     RESTART DATABASE MANAGER
-------------+------+--------------------------------------------------
 sampudf.sqc |      |Demonstrates the use of User-defined Types (UDT)
             |      |and User-defined Functions (UDF).  The UDFs
             |      |declared in this program are all sourced UDFs,
             |      |and do not call a UDF library on the server.
-------------+------+--------------------------------------------------
 setact.c    |      |Demonstrates the use of the following API:
             |      |     SET ACCOUNTING STRING
-------------+------+--------------------------------------------------
 setrundg.c  |      |Demonstrates the use of the following API:
             |      |     SET RUNTIME DEGREE
-------------+------+--------------------------------------------------
 spclient.sqc|      |Client program for the stored procedure server
             |      |program "spserver".
-------------+------+--------------------------------------------------
 spcreate.db2| SRV  |DB2 script to register stored procedures for the
             |      |server program "spserver".
-------------+------+--------------------------------------------------
 spdrop.db2  | SRV  |DB2 script to deregister stored procedures for the 
             |      |server program "spserver".
-------------+------+--------------------------------------------------
 spserver.sqc| STP  |Stored procedure program called by "spclient".
             |      |To build the spserver shared library:
             |      |1. Allow unloading shared libraries while developing
             |      |stored procedures by entering: 
             |      |"db2 update dbm cfg using KEEPDARI no".
             |      |2. Enter either "bldsrv spserver" or "make spserver".
             |      |3. Enter: "db2 connect to sample".
             |      |4. If the stored procedures were previously cataloged  
             |      |for a different language, uncatalog them by entering:
             |      |"db2 -td@ -vf spdrop.db2".
             |      |5. Catalog the stored procedures by entering: 
             |      |"db2 -td@ -vf spcreate.db2".
-------------+------+--------------------------------------------------
 static.sqc  |      |Demonstrates the use of static SQL to retrieve 
             |      |information.
-------------+------+--------------------------------------------------
 sws.c       |      |Demonstrates the use of the following API:
             |      |     DATABASE MONITOR SWITCH
-------------+------+--------------------------------------------------
 tabspace.sqc|      |Demonstrates the use of the following APIs:
             |      |     TABLESPACE QUERY
             |      |     SINGLE TABLESPACE QUERY
             |      |     OPEN TABLESPACE QUERY
             |      |     FETCH TABLESPACE QUERY
             |      |     GET TABLESPACE STATISTICS
             |      |     CLOSE TABLESPACE QUERY
-------------+------+--------------------------------------------------
 tabscont.sqc|      |Demonstrates the use of the following APIs:
             |      |     TABLESPACE CONTAINER QUERY
             |      |     OPEN TABLESPACE CONTAINER QUERY
             |      |     FETCH TABLESPACE CONTAINER QUERY
             |      |     CLOSE TABLESPACE CONTAINER QUERY
             |      |     SET TABLESPACE CONTAINER QUERY
-------------+------+--------------------------------------------------
 tabsql.sqc  |      |Demonstrates the use of advanced SQL table expressions.
-------------+------+--------------------------------------------------
 tbdefine.sqc|      |Demonstrates how to create/drop tables.
-------------+------+--------------------------------------------------
 thdsrver.sqc|      |Maintains a pool of contexts.  A generate_work function
             |      |is creates dynamic sql statements that are executed
             |      |by worker threads.
-------------+------+--------------------------------------------------
 tload.sqc   | SRV  |Demonstrates the use of the following APIs:
             |      |     EXPORT
             |      |     QUIESCE TABLESPACES FOR TABLE
             |      |     LOAD
             |      |     LOAD QUERY
-------------+------+--------------------------------------------------
 trigsql.sqc |      |Demonstrates the use of advanced SQL triggers and
             |      |contraints.
-------------+------+--------------------------------------------------
 tspace.sqc  |      |Demonstrates the use of TABLESPACE and TABLESPACE 
             |      |CONTAINER APIs.
-------------+------+--------------------------------------------------
 udf.c       | UDF  |Creates a library of User-defined Functions (UDF)
             |      |made specifically for the SAMPLE database tables,
             |      |but can be used with tables of compatible column
             |      |types.
-------------+------+--------------------------------------------------
 updat.sqc   |      |Demonstrates the use of static SQL to update a 
             |      |database.
-------------+------+--------------------------------------------------
 utilapi.c   |      |Error checking utility for non-embedded SQL DB2
             |      |API programs.
-------------+------+--------------------------------------------------
 utilapi.h   |      |Header file for "utilapi.c".
-------------+------+--------------------------------------------------
 utilemb.sqc |      |Error checking utility for embedded SQL programs.
-------------+------+--------------------------------------------------
 utilemb.h   |      |Header file for "utilemb.sqc". 
-------------+------+--------------------------------------------------
 varinp.sqc  |      |Demonstrates the use of variable input to Embedded 
             |      |Dynamic SQL calls using parameter markers.
-------------+------+--------------------------------------------------


-------------+------+---------------------------------------------------
 BUILD       |NOTES | DESCRIPTION
 FILE        |      |
 NAME        |      |
-------------+------+---------------------------------------------------
 bldapp      |      |Builds an application program.
-------------+------+---------------------------------------------------
 bldevm      |      |Builds the Event Monitor program.
-------------+------+---------------------------------------------------
 bldmt       |      |Builds a multi-threaded embedded SQL program.
-------------+------+---------------------------------------------------
 bldsrv      |      |Builds a stored procedure.
-------------+------+---------------------------------------------------
 bldudf      |      |Builds a user-defined function (UDF) library.
-------------+------+---------------------------------------------------
 embprep     |      |Precompiles and binds an embedded SQL program.
-------------+------+---------------------------------------------------


-------------+------+---------------------------------------------------
 OTHER       |NOTES | DESCRIPTION
-------------+------+---------------------------------------------------
 makefile    |      |Builds most of the supplied sample progams in
             |      |the "sqllib/samples/c" subdirectory.
-------------+------+---------------------------------------------------
 README      |      |Lists and describes all files in
             |      |the "sqllib/samples/c" subdirectory. (This file).
-------------+------+---------------------------------------------------