README file for Micro Focus COBOL Sample Programs DB2 Universal Database for OS/2 ================================================= Last updated : April 2000. These sample files are for the COBOL programming language using the Micro Focus Cobol compiler, and are located in the sqllib\samples\cobol_mf 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 COBOL, refer to the: - "Programming in COBOL" section of the Application Development Guide. For more information on Building COBOL Applications, refer to the: - "Building COBOL Applications" section of the Application Building Guide. For more information on the SQL language, refer to 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 nmake+-----------------------------+ | +--------------------------------------------+ | | Note: The supplied makefile runs the 32-bit Micro Focus COBOL compiler. | | To use the 16-bit Micro Focus Cobol compiler see the samples in the | | "sqllib\samples\cobol_16" directory. To use the IBM VisualAge | | COBOL compiler, see the samples in the "sqllib\samples\cobol" | | directory. | | | | Before building the sample programs, you require: | | | | - The sample database (created with the db2sampl commmand). | | - The database manager must be started (with the db2start command). | | - Write permission to the "sqllib\function" directory of | | the database instance prior to building the following programs: | | | | outsrv | | inpsrv | | | | Using the makefile in this directory, you can build any of the supplied | | sample programs in one step by entering the following command: | | | | nmake <prog_name> (e.g. nmake updat) | | | | You can also use the makefile to build all the supplied sample programs | | in one step by entering the following command: | | | | nmake all | | | | To remove the intermediate files, enter: | | | | nmake clean | | | | To remove all intermediate files and the resulting executables, enter: | | | | nmake cleanall | | | | Although the makefile is easier to use, it may be more difficult to | | understand, so command files are also included, as described below. | +-----------------------------------------------------------------------------+ +----------------------------------------------------+ +--+How to build the SAMPLE programs using command files+---------------------+ | +----------------------------------------------------+ | | To compile the following programs, you need to invoke the proper build | | commands. The supplied command files are listed near the end of this README | | file. For detailed information on the content of these build command files | | and additional setup information, see the "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. 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 | | -------------+------+-------------------------------------------------- advsql.sqb | |An example using advanced SQL expressions like | |CASE, CAST, and scalar fullselects. -------------+------+-------------------------------------------------- checkerr.cbl| |Demonstrates the use of the following APIs: | | GET ERROR MESSAGE | | INSTALL SIGNAL HANDLER | | INTERRUPT | |This program also contains code to output | |information from an SQLDA. -------------+------+-------------------------------------------------- client.cbl | |Demonstrates the use of the following APIs: | | SET CLIENT | | QUERY CLIENT -------------+------+-------------------------------------------------- cursor.sqb | |Demonstrates the use of a "CURSOR" using static | |SQL. -------------+------+-------------------------------------------------- d_dbconf.cbl| |Demonstrates the use of the following API: | | GET DATABASE CONFIGURATION DEFAULTS -------------+------+-------------------------------------------------- d_dbmcon.cbl| |Demonstrates the use of the following API: | | GET DATABASE MANAGER CONFIGURATION DEFAULTS -------------+------+-------------------------------------------------- db_udcs.cbl | |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.sqb | |Demonstrates the use of the following API: | | GET AUTHORIZATIONS -------------+------+-------------------------------------------------- dbcat.cbl | |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.cbl | |Demonstrates the use of the following API: | | CHANGE DATABASE COMMENT -------------+------+-------------------------------------------------- dbconf.cbl | |Demonstrates the use of the following APIs: | | CREATE DATABASE | | DROP DATABASE | | GET DATABASE CONFIGURATION | | RESET DATABASE CONFIGURATION | | UPDATE DATABASE CONFIGURATION -------------+------+-------------------------------------------------- dbinst.cbl | |Demonstrates the use of the following APIs: | | ATTACH TO INSTANCE | | DETACH FROM INSTANCE | | GET INSTANCE -------------+------+-------------------------------------------------- dbmconf.cbl | |Demonstrates the use of the following APIs: | | GET DATABASE MANAGER CONFIGURATION | | RESET DATABASE MANAGER CONFIGURATION | | UPDATE DATABASE MANAGER CONFIGURATION -------------+------+-------------------------------------------------- dbsnap.cbl | |Demonstrates the use of the following API: | | DATABASE MONITOR SNAPSHOT -------------+------+-------------------------------------------------- dbstat.sqb | |Demonstrates the use of the following APIs: | | REORGANIZE TABLE | | RUN STATISTICS -------------+------+-------------------------------------------------- dbstart.cbl | SRV |Demonstrates the use of the following API: | | START DATABASE MANAGER -------------+------+-------------------------------------------------- dbstop.cbl | SRV |Demonstrates the use of the following APIs: | | FORCE USERS | | STOP DATABASE MANAGER -------------+------+-------------------------------------------------- dcscat.cbl | |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.sqb | |Uses static SQL to delete items from a database. -------------+------+-------------------------------------------------- dynamic.sqb | |Demonstrates the use of a "CURSOR" using dynamic | |SQL. -------------+------+-------------------------------------------------- ebcdicdb.cbl| |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.sqb | |Demonstrates the use of the following APIs: | | EXPORT | | IMPORT | |in conjunction with a DRDA database. -------------+------+-------------------------------------------------- impexp.sqb | |Demonstrates the use of the following APIs: | | EXPORT | | IMPORT -------------+------+-------------------------------------------------- inpcli.sqb | CLI |Demonstrates stored procedures using the SQLDA | |structure. 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 | |uses an embedded SQL CALL statement to call the. | |stored procedure. -------------+------+-------------------------------------------------- inpsrv.sqb | STP |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. -------------+------+-------------------------------------------------- joinsql.sqb | |An example using advanced SQL join expressions. -------------+------+-------------------------------------------------- loadqry.sqb | |Demonstrates how APIs are implemented in order | |to query the current status of a LOAD being | |invoked on the table "TABLE" in the database | |"SAMPLE". -------------+------+-------------------------------------------------- lobeval.sqb | |Demonstrates the use of deferring the evaluation | |of a LOB within a database. -------------+------+-------------------------------------------------- lobfile.sqb | |Demonstrates the use of LOB file handles. -------------+------+-------------------------------------------------- lobloc.sqb | |Demonstrates the use of LOB locators. -------------+------+-------------------------------------------------- migrate.cbl | |Demonstrates the use of the following API: | | MIGRATE DATABASE -------------+------+-------------------------------------------------- monreset.cbl| |Demonstrates the use of the follwing API: | | RESET DATABASE SYSTEM MONITOR DATA AREAS -------------+------+-------------------------------------------------- monsz.cbl | |Demonstrates the use of the following APIs: | | ESTIMATE DATABASE SYSTEM MONITOR BUFFER SIZE | | DATABASE SYSTEM MONITOR SNAPSHOT -------------+------+-------------------------------------------------- nodecat.cbl | |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.sqb| |Uses static SQL to fetch rows and then UPDATE | |or DELETE them. -------------+------+-------------------------------------------------- outcli.sqb | CLI |Demonstrates stored procedures using the SQLDA | |structure. This is the client program of a | |client/server example. (The server program is | |called "outsrv".) This program allocates and | |initializes a one variable SQLDA, and passes it | |to the server program for further processing. | |The filled SQLDA is returned to the client | |program along with the SQLCA status. This | |program uses an embedded SQL CALL statement to | |call the stored procedure. -------------+------+-------------------------------------------------- outsrv.sqb | STP |Demonstrates stored procedures using the SQLDA | |structure. This is the server program of a | |client/server example. (The client program is | |called "outcli".) The program fills the SQLDA | |with the median "SALARY" of the employees in the | |"STAFF" table of the "SAMPLE" database. The | |server program does all the database processing | |(finding the median). The server program returns | |the filled SQLDA and the SQLCA status to the | |client program. -------------+------+-------------------------------------------------- prepbind.sqb| |Demonstrates the use of the following APIs: | | BIND | | PRECOMPILE PROGRAM -------------+------+-------------------------------------------------- qload.sqb | |Demonstrates the use of the LOAD QUERY API -------------+------+-------------------------------------------------- rebind.sqb | |Demonstrates the use of the REBIND API -------------+------+-------------------------------------------------- restart.cbl | SRV |Demonstrates the use of the following API: | | RESTART DATABASE MANAGER -------------+------+-------------------------------------------------- setact.cbl | |Demonstrates the use of the following API: | | SET ACCOUNTING STRING -------------+------+-------------------------------------------------- static.sqb | |Uses static SQL to retrieve information. -------------+------+-------------------------------------------------- sws.cbl | |Demonstrates the use of the following API: | | DATABASE MONITOR SWITCH -------------+------+-------------------------------------------------- tabspace.sqb| |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.sqb| |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.sqb | |An example using advanced SQL table expressions. -------------+------+-------------------------------------------------- tload.sqb | SRV |Demonstrates the use of the following APIs: | | EXPORT | | QUIESCE TABLESPACES FOR TABLE | | LOAD -------------+------+-------------------------------------------------- trigsql.sqb | |An example using advanced SQL triggers and | |contraints. -------------+------+-------------------------------------------------- tspace.sqb | |Demonstrates the use of the following APIs: | | COPY MEMORY | | FREE MEMORY | | TABLESPACE QUERY | | TABLESPACE CONTAINER QUERY | | SINGLE TABLESPACE QUERY | | OPEN TABLESPACE QUERY | | FETCH TABLESPACE QUERY | | CLOSE TABLESPACE QUERY | | OPEN TABLESPACE CONTAINER QUERY | | FETCH TABLESPACE CONTAINER QUERY | | CLOSE TABLESPACE CONTAINER QUERY | | SET TABLESPACE CONTAINERS | | GET TABLESPACE STATISTICS -------------+------+-------------------------------------------------- updat.sqb | |Uses static SQL to update a database. -------------+------+-------------------------------------------------- varinp.sqb | |An example of variable input to Embedded Dynamic | |SQL calls using parameter markers. -------------+------+-------------------------------------------------- -------------+------+--------------------------------------------------- COMMAND |NOTES | DESCRIPTION FILE | | NAME | | -------------+------+-------------------------------------------------- bldapp.cmd | |Builds a Micro Focus COBOL application program. -------------+------+--------------------------------------------------- bldsrv.cmd | |Builds a Micro Focus COBOL stored procedure. -------------+------+--------------------------------------------------- embprep.cmd | |Command file to prep and bind a COBOL embedded | |SQL program. -------------+------+--------------------------------------------------- -------------+------+--------------------------------------------------- OTHER |NOTES | DESCRIPTION -------------+------+-------------------------------------------------- makefile | |Builds most of the supplied programming examples in | |the "sqllib\samples\cobol_mf" subdirectory. -------------+------+--------------------------------------------------- README | |Lists and describes at a high-level, all files in | |the "sqllib\samples\cobol_mf" subdirectory. (This file). -------------+------+---------------------------------------------------