	 k
p V1V1by name         by name         service         d   
kꄦ hB           O  V1V1V1        W  O      ./lpp_name                                    4 R S db2_02_01 {
db2_02_01.sdk.c 04.01.0001.3000 1 N U US_ENG DB2 C Language Include Files and Samples
[
*prereq db2_02_01.sdk.c 4.1.1.2

*ifreq db2_02_01.client 04.01.0001.3000
%
/usr/lpp/db2_02_01/include/sql.h 136
/usr/lpp/db2_02_01/include/sqlaprep.h 136
/usr/lpp/db2_02_01/include/sqlcli.h 32
/usr/lpp/db2_02_01/include/sqlcli1.h 88
/usr/lpp/db2_02_01/include/sqlcodes.h 80
/usr/lpp/db2_02_01/include/sqlenv.h 192
/usr/lpp/db2_02_01/include/sqlstate.h 64
/usr/lpp/db2_02_01/include/sqlutil.h 368
/usr/lpp/db2_02_01/samples/c/db2mon.c 256
/usr/lpp/db2_02_01/samples/c/evmprint.c 88
]
}
 k           * V1V1V1           *     ./usr/lpp/db2_02_01/db2_02_01.sdk.c/4.1.1.3000/liblpp.a                               <aiaff>
188400      0           68          182306      0           509         678         0           834095614   0           2           444         9   copyright `
Licensed Materials - Property of IBM

5765-453
(C) Copyright International Business Machines Corporation. 1993, 1996.

5765-454
(C) Copyright International Business Machines Corporation. 1993, 1996.

5765-455
(C) Copyright International Business Machines Corporation. 1993, 1996.

5765-642
(C) Copyright International Business Machines Corporation. 1993, 1996.

All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
 381         1168        68          834098936   2379        200         644         18  db2_02_01.sdk.c.al`
./usr/lpp/db2_02_01/include/sql.h
./usr/lpp/db2_02_01/include/sqlaprep.h
./usr/lpp/db2_02_01/include/sqlcli.h
./usr/lpp/db2_02_01/include/sqlcli1.h
./usr/lpp/db2_02_01/include/sqlcodes.h
./usr/lpp/db2_02_01/include/sqlenv.h
./usr/lpp/db2_02_01/include/sqlstate.h
./usr/lpp/db2_02_01/include/sqlutil.h
./usr/lpp/db2_02_01/samples/c/db2mon.c
./usr/lpp/db2_02_01/samples/c/evmprint.c
 406         1684        678         834098938   0           200         444         20  db2_02_01.sdk.c.size`
/usr/lpp/db2_02_01/include/sql.h 136
/usr/lpp/db2_02_01/include/sqlaprep.h 136
/usr/lpp/db2_02_01/include/sqlcli.h 32
/usr/lpp/db2_02_01/include/sqlcli1.h 88
/usr/lpp/db2_02_01/include/sqlcodes.h 80
/usr/lpp/db2_02_01/include/sqlenv.h 192
/usr/lpp/db2_02_01/include/sqlstate.h 64
/usr/lpp/db2_02_01/include/sqlutil.h 368
/usr/lpp/db2_02_01/samples/c/db2mon.c 256
/usr/lpp/db2_02_01/samples/c/evmprint.c 88
1043        2844        1168        834098938   0           200         444         25  db2_02_01.sdk.c.inventory `
/usr/lpp/db2_02_01/include/sql.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 68183

/usr/lpp/db2_02_01/include/sqlaprep.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 68402

/usr/lpp/db2_02_01/include/sqlcli.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 15866

/usr/lpp/db2_02_01/include/sqlcli1.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 41168

/usr/lpp/db2_02_01/include/sqlcodes.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 38753

/usr/lpp/db2_02_01/include/sqlenv.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 95268

/usr/lpp/db2_02_01/include/sqlstate.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 30768

/usr/lpp/db2_02_01/include/sqlutil.h:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 187182

/usr/lpp/db2_02_01/samples/c/db2mon.c:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 127417

/usr/lpp/db2_02_01/samples/c/evmprint.c:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 41778

 173945      176890      1684        834098304   0           200         444         10  lpp.README`
***********************************************************************
**                                                                   **
**  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1996.  **
**                    ALL RIGHTS RESERVED.                           **
**                                                                   **
***********************************************************************

                 Welcome to IBM Database Server for AIX!
                                Version 4


+--- NOTE! ----------------------------------------------------------+
|                                                                    |
| Set the font to monospace for better viewing of this README.       |
|                                                                    |
+--------------------------------------------------------------------+

This README file contains information for the following Database Server
products and components:

AIX-Specific
------------
 IBM DB2 Server (DB2 for AIX Version 2.1.1)
 IBM DB2 World Wide Web Connection
 IBM Distributed Database Connection Services Multi-User Gateway for AIX
   (DDCS Multi-User Gateway for AIX Version 2.3.1)

For information, see also

     Part Number   Publication
     -----------   -----------------------------------------------------------
     33H4879       IBM* Database Server for AIX Up and Running!

  ---------------------------------------------------------------------------


1.0  Contents

2.  INSTALLATION NOTES
2.1  System Requirements
2.2  Installing DDCS and Database Server on the Same Workstation
  2.2.1  Considerations When DDCS Is Already Installed
  2.2.2  Installing DDCS and Database Server
  2.2.3  Applying Fixes or Installing Additional Database Server
   Products
2.3  Prerequisite Notes
2.4  Automatic Adjustments to your System During Install
2.5  Installing Translated Messages on AIX 4.1 Systems
2.6  Information Presentation Facility (IPF/X) Considerations
  2.6.1  Consideration for AIX Version 4 (General Users)
  2.6.2  Consideration for AIX Version 4 (Simplified Chinese Only)
  2.6.3  Considerations for AIX (Japanese Users)
  2.6.4  Printing PostScript files from IPF/X
2.7  TZ Environment Variable
2.8  LAN Support Program and NetBIOS rc=0x18

3.  MIGRATION CONSIDERATIONS FROM DB2 2.1.0 PRODUCTS OR DB2 2.1.1 BETA
 DRIVERS
3.1  Coexistance with DB2 V2.1.0 and DDCS V2.3.0 products
3.2  Migrating from the DB2 2.1.0 GA or from the DB2 2.1.1 Beta
  3.2.1  Database Considerations
  3.2.2  Application Considerations
  3.2.3  Installing Over DB2 V2.1.0, DDCS V2.3.0 Products or the DB2
   Beta V2.1.1

4.  USAGE NOTES
4.1  Database Directory Utility
  4.1.1  Linking to Online Books from Database Director Online
   Help
  4.1.2  If Problems are Encountered when Running the Database
   Director
  4.1.3  DBCS Environment
4.2  Roll Forward and Log File Size
4.3  Using DCE Directories on AIX 4.1 Systems
4.4  Import/Load APIs
4.5  sqlestrd() API
4.6  Enabling IBM DB2-SMARTsort for DB2 LOAD
  4.6.1  Enabling SMARTsort under DB2
    4.6.1.1  Internal Information
  4.6.2  Disabling SMARTsort under DB2
  4.6.3  Programs
  4.6.4  DB2
4.7  DARI and UDF Considerations for National Language-Specific
 Processing
4.8  Package Name Considerations in Mixed Code Page Environments
4.9  Japanese and Traditional-Chinese EUC Code Page Environments
  4.9.1  Mixed EUC/Double-Byte Client and Database Considerations
  4.9.2  Character Conversion Considerations for Traditional-Chinese
   Users
    4.9.2.1  Code Page 964 (Traditional-Chinese EUC)
    4.9.2.2  Code Page 950 (Traditional-Chinese Big-5)
  4.9.3  DDCS-Specific Prerequisites and Limitations

5.  ENVIRONMENT CONSIDERATIONS
5.1  Copying a Shared Library
5.2  Receiving Error Message -30081 when Using the TCP/IP Protocol

6.  COMMUNICATIONS ISSUES
6.1  TCP/IP

7.  PROGRAMMING NOTES
7.1  Sample Applications
7.2  Considerations when Using Micro Focus COBOL
  7.2.1  Updating the Micro Focus COBOL Runtime System
  7.2.2  Configuring CICS for Use With DB2 2.1.1 and Micro Focus COBOL
   on UNIX Platforms
7.3  BINARY/COMP-4 COBOL Data Types in the DB2 Precompiler
7.4  Using REDEFINES in COBOL Group Data Items
7.5  Running DB2 for AIX COBOL Stored Procedures
7.6  Building Micro Focus COBOL Stored Procedures on AIX
7.7  Precompiler Customization
7.8  Considerations When Using REXX Stored Procedures

8.  AIX ODBC DRIVER
8.1  Common Application Problems and Work Arounds
8.2  SQLDescribeParam()
8.3  New CLI/ODBC Configuration Keywords in db2cli.ini
  8.3.1  CLI/ODBC Trace File
  8.3.2  Specifying a Directory for Temporary Files
  8.3.3  SQLDescribeParam() Enable/Disable
  8.3.4  Asynchronous ODBC Enable/Disable

9.  CHANGES TO THE DB2 DOCUMENTATION
9.1  For the "Changes for This Release" Section
9.2  Administration Guide
9.3  API Reference
  9.3.1  Backup and Restore API's for Vendor Products Appendix
   DB2-INFO Data Structure
  9.3.2  QUIESCE TABLESPACES FOR TABLE
9.4  Command Reference
  9.4.1  FORCE APPLICATION
  9.4.2  ROLLFORWARD DATABASE
  9.4.3  EXPORT
  9.4.4  QUIESCE TABLESPACES FOR TABLE
  9.4.5  RUNSTATS Enhancement
9.5  Call Level Interface Guide and Reference
  9.5.1  SQLColAttributes - Get Column Attributes
  9.5.2  New CLI/ODBC Configuration Keyword
9.6  Database System Monitor Guide and Reference
  9.6.1  db_conn_time Data Element
  9.6.2  Buffer Pool Data Pages Written to Disk
  9.6.3  DBMON Element Formula
  9.6.4  Buffer Pool Threshold Cleaners Triggered
  9.6.5  Event Start Time
  9.6.6  Package Cache Inserts/Package Cache Lookups
  9.6.7  Status of Database and Status of DB2 Instance
9.7  Planning Guide
  9.7.1  Segments Versus 4KB Pages
  9.7.2  BUFFPAGE and SORTHEAP
9.8  Configuration Parameters
  9.8.1  DIR_CACHE
  9.8.2  MAXAPPLS
  9.8.3  REC_HIS_RETENTN
  9.8.4  Configuration Parameters (YES/NO and ON/OFF Values)
  9.8.5  DFT_QUERYOPT
  9.8.6  LOGFILSIZ
9.9  Building Your Applications
  9.9.1  C++ Type Decoration Consideration
9.10  Installation and Operation Guides
9.11  SQL Reference
  9.11.1  ALTER TABLE Notes Addition
  9.11.2  SQL Communications Area (SQLCA)
  9.11.3  GROUP-BY and ORDER-BY Changes
    9.11.3.1  Expressions Section
    9.11.3.2  Queries Section
9.12  Application Programming Guide
9.13  References to CompuServe
9.14  Database Server Up and Running!
9.15  Messages Reference
  9.15.1  New Messages
  9.15.2  Changed Messages

10.  DB2 WORLD WIDE WEB CONNECTION FOR AIX INFORMATION
10.1  Installation Notes
10.2  DB2 WWW Connection Configuration
10.3  Usage Notes
  10.3.1  Authentication
10.4  Using the Sample Application
  10.4.1  Installation Notes
  10.4.2  DBCS Considerations When Using the Sample Application

11.  DDCS FOR AIX INFORMATION
11.1  Prerequisites
  11.1.1  Need to Apply DB2 for MVS PTF to Use DB2DRDA as RTPN
11.2  Documentation Changes
  11.2.1  Installation Requirements
  11.2.2  National Language (Code Page and Conversion) Information
   Changes
  11.2.3  OS/2 and UNIX-Based Databases
  11.2.4  SET CURRENT PACKAGESET Support
  11.2.5  DB2 for OS/400 Column Types and Length
  11.2.6  Binding DDCS Utilities to an OS/400 Database
    11.2.6.1  Possible Solutions
  11.2.7  Binding Utilities for Back-Level Clients
  11.2.8  Description of Environment Keywords
  11.2.9  DDCS (non-OS/2) Auto Disconnect Option Not Supported
  11.2.10  SPM Instance Name
11.3  Syncpoint Manager (SPM)
  11.3.1  AIX SNA Server Coexistence Considerations
  11.3.2  Prerequisite PTFs
  11.3.3  AIX/SNA Server Operational Considerations
11.4  Authentication Default
11.5  Performance Troubleshooting
11.6  DDCS 2.3 Gateway Connection to DB2/MVS
  11.6.1  Summary of Steps
  11.6.2  Products used in this example
  11.6.3  Network Element Names
  11.6.4  Configuring SNA Communications
  11.6.5  Cataloging DB2 Directory Entries at the Workstation
    11.6.5.1  Cataloging the Workstation
    11.6.5.2  Cataloging the Database
    11.6.5.3  Cataloging the DCS Database
    11.6.5.4  Verify DCS Directory Information
  11.6.6  Configuring VTAM
  11.6.7  VTAM DB2 APPL Definition
    11.6.7.1  VTAM DB2 PU and LU definitions
    11.6.7.2  Sample Log Mode Definition
  11.6.8  Configuring DB2/MVS
    11.6.8.1  Updating the SYSIBM.SYSUSERNAMES Table
    11.6.8.2  Update the SYSIBM.SYSLUNAMES Table
11.7  Connectivity Via DDCS (Thailand Users Only)
11.8  DDCS User's Guide BIND Information
11.9  Using DDCS with Bull SNA on AIX 4.1
  11.9.1  Installing Bull SNA Support with DB2/6000 Client or
   Gateway
    11.9.1.1  Configuring the Bull DPX/20 SNA/20 Server

12.  SAMPLE TOOLS AND UTILITIES

13.  LIMITATIONS IN DOCUMENTED FUNCTIONS
13.1  Transaction Manager Database Considerations
13.2  Recursive SQL Incompatibility
13.3  Command and API Limitations
  13.3.1  Remote Administration Command
13.4  Call Level Interface Limitations
  13.4.1  Limited Support for SQLDriverConnect on Motif Systems
13.5  WCHARTYPE CONVERT Precompile Option Limitation
13.6  Using DB2 with an XA-Compliant Transaction Manager
13.7  DB2 SNMP Subagent
13.8  Database Director Limitations
  13.8.1  Mount Container
  13.8.2  Restriction for Visual Explain
    13.8.2.1  Snapshot Monitor
    13.8.2.2  Event Analyzer
13.9  Online Backup and Load with COPY NO option

14.  MISCELLANEOUS
14.1  DB2 Family Newsletter


======================
2.  Installation Notes

2.1  System Requirements

See the Up and Running! Guide for the system requirements for Database
Server components.


2.2  Installing DDCS and Database Server on the Same Workstation


2.2.1  Considerations When DDCS Is Already Installed

If DDCS was installed from the DB2 Family CD or tape, you MUST
re-install DDCS using the Database Server CD.  Otherwise, you will not
be able to apply any Database Server PTFs.  Use the instructions in
the Up and Running! book to help you install DDCS.


2.2.2  Installing DDCS and Database Server

If you want to install both DDCS and Database Server on the same
workstation, perform the following steps:

o   Order the DDCS Multi-User Gateway Version 2.3.1 program package to
    obtain a license key.  Do NOT INSTALL DDCS from this package.
o   Install both products from the Database Server CD.
o   Apply the keys for the DB2 Server and DB2 Software Developer's Kit
    that are provided in the Database Server box.
o   Apply the key for DDCS that is provided in the DDCS Multi-User
    Gateway box.  YOU MUST INSTALL DDCS FROM THE DATABASE SERVER CD.


2.2.3  Applying Fixes or Installing Additional Database Server
Products

Once the Database Server product is installed on a workstation, you
must install any additional products ONLY from the Database Server CD.
DO NOT install any products from the DB2 Family media.  You must apply
all PTFs for the workstation from the Database Server PTFs.  DO NOT
apply any PTFs from the DB2 Family PTFs.


2.3  Prerequisite Notes

If the prerequisites that are listed in Appendix A of the Installation
and Operation Guide are not on the system for the following options,
installation of the these options will still proceed successfully:

     db2_02_01.cs.sna     DB2 Communications Support - SNA
     db2_02_01.cs.drda    DB2 Communications Support - DRDA Application Server
     db2_02_01.ddcs       DDCS DRDA Application Requestor

These options will only fail to install if their prerequisites are
installed but are not at the required levels or required PTFs are
missing.

Also, there is no installation-time check for the prerequisites listed
for the options:

     db2_02_01.cs.rte     DB2 Communications Support - Base with TCPIP
     db2_02_01.cs.ipx     DB2 Communications Support - IPX

Therefore, if you wish to use DB2 Communications Support with TCP/IP
or IPX/SPX communications protocols, you can either install the
required prerequisites before or after you install these DB2
Communications Support options.

ipfx.Runtime or ipfx.rte is a prerequisite for:

     db2_02_01.dd         DB2 Database Director

Note:  For Chinese users, you can only use the ipfx.Runtime
prerequisite.


2.4  Automatic Adjustments to your System During Install

When the db2_02_01.db2.rte option is installed, the following
adjustments are automatically made to your system:

o   The maximum number of user processes will be set to at least 500.

In addition, the following user attributes of the instance owner will
be adjusted when an instance is created:

1.  The maximum file size (fsize) is set to 2 gigabytes.

2.  The File Creation Mask (umask) is set to 022.


2.5  Installing Translated Messages on AIX 4.1 Systems

Translated messages for locales, other than En_US (English or United
States code page IBM-850), are not automatically installed via SMIT on
AIX 4.1 systems according to the setting of primary language
environment.

To install messages for locales other than English in the United
States via SMIT, you need to select "Install/Update From All Available
Software" from within the "Install/Update Selectable Software (Custom
Install)" menu.  After entering the "INPUT device/directory for
software", you can then list the "SOFTWARE to install" and select the
message options for the desired locales.  The message options will be
listed as:

    DB2 Product Messages - <locale>

where <locale> is the desired locale, for example locale=Fr_FR for
French in France with the IBM-850 code set.


2.6  Information Presentation Facility (IPF/X) Considerations

Database Server products are shipped with IPF/X Version 2.2.  This
version of IPF/X is automatically installed on your workstation when
Database Server is installed using software bundles.

The messages and online documentation for the language locale of your
workstation are automatically installed when using software bundles
to install Database Server.  If you want to install documentation
for other languages locales, you must also select the message option
for each one.  For example, to add the French documentation, you would
select the db2_02_01.doc.Fr_FR.ipfx and the db2_02_01.msg.Fr_FR options.

The DB2 Installation Guides contain information about IPF/X.  The
information in these sections has changed as follows:

o   The information in the "Restrictions" sections is no longer valid
    and should not be used.
o   Any references to ipfx.Runtime should be changed to ipfx.rte.
o   In the section "Considerations for Non-English Users" under the
    "Requirements" heading, the information about installing the
    proper IPF/X support no longer applies.

2.6.1  Consideration for AIX Version 4 (General Users)

All online documentation is created using IBM code pages.   To view
the books properly, you may have to install additional locales and
fonts on your workstation.

For example, if you wish to view the online books in English, and your
locale setting is En_US, you need to ensure that the En_US locale is
also installed on your workstation.  You can verify this with the
command:

     locale -a

If En_US does not appear in the resulting list, please install the
following LPP from your AIX installation media:

     bos.loc.pc_compat.En_US

For other languages, please install the corresponding LPP as follows:

   Language           LPP to be installed
   --------           -------------------------
   English            bos.loc.pc_compat.En_US
   French             bos.loc.pc_compat.Fr_FR
   German             bos.loc.pc_compat.De_DE
   Italian            bos.loc.pc_compat.It_IT
   Portuguese         bos.loc.pc_compat.Pt_PT
   Spanish            bos.loc.pc_compat.Es_ES

The proper fonts need to be installed as well.  Please ensure that the
following filesets are installed on your workstation:

     X11.compat.fnt.pc
     X11.fnt

Otherwise, some of the graphics (especially the tables) will not
appear correctly online.

If the fonts are installed, but the bos.loc.pc_compat.%L LPPs (or the
IBM PC locales) are not installed, then you can try to set the values
for xview*genFont and xview*monoFont in you environment to different
values.  For example, you can add the two following lines to you
.Xdefaults file:

   xview*genFont:-linotype-helvetica-medium-r-normal--19-140-100-100-p-102-ibm-850
   xview*monoFont:-linotype-helvetica-medium-r-normal--19-140-100-100-p-102-ibm-850

You can try using other ibm850 fonts.


2.6.2  Consideration for AIX Version 4 (Simplified Chinese Only)

If you are running version 4 of the AIX operating system, you require
version 4.1.3 to view the online books and online help.

This consideration does not apply to AIX version 3.


2.6.3  Considerations for AIX (Japanese Users)

For Japanese users to display online books and the online help
properly, please include the following lines in the .Xdefaults file
under the /home/user_id directory:

xview*genFont: romankn17;kanji17;IBM_JPN17;kana17:
xview*monoFont: romankn17;kanji17;IBM_JPN17;kana17:
xview*iconFont: romankn17;kanji17;IBM_JPN17;kana17:
xview*titleFont: romankn17;kanji17;IBM_JPN17;kana17:


2.6.4  Printing PostScript files from IPF/X

IPF/X allows printing of individual panels or entire sections to
PostScript printers.  To allow general user to print, you need to
modify the file protection mode for the file

   /usr/lpp/ipfx/misc/ps.prolog

to world-readable.  You can do this by logging on with root authority,
and then issuing the command:

   chmod o+r /usr/lpp/ipfx/misc/ps.prolog


2.7  TZ Environment Variable

When connecting a client to the server which runs on an operating
system that supports the concept of local time versus Universal
Coordinated Time (UCT, also known as Greenwich Mean Time or GMT), the
client machine should also set up timezone information that
corresponds to the server machine.  If it is not set, the client may
display certain timestamps (that are returned by the server)
incorrectly (being off by the difference between the UCT and local
time).

So for example, if a server is running under Pacific Standard Time
(PST) and a client is running under Eastern Standard Time (EST),
timestamps on the client will show PST unless the TZ variable is set.


2.8  LAN Support Program and NetBIOS rc=0x18

If you use IBM LAN Support Program to provide NetBIOS communications
protocol support, and you load the LAN Support Program device drivers
in DOS upper / high memory, you may encounter intermittent NetBIOS
communications errors "SQL30081, rc=0x18".  To avoid these
communications errors, load the LSP device drivers in conventional
memory.


======================================================================
3.  Migration Considerations from DB2 2.1.0 Products or DB2 2.1.1 Beta
Drivers

3.1  Coexistance with DB2 V2.1.0 and DDCS V2.3.0 products

The Database Server for AIX CD contains updated versions of all the
products. If you are installing your new product from this CD, you can
also update any other DB2 V2.1.0 or DDCS V2.3.0 products currently
installed.

Alternatively, you can contact IBM Service to obtain the DB2 V2.1.1 or
DDCS V2.3.1 service refresh for other products already installed.


3.2  Migrating from the DB2 2.1.0 GA or from the DB2 2.1.1 Beta


3.2.1  Database Considerations

The following points apply to the workstations that have either
installed the 2.1.1 Beta driver or one of the following products:

IBM DB2 for AIX Server V2.1.0
IBM DB2 for AIX Single-User V2.1.0

and they have created databases with these code levels.

o   It is strongly recommended that you perform an optional migration
    on any of your databases that were created by the V2.1.0 database
    manager, in order to give your applications access to the new
    scalar functions that have been implemented in V2.1.1.
o   DBADM authority is granted implicitly by DB2 when a SYSADM user
    creates a view or package that requires DBADM authority.  However,
    if such a user is later removed from the SYSADM group, their DBADM
    authority will also be removed.  Therefore, any users with DBADM
    authority who do not belong to the SYSADM group must have been
    explicitly granted DBADM access.
o   It is recommended that you use the runstats utility to update the
    index statistics for your tables.
o   The total database log file size (i.e the combined size of all the
    primary and secondary files in the database log directory) is
    limited to 4 gigabytes.  This is now enforced in the update
    database configuration command/API where the product of logfilsiz
    * (logprimary + logsecond) cannot exceed 1048575.  As a result:
    -   Any databases which have been configured in 2.1.0 with values
        that violate this condition should be re-configured.
    -   If the database has not been reconfigured to satisfy this
        condition, any attempt to update any other database
        configuration parameters will fail.


3.2.2  Application Considerations

The following points apply to systems that have either installed the
2.1.1 Beta driver or one of the following products:

IBM DB2 Software Developer's Kit for AIX V2.1.0
IBM DB2 for AIX Single-User V2.1.0

and applications have been created at these code levels.

o   If a V2.1.0 application is compiled and linked using an x1C 1.x
    compiler, the application may fail to run when you upgrade to
    V2.1.1.

    There are two possible solutions:

    1.  If you have the source code of the application, relink the
        application.
    2.  If you do not have access to the source code of the
        application, set the following LIBPATH:

          LIBPATH=/usr/lpp/db2_01_01/lib:/usr/lpp/db2_01_01/.rtelib:/usr/lib:/lib
          export LIBPATH


o   If you are migrating from the V2.1.1 beta driver, you must rebind
    your applications prior to running them. Use the db2rbind command
    to rebind all packages on your databases.


3.2.3  Installing Over DB2 V2.1.0, DDCS V2.3.0 Products or the DB2
Beta V2.1.1

If you have instances which have been created with any of the DB2
V2.1.0 or DDCS V2.3.0 products or the Beta V2.1.1 then you will need
to perform the following steps:

1.  Logon as root

2.  Make the directory /usr/lib/db2/V2.1/instance

3.  Move /usr/lpp/db2_02_01/instance/db2idir to
    /usr/lib/db2/V2.1/instance/db2idir

4.  For each instance:

    o   Logon as sysadm for the instance
    o   Stop all your DB2 applications
    o   Stop the database manager (db2stop)
    o   Stop the DB2 license daemon (issue the db2licd end command)
    o   Stop all command line processor sessions (Issue a db2
        terminate command for in each session that was running the
        command line processor. This step has to be performed by every
        user that has an active session that has used the command line
        processor).

Logon as root and do the following:

1.  Run the /usr/sbin/slibclean command

2.  If the 2.1.1. Beta driver is installed then it is recommended that
    you de-install the Beta driver first before installing the 2.1.1
    code.

    NOTE:  On AIX 3.2 systems, if the Beta driver is in COMMITTED
    state, you will need to FORCE APPLY the Beta driver first before
    you can REJECT it.

    If you have a DB2 V2.1.0 or a DDCS V2.3.0 product installed then
    you can either de-install these products first or you can install
    the new DB2 V2.1.1 or DDCS V2.3.1 products on top of them.

    NOTE:  On AIX 3.2 systems, if the DB2 V2.1.0 or DDCS V2.3.0
    products are in APPLIED state then you must either REJECT or
    COMMIT them before you can install the new products (REJECTING the
    old versions is the recommended approach).

3.  Install the DB2 V2.1.1 and/or DDCS V2.3.1 Products using SMIT or
    installp

4.  For each instance on the machine run the command:

            /usr/lpp/db2_02_01/instance/db2iupdt instance

    (where instance is the name of the instance. You can get a list of
    all the instances on the machine by issuing the
    /usr/lpp/db2_02_01/instance/db2ilist command)


===============
4.  Usage Notes

4.1  Database Directory Utility


4.1.1  Linking to Online Books from Database Director Online Help

If you are using Database Director online help, and you try
double-clicking on a hypertext link in order to open an online book
but the book is not displayed (that is, you receive an error message),
it is possible that the online book has not been installed.  You may
need to install the English version of the book if it has not been
translated or the BOOKSHELF environment variable has not been set.

NOTE:   If the book is not translated and you wish to view the English
version, update the value of the environment variable BOOKSHELF to
include:

      /usr/lpp/db2_02_01/doc/%L:/usr/lpp/db2_02_01/doc/En_US

Where %L represents the language locale you selected in the initial
installation of online books.


4.1.2  If Problems are Encountered when Running the Database Director

If the Database Director program cannot be loaded, the problem may be
caused by the setting of the LIBPATH environment variable.  If this
problem occurs one solution is to unset the LIBPATH environment
variable by issuing the command:

    unset LIBPATH

before running the Database Director again.

If you are running another application in the same window as the
Database Director and the other application requires you to set
LIBPATH, then you can open another window and run the Database
Director from the newly open window (make sure you issue the command
"unset LIBPATH" in the new window).


4.1.3  DBCS Environment

If you are running AIX Version 4.1.3 in the DBCS environment,
selecting the Cancel pushbutton from some Database Director windows
may result in abnormal ending of your application.  This problem is
referenced in APAR #IX55448, and is fixed with PTF U441217.


4.2  Roll Forward and Log File Size

If the log file size (LOGFILSIZ) was modified during the course of
normal processing, then database level roll forward through these log
files will behave as follows:

On any invocation of roll forward, only log files with the same log
file size will be processed.  When roll forward encounters a log file
of different size (excluding truncated log files), roll forward
processing will stop and return error SQL1042N.  Diagnostic
information will be logged.  You will then be required to re-issue the
roll forward command to continue processing from the next log file.


4.3  Using DCE Directories on AIX 4.1 Systems

To use DCE Directory Services with DB2 on an AIX 4.1 system the AIX
4.1 system must be at level AIX 4.1.4 or higher and dce.pthreads.rte
must be installed.

If DB2 is installed on a system which is below level AIX 4.1.4 or it
is installed on an AIX 4.1.4 or higher system that does not have
dce.pthreads.rte installed and you later decide that you want to use
DCE Directory Services with DB2 on an AIX 4.1 system then you must do
the following:

For each instance on the machine

1.  Logon as sysadm for the instance

2.  Stop all your DB2 applications

3.  Stop the database manager (db2stop)

4.  Stop the DB2 license daemon (issue the db2licd end command)

5.  Stop all command line processor sessions (Issue a db2 terminate
    command for in each session that was running the command line
    processor. This step has to be performed by every user that has an
    active session that has used the command line processor).

Logon as root and do the following:

1.  Run the /usr/sbin/slibclean command

2.  Upgrade your AIX 4.1 system to level AIX 4.1.4 or higher and
    ensure that you also install the optional DCE Threads
    Compatibility Library (dce.pthreads.rte)

3.  Run the command:

            /usr/lpp/db2_02_01/cfg/db2cfgos

4.  For each instance on the machine run the command:

            /usr/lpp/db2_02_01/instance/db2iupdt instance

    (where instance is the name of the instance. You can get a list of
    all the instances on the machine by issuing the
    /usr/lpp/db2_02_01/instance/db2ilist command)

User C/C++ applications that read DB2 database or database locator or
routing information objects from the DCE directory services on AIX
4.1.4, need to relink using the xlc_r4 or xlC_r4 command.

The following is the error returned by the application if it is not
relinked:

  The DCE Compatibility Library was not initialized.
  The application may not have been compiled with the correct
  compiler (cc_r4/xlc_r4).

NOTE:  There are no limitations on AIX 3.2.


4.4  Import/Load APIs

The following are changes to the import API:

o   Additional information is stored in IXF files to be used by import
    with the CREATE option.  If you specify a select statement of the
    format "SELECT * FROM tablename" on export, the following
    information will also be retrieved and stored in the IXF file:

    -   the default value for each column
    -   the original lob length even if the data is being truncated or
        the lobs are stored in individual files as specified with the
        LOBSINFILE option
    -   the user defined type.

    When the IXF file is used to create a new table, this new
    information will be used.

o   You can specify a target tablespace when issuing a import with the
    CREATE option.  New syntax allowed for the tcolstrg is:

      CREATE INTO tablename [(column_list)]
               [IN tablespace [INDEX IN indextblespace] [LONG IN longtblspace]]

    Note that to specify a tablespace for the indexes or long data,
    you must specify a tablespace for the table.

o   If you explicitly do not specify a source column for one of the
    target table columns, one of the following things will happen:

    -   if the column is defaultable, the default will be imported
    -   if the column is nullable and not defaultable, a NULL will be
        imported
    -   if the column is not nullable and not defaultable, an error
        will be returned and the utility will stop processing.

    Previously, if a source column was not provided, and if the column
    was nullable, a NULL would have been imported, but if the column
    was not nullable, an error would have been returned.  If the old
    behavior is desired, specify the NODEFAULTS option in the
    filetype-modifier.

The following is a change to both the import and load APIs:

o   A source column may be designated for a target table column but
    may be omitted for any given row instance.  Examples of missing
    data are:

    -   for DEL files, ",," is specified for the column
    -   for DEL/ASC/WSF files, a row that does not have enough columns
        or is not long enough for the original specification.

    In these cases, import/load was used to import/load a NULL if the
    column was nullable, and reject the row if the column is not
    nullable.  If the USEDEFAULTS option is specified in the
    filetype-modifier, the following will be the new behavior:

    -   if the column is defaultable, the default will be
        imported/loaded
    -   if the column is nullable and not defaultable, a NULL will be
        imported/loaded
    -   if the column is not nullable and not defaultable, the row
        will be rejected.

4.5  sqlestrd() API

Applications which use the sqlestrd() API to connect to databases must
change this to EXEC SQL CONNECT syntax if the application needs to
take advantage of using version 2 distributed unit of work features
specified by precompiler options.


4.6  Enabling IBM DB2-SMARTsort for DB2 LOAD

The following information applies to the use of DB2 LOAD to load a
table:

For AIX environments, the DB2-SMARTsort Accelerator provides improved
performance when compared to the current performance of DB2 LOAD with
Index Create without SMARTsort.

SMARTsort is designed to work with IBM's DB2 2.1.1 with the
appropriate service update.  When used in conjunction with DB2's LOAD
with Create Index function, SMARTsort can reduce the time it takes to
load a database, especially when processing large amounts of data.
Once SMARTsort is enabled under DB2, DB2 calls SMARTsort automatically
every time the LOAD with Index Create function is invoked.  All
programs, scripts or command line calls that use DB2 LOAD with Index
Create can take full advantage of the performance of SMARTsort.

NOTE:  See the SMARTsort Release 2 READ.ME file for specific service
       requirements.

Users also have the option to produce a log of all SMARTsort
invocations made by DB2, or, they can choose not to create such a log
and allow all DB2-to-SMARTsort calls to be transparent.  Either way,
DB2 Loads will be able to exploit the performance advantages of using
SMARTsort, without any additional set-up by the user.


4.6.1  Enabling SMARTsort under DB2

Any DB2 user who wishes to use SMARTsort, during DB2 LOAD with Index
Create processing, can enable its use by adding the DB2SORT
environmental variable to their .profile or db2profile file.  As with
other DB2 environmental variables, the DB2SORT environmental variable
must be exported before starting DB2.  It may also be necessary to
issue a 'db2stop' and 'db2start' command to stop and restart the
database manager.

  DB2SORT=SMARTSORT
  export DB2SORT

Figure 1. DB2SORT environmental variable

By exporting the optional DB2SORTLOG environmental variable (see
Figure 2), you can collect a log of all DB2 invocations of SMARTsort.
DB2SORTLOG should be set to the name of a directory that SMARTsort can
write to.  Each time DB2 invokes SMARTsort, SMARTsort makes an entry
to the smrtsort.log file, located in this directory.  For example:
DB2SORTLOG=/tmp would create a smrtsort.log file and a serverX.log
file, in a directory named /tmp.

If no directory name is specified, or an invalid directory name is
provided, no log file is created.

  DB2SORTLOG=/tmp
  export DB2SORTLOG

Figure 2. DB2SORTLOG environmental variable

The smrtsort.db2 file, located in /usr/lpp/smartsort (see Figure 3),
shows how the DB2SORT and DB2SORTLOG environmental variables can be
coded in a functioning Shell Script.  You can call this Script
directly from your db2profile or .profile file.

  #----------------------------------------------------------------
  # Licensed Materials: Property of IBM

  # 5765-349
  # (c) IBM Corporation 1994, 1996
  # All Rights Reserved
  #
  # NAME: smrtsort.db2
  #
  # DESCRIPTION: This partial script sample demonstrates how to
  # enable SMARTsort under DB2.
  #
  # USAGE: The contents of this script can be added to a user's
  # db2profile file to enable DB2's use of SMARTsort
  # during the LOAD operation.

  #
  # This script can also be invoked directly after
  # invoking the db2profile.
  #
  # A user may wish to copy this script into their
  # directory structure and customize it.
  #
  #-------------------------------------------------------------


  #-------------------------------------------------------------
  # DB2SORT Default=
  # is set to SMARTSORT to enable the use of SMARTsort during DB2
  # LOAD processing.
  #-------------------------------------------------------------
  DB2SORT=SMARTSORT
  export DB2SORT

  #-------------------------------------------------------------
  # DB2SORTLOG Default=
  # is set to a directory name in which SMARTsort is to create a
  # log file (called smrtsort.log). Each time SMARTsort is invoked
  # by DB2, SMARTsort will write a message to this log file. See
  # the SMARTsort Guide and Reference for more information.
  #----------------------------------------------------------------
  #DB2SORTLOG=/tmp

  #export DB2SORTLOG

Figure 3. Shell Script Coding for DB2SORT and DB2SORTLOG


4.6.1.1  Internal Information

There are two additional DB2 profile entries needed to activate the
use of DB2SORTLOG, they are:

   DB2SORTDEBUG=ON
   DB2SORTDATA=ON

If either of these entries are OFF, the DB2SORTLOG will not be used.


4.6.2  Disabling SMARTsort under DB2

To revert to the default DB2 sort when executing a DB2 LOAD, simply
reset the DB2SORT environment variable (see Figure 4).  Again, it may
be necessary to issue a 'db2stop' and a 'db2start' to stop and restart
the database manager.

  DB2SORT=
  export DB2SORT

Figure 4. Resetting the DB2SORT environmental variable


4.6.3  Programs

The SMARTsort Release 2 DB2-SMARTsort Accelerator is currently only
supported on AIX as follows:

1.  The minimum release level for AIX is 4.1.3

2.  If the DB2-SMARTsort Accelerator is to be used, then DB2 2.1.1 PTF
    U442530 is required.

3.  The required License Use Management run-time programs, and their
    pre-reqs, are shipped as part of the AIX operating system.  Check
    your AIX operating system to determine if the IBM SystemView
    License Use Management product, or the iFOR/LS product is
    installed on your system.


4.6.4  DB2

The DB2-SMARTsort Accelerator consists of SMARTsort Release 2 and PTF
U442530 for DB2 V2.1.1, which supports the new DB2SORT and DB2SORTLOG
parameters.


4.7  DARI and UDF Considerations for National Language-Specific
Processing

By default, DB2 DARI stored procedures and user defined functions,
when invoked, execute under a default national language environment
which may not match the database's.  Consequently, country or code
page specific operations, such as the use of C wchar_t graphic host
variables and functions, may not work as expected.  Application
developers need to ensure that, if applicable, the correct environment
is initialized when the stored procedure or UDF is invoked.


4.8  Package Name Considerations in Mixed Code Page Environments

Package names are generated as part of the invocation of the
PRECOMPILE PROGRAM command or API.  By default, they are generated
based on the first 8 bytes of the application program source file
(minus the extension and folded to upper case).  Optionally, a name
can be explicitly defined.  Regardless of the origin of the package
name attention should be paid in mixed code page environments to
ensure that the package name does become modified as result of
conversions between the application code page and the database code
page.  A modification due to character conversion will occur if any of
the characters in the package name (or fragments of a character in a
multi-byte code page ) are not directly mapped to a valid character in
the database code page.  In such cases a substitution character
replaces the unconverted character.  After such a modification, the
package name, when converted back to the application code page, may
not match the original.  An example of a case where this behavior is
undesirable would be while using the DB2 Database Director to list and
work with packages.  Package names displayed may not match expected
names.

To avoid conversion problems with package names ensure that only
characters are used which are valid under both the application and
database code pages.


4.9  Japanese and Traditional-Chinese EUC Code Page Environments


4.9.1  Mixed EUC/Double-Byte Client and Database Considerations

The administration of database objects in mixed EUC and double-byte
code page environments is complicated by the possible expansion or
contraction in the length of object names as a result of conversions
between the client and database code page. In particular, many
administrative commands and utilities have documented limits to the
lengths of character strings which they may take as input or output
parameters.  These limits are typically enforced at the client, unless
documented otherwise. For example, the limit for a table name is 18
bytes.  It is possible that a character string which is 18 bytes under
a double-byte code page is larger, say 21 bytes, under an EUC code
page.  This hypothetical 21-byte table name would be considered
invalid by such commands as REORGANIZE TABLE if used as an input
parameter despite being valid in the target double-byte database.
Similarly, the maximum permitted length of output parameters may be
exceeded, after conversion, from the database code page to the
application code page. This may cause either a conversion error or
output data truncation to occur.

If the extensive use of administrative commands and utilities is
expected in a mixed EUC and double-byte environment it is recommended
that database objects and associated data are defined with the
possibility of length expansion past supported limits, due to
conversion, kept in mind.  Administration of an EUC database from a
double-byte client will face less restrictions then administration of
a double-byte database from an EUC client.  The reason being that
double-byte character strings will always be equal in length or
shorter then the corresponding EUC character string.  This will
generally lead to less problems caused by character string length
limits being enforced.

Note: In the case of SQL statements, validation of input parameters is
not done until the entire statement has been converted to the database
code page.  This permits character strings to be used which may be
technically longer then allowed when represented in the client code
page but which meet length requirements when represented in the
database code page.

For more information concerning mixed code page environments refer to
the "Application Programming Guide" and the "SQL Reference".


4.9.2  Character Conversion Considerations for Traditional-Chinese
Users

A database or application running under the Traditional-Chinese EUC
code page will actually store and manipulate graphic data using the
ISO 10646 UCS-2 code set, a double-byte encoding scheme which is a
proper subset of the full ISO 10646 Unicode standard.  As part of the
standards definition for Traditional-Chinese, there is a side effect
which will be encountered when converting some characters between
double-byte or EUC code pages and UCS-2. There are 189 characters (187
radicals, 2 numbers) which share the same UCS-2 code point, when
converted, as another character in the code set. When these characters
are converted back to double-byte or EUC they will be converted to the
code point of the same character's ideograph, with which it shared the
same UCS-2 code point, rather then back to the original code point.
The character, when displayed, appears the same but is encoded
differently.  Depending on the design of your application, this
behavior may need to be taken into account.

The tables below list the EUC (code page 964) and double-byte (code
page 950) code points which, when converted to UCS-2 and then back to
the original code set, will experience this behavior.  Each entry in
the table is composed of three columns, for example the first entry in
the table for code page 964 is:

       (1)     (2)     (3)
       964 -> UCS-2 -> 964
       ----   ------   --------
       a7a1   4e00     c4a1

Each column contains the hexadecimal encoding of a code point
belonging to the code set/code page indicated by the column title:

o   Column (1) contains the original character's code point, read as
    x'a7a1', under code page 964 (Traditional-Chinese EUC).

o   Column (2) contains the code point, read as x'4e00', of the
    character in column (1) as represented under the UCS-2 code set.
    The arrow, '->', indicates the flow of conversion.  x'a7a1', when
    converted to UCS-2, is x'4e00'.

o   Column (3) contains the code point, read as x'c4a1', of the
    character in column (2) as represented under code page 964.  The
    arrow, '->', indicates the flow of conversion.  x'4e00', when
    converted to Traditional-Chinese EUC, is x'c4a1'.

Note:  For more detailed information concerning the usage of UCS-2 and
EUC refer to the "DB2 for AIX Installation and Operation Guide" and
the "Application Programming Guide".


4.9.2.1  Code Page 964 (Traditional-Chinese EUC)

  964 -> UCS-2 -> 964         964 -> UCS-2 -> 964         964 -> UCS-2 -> 964
  ----   -----    --------    ----   -----    --------    ----   -----    --------
  a4be   5341     c4b2        a7f4   6c34     c5d5        a8d7   8c37     cbc7
  a4c0   5345     c5ab        a7f5   706b     c5d6        a8d8   8c46     cbc8
  a7a1   4e00     c4a1        a7f6   722a     c5d7        a8d9   8c55     cbc9
  a7a5   4e59     c4a2        a7f7   7236     c5d8        a8da   8c78     8ea2a5a4
  a7a7   4e8c     c4a8        a7f8   723b     c5d9        a8db   8c9d     cbca
  a7a9   4eba     c4a9        a7f9   723f     8ea2a1c2    a8dc   8d64     cbcb
  a7aa   513f     c4aa        a7fa   7247     c5da        a8dd   8d70     cbcc
  a7ab   5165     c4ab        a7fb   7259     c5db        a8de   8db3     cbcd
  a7ac   516b     c4ac        a7fc   725b     c5dc        a8df   8eab     cbce
  a7b0   51e0     c4ad        a7fd   72ac     c5dd        a8e0   8eca     cbcf
  a7b1   51f5     8ea2a1a3    a7fe   7384     c6e8        a8e1   8f9b     cbd0
  a7b2   5200     c4ae        a8a1   7389     c6e9        a8e2   8fb0     cbd1
  a7b3   529b     c4b0        a8a2   74dc     c6ea        a8e4   9091     cbd7
  a7b5   5315     c4b1        a8a3   74e6     c6eb        a8e5   9149     cbdc
  a7b6   531a     8ea2a1a4    a8a4   7518     c6ec        a8e6   91c6     cbdd
  a7b8   5341     c4b2        a8a5   751f     c6ed        a8e7   91cc     cbde
  a7b9   535c     c4b3        a8a6   7528     c6ee        a8e8   91d1     cfda
  a7bb   5382     8ea2a1a5    a8a7   7530     c6f0        a8e9   9577     cfdb
  a7bd   53c8     c4b4        a8a8   758b     c6f4        a8ea   9580     cfdc
  a7be   53e3     c4c7        a8ab   767d     c6f5        a8eb   961c     cfdd
  a7bf   56d7     8ea2a1aa    a8ac   76ae     c6f6        a8ed   96b9     cfe3
  a7c0   571f     c4c8        a8ad   76bf     c6f7        a8ee   96e8     cfe4
  a7c1   58eb     c4c9        a8ae   76ee     c6f8        a8ef   9752     cfe5
  a7c3   5915     c4ca        a8af   77db     c6f9        a8f0   975e     cfe6
  a7c4   5927     c4cb        a8b0   77e2     c6fa        a8f1   9762     d3f2
  a7c5   5973     c4cc        a8b1   77f3     c6fb        a8f2   9769     d3f3
  a7c6   5b50     c4cd        a8b2   793a     c6fc        a8f3   97cb     d3f4
  a7c8   5bf8     c4d0        a8b3   79b8     8ea2a1e7    a8f4   97ed     d3f5
  a7c9   5c0f     c4d1        a8b4   79be     c6fd        a8f5   97f3     d3f6
  a7ca   5c22     c4d2        a8b5   7a74     c6fe        a8f6   9801     d3f7
  a7cb   5c38     c4d3        a8b6   7acb     c7a1        a8f7   98a8     d3f8
  a7cc   5c6e     8ea2a1ab    a8b7   7af9     c8cc        a8f8   98db     d3f9
  a7cd   5c71     c4d4        a8b8   7c73     c8cd        a8f9   98df     d3fa
  a7cf   5de5     c4d6        a8b9   7cf8     c8ce        a8fa   9996     d3fb
  a7d0   5df1     c4d7        a8ba   7f36     c8cf        a8fb   9999     d3fc
  a7d1   5dfe     c4da        a8bb   7f51     8ea2a2e9    a8fc   99ac     d8eb
  a7d2   5e72     c4db        a8bc   7f8a     c8d0        a8fd   9aa8     d8ec
  a7d6   5efe     c4dc        a8bd   7fbd     c8d1        a8fe   9ad8     d8ed
  a7d7   5f0b     c4dd        a8be   8001     c8d2        a9a1   9adf     8ea2b3cc
  a7d8   5f13     c4de        a8bf   800c     c8d4        a9a2   9b25     d8ee
  a7db   5f73     8ea2a1ac    a8c0   8012     c8d5        a9a3   9b2f     8ea2b3cd
  a7dc   5fc3     c5c0        a8c1   8033     c8d6        a9a4   9b32     d8ef
  a7dd   6208     c5c1        a8c2   807f     c8d7        a9a5   9b3c     d8f0
  a7de   6236     c5c2        a8c3   8089     c8d8        a9a6   9b5a     dea3
  a7df   624b     c5c3        a8c4   81e3     c8db        a9a7   9ce5     dea4
  a7e0   652f     c5c5        a8c5   81ea     c8dc        a9a8   9e75     dea5
  a7e2   6587     c5c6        a8c6   81f3     c8dd        a9a9   9e7f     dea6
  a7e3   6597     c5c7        a8c7   81fc     c8de        a9aa   9ea5     dea7
  a7e4   65a4     c5c8        a8c8   820c     c8df        a9ab   9ebb     dea8
  a7e5   65b9     c5c9        a8c9   821b     c8e0        a9ac   9ec3     e3a7
  a7e7   65e5     c5ca        a8ca   821f     c8e1        a9ad   9ecd     e3a8
  a7e8   66f0     c5cb        a8cb   826e     c8e2        a9ae   9ed1     e3a9
  a7e9   6708     c5cc        a8cc   8272     c8e3        a9af   9ef9     8ea2c1d5
  a7ea   6728     c5cd        a8cd   8278     8ea2a2ea    a9b0   9efd     8ea2c8f5
  a7eb   6b20     c5ce        a8ce   864d     8ea2a2ef    a9b1   9f0e     e7ef
  a7ec   6b62     c5cf        a8cf   866b     c8e5        a9b2   9f13     e7f0
  a7ed   6b79     c5d0        a8d0   8840     c8e6        a9b3   9f20     e7f1
  a7ee   6bb3     8ea2a1bf    a8d1   884c     c8e7        a9b4   9f3b     ebfc
  a7ef   6bcb     c5d1        a8d2   8863     c8e8        a9b5   9f4a     ebfd
  a7f0   6bd4     c5d2        a8d3   897e     8ea2a2f0    a9b6   9f52     f0af
  a7f1   6bdb     c5d3        a8d4   898b     cbc4        a9b7   9f8d     f3be
  a7f2   6c0f     c5d4        a8d5   89d2     cbc5        a9b8   9f9c     f3bf
  a7f3   6c14     8ea2a1c1    a8d6   8a00     cbc6        a9b9   9fa0     8ea2e1c2


4.9.2.2  Code Page 950 (Traditional-Chinese Big-5)


  950 -> UCS-2 -> 950         950 -> UCS-2 -> 950         950 -> UCS-2 -> 950
  ----   -----    ----        ----   -----    ----        ----   -----    ----
  a2cc   5341     a451        f59f   6c34     a4f4        f79e   8c37     a8a6
  a2ce   5345     a4ca        f5a0   706b     a4f5        f79f   8c46     a8a7
  f481   4e00     a440        f681   722a     a4f6        f7a0   8c55     a8a8
  f483   4e59     a441        f682   7236     a4f7        f881   8c78     cba4
  f484   4e8c     a447        f683   723b     a4f8        f882   8c9d     a8a9
  f485   4eba     a448        f684   723f     c962        f883   8d64     a8aa
  f486   513f     a449        f685   7247     a4f9        f884   8d70     a8ab
  f487   5165     a44a        f686   7259     a4fa        f885   8db3     a8ac
  f488   516b     a44b        f687   725b     a4fb        f886   8eab     a8ad
  f489   51e0     a44c        f688   72ac     a4fc        f887   8eca     a8ae
  f48a   51f5     c942        f689   7384     a5c8        f888   8f9b     a8af
  f48b   5200     a44d        f68a   7389     a5c9        f889   8fb0     a8b0
  f48c   529b     a44f        f68b   74dc     a5ca        f88a   9091     a8b6
  f48d   5315     a450        f68c   74e6     a5cb        f88b   9149     a8bb
  f48e   531a     c943        f68d   7518     a5cc        f88c   91c6     a8bc
  f48f   5341     a451        f68e   751f     a5cd        f88d   91cc     a8bd
  f490   535c     a452        f68f   7528     a5ce        f88e   91d1     aaf7
  f491   5382     c944        f690   7530     a5d0        f88f   9577     aaf8
  f492   53c8     a453        f691   758b     a5d4        f890   9580     aaf9
  f493   53e3     a466        f692   767d     a5d5        f891   961c     aafa
  f494   56d7     c949        f693   76ae     a5d6        f892   96b9     ab41
  f495   571f     a467        f694   76bf     a5d7        f893   96e8     ab42
  f496   58eb     a468        f695   76ee     a5d8        f894   9752     ab43
  f497   5915     a469        f696   77db     a5d9        f895   975e     ab44
  f498   5927     a46a        f697   77e2     a5da        f896   9762     adb1
  f499   5973     a46b        f698   77f3     a5db        f897   9769     adb2
  f49a   5b50     a46c        f699   793a     a5dc        f898   97cb     adb3
  f49b   5bf8     a46f        f69a   79b8     c9a8        f899   97ed     adb4
  f49c   5c0f     a470        f69b   79be     a5dd        f89a   97f3     adb5
  f49d   5c22     a471        f69c   7a74     a5de        f89b   9801     adb6
  f49e   5c38     a472        f69d   7acb     a5df        f89c   98a8     adb7
  f49f   5c6e     c94b        f69e   7af9     a6cb        f89d   98db     adb8
  f4a0   5c71     a473        f69f   7c73     a6cc        f89e   98df     adb9
  f581   5de5     a475        f6a0   7cf8     a6cd        f89f   9996     adba
  f582   5df1     a476        f781   7f36     a6ce        f8a0   9999     adbb
  f583   5dfe     a479        f782   7f51     ca49        f981   99ac     b0a8
  f584   5e72     a47a        f783   7f8a     a6cf        f982   9aa8     b0a9
  f585   5efe     a47b        f784   7fbd     a6d0        f983   9ad8     b0aa
  f586   5f0b     a47c        f785   8001     a6d1        f984   9adf     d449
  f587   5f13     a47d        f786   800c     a6d3        f985   9b25     b0ab
  f588   5f73     c94c        f787   8012     a6d4        f986   9b2f     d44a
  f589   5fc3     a4df        f788   8033     a6d5        f987   9b32     b0ac
  f58a   6208     a4e0        f789   807f     a6d6        f988   9b3c     b0ad
  f58b   6236     a4e1        f78a   8089     a6d7        f989   9b5a     b3bd
  f58c   624b     a4e2        f78b   81e3     a6da        f98a   9ce5     b3be
  f58d   652f     a4e4        f78c   81ea     a6db        f98b   9e75     b3bf
  f58e   6587     a4e5        f78d   81f3     a6dc        f98c   9e7f     b3c0
  f58f   6597     a4e6        f78e   81fc     a6dd        f98d   9ea5     b3c1
  f590   65a4     a4e7        f78f   820c     a6de        f98e   9ebb     b3c2
  f591   65b9     a4e8        f790   821b     a6df        f98f   9ec3     b6c0
  f592   65e5     a4e9        f791   821f     a6e0        f990   9ecd     b6c1
  f593   66f0     a4ea        f792   826e     a6e1        f991   9ed1     b6c2
  f594   6708     a4eb        f793   8272     a6e2        f992   9ef9     dcb0
  f595   6728     a4ec        f794   8278     ca4a        f993   9efd     e0ef
  f596   6b20     a4ed        f795   864d     ca4f        f994   9f0e     b9a9
  f597   6b62     a4ee        f796   866b     a6e4        f995   9f13     b9aa
  f598   6b79     a4ef        f797   8840     a6e5        f996   9f20     b9ab
  f599   6bb3     c95f        f798   884c     a6e6        f997   9f3b     bbf3
  f59a   6bcb     a4f0        f799   8863     a6e7        f998   9f4a     bbf4
  f59b   6bd4     a4f1        f79a   897e     ca50        f999   9f52     bea6
  f59c   6bdb     a4f2        f79b   898b     a8a3        f99a   9f8d     c073
  f59d   6c0f     a4f3        f79c   89d2     a8a4        f99b   9f9c     c074
  f59e   6c14     c961        f79d   8a00     a8a5        f99c   9fa0     efb6


4.9.3  DDCS-Specific Prerequisites and Limitations

In order to support connectivity between a DDCS for AIX workstation
running under a Japanese or Traditional-Chinese EUC environment and a
DB2 for MVS DRDA application server one of the following DB2 for MVS
PTFs must be applied:

o   DB2 for MVS Version 3.1, fix for APAR PN77480 (PTF number not
    available at time of writing)

o   DB2 for MVS Version 4.1, fix for APAR PN77480 (PTF number not
    available at time of writing)

Note:  Connectivity is not supported between DDCS for AIX workstations
running under Japanese or Traditional-Chinese EUC environments and the
following DRDA application servers:

DB2 for OS/400
DB2 for VM and VSE


==============================
5.  Environment Considerations

5.1  Copying a Shared Library

On occasion, a problem may occur when attempting to replace either a
stored procedure or a user-defined function shared library, with the
copy operation failing.  This is because AIX keeps a cache of
referenced libraries and does not allow the library to be overwritten.

One solution is to run /usr/sbin/slibclean to flush the AIX shared
library cache.  Another solution is to remove the library from the
target directory and then copy the library from the source directory
to the target directory.


5.2  Receiving Error Message -30081 when Using the TCP/IP Protocol

When using the TCP/IP protocol, you may occasionally receive a -30081
error message with the first errno token = ETIMEDOUT on a CONNECT
request.  This is a result of the server handling too many incoming
connection requests, or a very busy network.  When an application
receives this error, it should pause for a short time and then try the
connection again.


=========================
6.  Communications Issues

6.1  TCP/IP

If an application attempting a CONNECT to the server using the TCP/IP
protocol receives a -30081 error message with the first error token
containing a value of ETIMEDOUT (10060, 78, 145, 238) or EADDRINUSE
(10048, 67, 125, 226), or ECONNREFUSED (10061, 79, 146, 239); these
errors indicate that the server is handling too many incoming
connection requests or that the network is very busy.  The application
should pause for a short time then attempt the connection again.

Also, in the case where ECONNREFUSED is received, check that TCP/IP
support at the database server has been successfully started.

If you encounter EADDRINUSE errors during CONNECT, one of the
following fixes should be applied for APAR #IX41367:

PTF U435180
   or
PMP 3251 (PTF U493251)


=====================
7.  Programming Notes

7.1  Sample Applications

The following files contain information about the sample applications
which are used in the DB2 publications.  The sample applications will
only be useful to you if you have the DB2 Software Developer's Kit or
DB2 Single-User package for your platform installed.

    samples/c/README

        README file for the c sample applications.

    samples/cobol/README

        README file for the COBOL sample applications.

    samples/fortran/README

        README file for the FORTRAN sample applications.

    samples/rexx/README

        README file for the REXX sample applications.

    samples/cli/README

        README file for the Call Level Interface sample applications.

    samples/cli/INTCLI.DOC

        Documentation for the Interactive Call Level Interface applet.

    samples/clp/README

        README file for the Command Line Processor examples.


7.2  Considerations when Using Micro Focus COBOL

DB2 v2.1.1 has been modified to correctly handle abnormal termination
of Micro Focus COBOL applications compiled with the DB2 PREP command.
This ensures that partial transactions are rolled back in the event of
an error.

It is strongly recommended that any existing DB2 applications
precompiled with DB2 PREP and compiled with Micro Focus COBOL be
re-precompiled with the updated DB2 v2.1.1 precompiler, and then
re-compiled with Micro Focus COBOL.  If applications built with Micro
Focus COBOL and the IBM precompiler from a previous release/ version
are not rebuilt, there is a danger of database corruption if abnormal
termination occurs.

This support requires Micro Focus COBOL v3.2.

Once the necessary version of the Micro Focus compiler is available,
add the db2gmf library (-ldb2gmf) to your compile/link command as
follows (AIX):

    cob -x -o app app.cbl -ldb2 -ldb2gmf -L/usr/lpp/db2_02_01/lib

For stored procedures, the same new argument (-ldb2gmf) is added to
the compile/link command (AIX):

    cob -x -o app app.cbl -Q -H512 -Q -T512 -Q -e app \
        -Q -bE:app.exp -ldb2 -ldb2gmf -L/usr/lpp/db2_02_01/lib

Compile/line commands for other UNIX platforms are modified similarly,
by adding -ldb2gmf.

7.2.1  Updating the Micro Focus COBOL Runtime System

DB2 v2.1.1 for UNIX platforms provides an updated
sqllib/lib/db2mkrts.args file. This requires that the Micro Focus
COBOL runtime system, rts32, be rebuilt.  Follow the instructions for
building the Micro Focus COBOL runtime system under 'Developing
Applications with Micro Focus COBOL' in the DB2 Installation Guide.


7.2.2  Configuring CICS for Use With DB2 2.1.1 and Micro Focus COBOL
on UNIX Platforms

DB2 v2.1.1 requires changes in the way CICS is configured for use with
Micro Focus COBOL and DB2.   The object file sqlgmf.o contained in the
/usr/lpp/db2_02_01/lib/libdb2gmf.a archive needs to be extracted, and
used in the construction of the CICS runtime system.  Referring to the
CICS Administration Guide, perform the steps as documented under 'C
Transaction Support for DATABASE 2', if you have not already done so.
Then execute the following commands:

      cd /usr/lpp/db2_02_01/lib
      ar -vx libdb2gmf.a
      ln -s /usr/lpp/db2_02_01/lib/sqlgmf.o /usr/lib/db2gmf.o

Then, perform the steps under 'COBOL Transaction Support for DATABASE
2' in the CICS Administration Guide, with the following change.  Where
you are instructed to run cicsmkcobol to regenerate cicspsCOBOL, use
the following command instead of the one documented in the CICS
Administration Guide:

      cicsmkcobol /usr/lib/db2.o /usr/lib/db2gmf.o

This adds the sqlgmf API to the cicsprCOBOL runtime, allowing
applications precompiled with the DB2 v2.1.1 COBOL precompiler to
function correctly with CICS.


7.3  BINARY/COMP-4 COBOL Data Types in the DB2 Precompiler

The DB2 Precompiler supports use of BINARY, COMP-4 and COMP COBOL data
types wherever integer host variables and indicators are permitted, as
long as the target COBOL compiler views (or can be made to view)
BINARY/COMP-4/COMP as equivalent to COMP-5.  In the DB2 Application
Programming Guide, such host variables and indicators are shown with
type COMP-5.  Target compilers supported by DB2 which treat
BINARY/COMP-4/COMP and COMP-5 as equivalent are:

  IBM COBOL Set for AIX
  Micro Focus COBOL for AIX
  IBM COBOL Visual Set for OS/2 (with the -qbinary(native)
    option set)


7.4  Using REDEFINES in COBOL Group Data Items

The REDEFINES clause may be used when declaring host variables with
the DB2 COBOL precompiler.  If a member of a group data item is
declared with the REDEFINES clause, and that group data item is
referred to as a whole in an SQL statement, any subordinate items
containing the REDEFINES clause will not be expanded.  For example:

  01 foo.
      10 a pic s9(4) comp-5.
      10 a1 redefines a pic x(2).
      10 b pic x(10).

Referring to foo in an SQL statement like so:

      ... INTO :foo ...

is equivalent to

      ... INTO :foo.a, :foo.b ...

That is, the subordinate item a1 with the REDEFINES is not
automatically expanded out in such situations.  A subordinate with a
REDEFINES may be referred to in an SQL statement explicitly, as in

      ... INTO :foo.a1 ...
or
      ... INTO :a1 ...

if a1 is unambiguous.


7.5  Running DB2 for AIX COBOL Stored Procedures

Because of the way AIX loads stored procedures and resolves library
references within them, there are generally requirements on how
language products like COBOL should be installed.  When you are
running a normal executable, COBOL for example, these requirements are
not a factor.  They are, however, when it is a shared object (stored
procedure) being loaded on the fly.

When a stored procedure is loaded, the chain of libraries it refers to
must also be loaded.  When AIX searches for a library only indirectly
referenced by your program, it must use the path compiled into the
library that referenced it when it was built by the language provider
(in this case, Micro Focus** COBOL or the IBM COBOL group.)  This path
may very well not be the same path in which the compiler was
installed.  (If a library in the chain cannot be found, the stored
procedure load will fail, and you receive a -10013 sqlcode.)

To solve this problem, you can install the compiler wherever you want,
but you should then create symbolic links of all language libraries
from the install directory into /usr/lib (a directory which is almost
always searched when a library needs to be loaded.)  You could link
the libraries into sqllib/function (the stored procedure directory),
but this only works for one database instance.  /usr/lib works for
everyone on the machine.  Also, copying the libraries in is not
advised, especially for Micro Focus COBOL, since there may be problems
when multiple copies of the libraries exist.

A sample symbolic link of Micro Focus COBOL is provided below
(assuming it is installed in /usr/lpp/cobdir):

   [1] su root
   [2] cd /usr/lib
   [3] ln -sf /usr/lpp/cobdir/coblib/*.a .


7.6  Building Micro Focus COBOL Stored Procedures on AIX

In order to build stored procedures with Micro Focus COBOL v3.2 for
AIX, "-B static" and "-Q -bI:" options must be added to the command
line, and "-ldb2" must be removed, relative to what is shown in the
Software Developer's Kit for AIX, Building Your Applications manual.

Below are shown the modified commands to build the server portion of
the inpcli/inpsrv sample client/server pair:

    db2 connect to sample
    db2 prep inpsrv.sqb
    cob -xc inpsrv.cbl
    cob -x -o inpsrv inpsrv.o -Q -e inpsrv -Q -bE:inpsrv.exp \
      -Q -bI:$HOME/sqllib/lib/db2g.imp -B static \
      -L$HOME/sqllib/lib


7.7  Precompiler Customization

If you are writing your own precompiler interface to DB2 Precompiler
Services, you should be aware that the program_id parameter to
sqlainit() must indicate static storage.  This storage is referred to
by the Precompiler Services functions sqlaalhv() and sqlacmpl() during
precompilation.  The program_id storage must remain accessible and
undisturbed until Precompiler Services has been terminated with a call
to sqlafini().


7.8  Considerations When Using REXX Stored Procedures

When using host variables in the CALL statement, each host variable
must be initialized to a value compatible in type with the data that
is returned into it from the server procedure (if any). It should be
done even if the corresponding indicator is negative.  When using
descriptor, SQLDATA must be initialized and contain data compatible in
type with the data that is returned from the server procedure (if
any). It should be done even if the SQLIND field contains negative
value.  (See also OUTCLI.CMD example in the Application Programming
Guide for common servers).


===================
8.  AIX ODBC Driver

An AIX ODBC driver is now shipped as part of the DB2/6000 V2.1.1 CAE
component.  This driver will inter-operate with Visigenic Software's
ODBC 2.0 for AIX Driver Manager, Version 1.1.

For more information, see the Installing and Using AIX Clients book.


8.1  Common Application Problems and Work Arounds

The Patch1 keyword (specified in the sqllib\cfg\db2cli.ini file) is
used to specify work arounds for specific application problems.  There
are currently no work arounds that apply to AIX ODBC applications.

NOTE:  Most ODBC applications do not support LOB data types and
require the LONGDATACOMPAT keyword to be set to 1.


8.2  SQLDescribeParam()

With this release of DB2 v2.1.1, the DB2 CLI/ODBC function call
SQLDescribeParam() is now supported. This function returns the
description of a parameter marker associated with a prepared SQL
statement. You will receive an SQLSTATE of S1C00 - 'Driver not
capable' if you attempt to run this command against any DB2 common
server before this release of 2.1.1, or against a DRDA data source.

One output of the SQLDescribeParam() function indicates whether the
parameter allows NULL values. Currently the DB2 CLI/ODBC driver always
returns SQL_NULLABLE_UNKNOWN.

SQLGetFunctions() will not correctly indicate whether
SQLDescribeParam() is available.  Until you run either SQLPrepare() or
SQLExecDirect(), SQLGetFunctions() will always return TRUE (always
indicating that SQLDescribeParam() is available). Once you run either
of these two functions, SQLGetFunctions() will correctly indicate
whether SQLDescribeParam() is supported, based on the version of your
DB2 server.

See the new db2cli.ini keyword 'DescribeParam' for details on enabling
or disabling this new CLI/ODBC function when connecting to DB2 v2.1.1
servers.


8.3  New CLI/ODBC Configuration Keywords in db2cli.ini

The following ODBC configuration keywords were not described in the
book:

CURRENTFUNCTIONPATH = CURRENT_FUNCTION_PATH
    This keyword defines the path used to resolve function references
    and data type references that are used in dynamic SQL statements.
    It contains a list of one or more schema-names, where schema-names
    are enclosed in double quotes and separated by commas.

    The default value is "SYSIBM","SYSFUN",X where X is the value of
    the USER special register delimited by double quotes.  The schema
    SYSIBM does not need to be specified.  If it is not included in
    the function path then it is implicitly assumed as the first
    schema.

    This keyword is used as part of the process for resolving
    unqualified function references that may have been defined in a
    schema name other than the current users' schema.  The order of
    the schema names determines the order in which the function names
    will be resolved.  For more information on function resolution,
    refer to the SQL Reference guide.

MULTICONNECT = 0 | 1
    This keyword is used to specify how "SQLConnect()" requests are
    mapped to physical database connections.

        0 = false

        Each "SQLConnect()" request by the application will result in
        a physical database connection.

        1 = true

        All connections for the application are mapped to one physical
        connection.

        This may be used if the ODBC application runs out of file
        handles because it uses so many connections.

    NOTE:  If MULTICONNECT is set to true then all statements are
    executed on the same connection and therefore in the same
    transaction.  This means that a rollback will rollback ALL
    statements on all connections.  Be sure that the application is
    designed to work with MULTICONNECT set to true before doing so or
    the application may not operate correctly.

OPTIMIZEFORNROWS = INTEGER
    This keyword will append the "OPTIMIZE FOR n ROWS" clause to every
    select statement, where n is an integer larger than 0.  The
    default action is not to append this clause.

    For more information on the effect of the OPTIMIZE FOR n ROWS
    clause, refer to the SQL Reference guide.

IGNOREWARNINGS = 0 | 1

        0 = Warnings reported as usual (default).

        1 = All warnings are ignored, SQL_SUCCESS is returned.

    Use this keyword if an application does not handle warnings
    properly.


8.3.1  CLI/ODBC Trace File

The DB2 CLI/ODBC driver can now write the details of all function
calls to a trace file which can be sent to IBM support to help resolve
problems. A programmer familiar with the workings of CLI/ODBC could
also look at this file to gain a better understanding of program
execution.

Three additional keywords in the db2cli.ini have been added to
facilitate this function. They are located in the [COMMON] section in
the initialization file:

o   Trace = 1 (on) or 0 (off) - defaults to 0

o   TraceFileName = <full file name>

    If the file does not exist then it will be created, otherwise the
    new trace information will be appended to the end of the file.

    No trace will occur, and no error message will be returned, if the
    filename given is invalid or if the file cannot be created or
    written to.

o   TraceFlush = 1 (on) or 0 (off) - defaults to 0

    Set this keyword to 1 to force a write to disk after each Trace
    entry.  This will slow down the trace process, but will ensure
    that each entry is written to disk before the program continues to
    the next statement.

For example, the following settings in the db2cli.ini file will write
all details of DB2 CLI/ODBC function calls to a file called
C:\TRACE\MONDAY.TRC after each is executed.

  [COMMON]
  ...
  Trace=1
  TraceFileName=C:\TRACE\MONDAY.TRC
  TraceFlush=1


8.3.2  Specifying a Directory for Temporary Files

When working with Large Objects (CLOBS, BLOBS, etc...), a temporary
file is often created on the client machine to store the information.
It is possible that in some cases the system temporary directory
setting will not be used. The db2cli.ini keyword 'TempDir' has been
created to ensure that the DB2 CLI/ODBC driver manager selects an
appropriate path.

The keyword is placed in the datasource specific section of the
db2cli.ini file, and has the following syntax:

o   TempDir=<full path name>

    When a Large Object is accessed, an SQLSTATE of S1507 will be
    returned if the path name is invalid, or if the temporary files
    cannot be created in the directory specified.


8.3.3  SQLDescribeParam() Enable/Disable

The keyword 'DescribeParam' has been added to allow you to enable or
disable the new SQLDescribeParam() function. The keyword is placed in
the datasource specific section of the db2cli.ini file, and has the
following syntax:

o   DescribeParam = 0 or 1 (defaults to 0)

    0 = Disable SQLDescribeParam() - default

    1 = Enable SQLDescribeParam()

This keyword has the following effect based on the version of the DB2
server you are connecting to:

o   DB2 server before 2.1.1

    Keyword has no effect

    -   SQLGetFunctions() will indicate that SQLDescribeParam() is not
        supported
    -   if you call SQLDescribeParam() it will return SQLSTATE S1C00 -
        'Driver not capable'

o   DB2 server version 2.1.1, up to but not including this National Language
    version.

    Set DescribeParam = 0 to avoid errors if your application does
    call SQLDescribeParam(). This will:

    -   disable the SQLDescribeParam() function (if you call
        SQLDescribeParam() it will return SQLSTATE S1C00 - 'Driver not
        capable')
    -   have SQLGetFunctions() indicate that SQLDescribeParam() is not
        available

o   This current National Language version of the DB2 server version 2.1.1

    Setting DescribeParam to 1 will:

    -   enable the SQLDescribeParam() function
    -   have SQLGetFunctions() indicate that SQLDescribeParam() is
        available

    Setting DescribeParam to 0 will:

    -   disable the SQLDescribeParam() function (if you call
        SQLDescribeParam() it will return SQLSTATE S1C00 - 'Driver not
        capable')
    -   have SQLGetFunctions() indicate that SQLDescribeParam() is not
        available


8.3.4  Asynchronous ODBC Enable/Disable

The keyword 'AsyncEnable' has been added to allow you to enable or
disable the new asynchronous features. The keyword is placed in the
datasource specific section of the db2cli.ini file, and has the
following syntax:

AsyncEnable = 0 or 1

o   0 = Disable the new asynchronous features. The DB2 CLI/ODBC driver
    will act as it did with previous versions that did not support
    asynchronous

o   1 = Enable the new asynchronous features as described above.


====================================
9.  Changes to the DB2 Documentation

9.1  For the "Changes for This Release" Section

The following changes apply to the "Changes for This Release" sections
of several DB2 books.

o   In the DB2 CLI and ODBC Enhancements section, under 'New ODBC
    Scalar Functions', the new function which calculates the number of
    seconds since midnight is incorrectly named as MIDNIGHT_SECONDS.
    This is the correct name for the SYSFUN function, but in ODBC this
    name is mapped to SECONDS_SINCE_MIDNIGHT instead.
o   In the section entitled "DB2 CLI and ODBC Enhancements", under
    "New ODBC Scalar Functions", JULIAN_DAY(day_expr) should be
    JULIAN_DAY(date_expr).
o   In the section entitled "DRDA Two-Phase Commit", the following
    sentence should be clarified as follows, "See the DDCS
    Installation and Configuration Guide for your platform for
    instructions on how to install the SPM component and
    considerations for migrating from Encina Monitor PPC gateway."
o   In the section entitled "Graphical Tools", the last sentence in
    the section is augmented to read,

    For more information on the keywords for the DB2 CLI
    initialization file (db2cli.ini), see the "Call Level Interface
    Guide and Reference" or the appendix on "Configuring the Client
    Workstation" in the "Installing and Using DB2 Clients for Windows"
    manual.

    Also, the DB2 Performance Monitor is not available from a Windows
    client.


9.2  Administration Guide

In chapter 5, "Utilities for Moving Data", there is a section "Using
the EXPORT Utility" which requires a change to the first note.  In the
note, the extensions are listed as being from 000 to 999.  This is not
correct:  the first file extension begins with 001.

In chapter 6, Recovering a Database, there is a section
"Considerations for Managing Log Files" which requires two changes:

o   The second bullet should have the following change made: The
    sentence in the middle of the bullet beginning "At this time..."
    should now read "At this time, if there are no more logs available
    and you are rolling forward the entire database, you can use the
    ROLLFORWARD command to stop processing."
o   The sixth bullet should have the following changes made: The
    sentence at the beginning of the third paragraph beginning "If you
    terminate..." should now read "If you are rolling forward the
    entire database and you terminate the roll-forward recovery (by
    specifying the STOP option on the ROLLFORWARD command) and the log
    containing the completion of a transaction has not been applied to
    the database, then the incomplete transaction will be rolled back
    to ensure that the database is left in a consistent state."

In chapter 6, "Recovering a Database", it is explained that
tablespaces can be restored online.  However, restoring the tablespace
containing the system catalogs requires an exclusive connection, so it
must be restored offline.


9.3  API Reference


9.3.1  Backup and Restore API's for Vendor Products Appendix DB2-INFO
Data Structure

The following ADSM information has been added to the DB2-INFO data
structure.

  Field Name    Data Type    Description

  nodename      char         The current value of ADSM_NODENAME from
                             the database manager configuration
                             parameters.
  password      char         The current value of ADSM_PASSWORD from
                             the database manager configuration
                             parameters.
  owner         char         The current value of ADSM_OWNER from
                             the database manager configuration
                             parameters.

Nodename, password, and owner can be utilized to enable the restore of
a backup taken on one node, to a different node (for example, during
disaster recovery).  By setting these values in the database manager
configuration, they will be passed to the vendor device support
routines on the sqluvint call. Then they can be used in the retrieval
of the correct backup.  Owner can be used to specify the name (id) of
the individual who performed the backup.

These values will only be passed in the DB2_INFO structure on a
sqluvint call for a restore.  They will be set to null on a backup.

Added to C structure

     char     *nodename    /* name of node at which the backup          */
                           /* was generated                             */
     char     *password    /* password for the node at which the backup */
                           /* was generated                             */
     char     *owner       /* backup originator id                      */


9.3.2  QUIESCE TABLESPACES FOR TABLE

The following is a correction to the Usage notes:

When a quiesce request is received, the transaction requests a quiesce
mode of SHARE, UPDATE, or EXCLUSIVE for the tablespaces of the table.
The quiesce mode is granted only if there are no conflicting quiesce
modes held by other applications.

A quiescer can upgrade their quiesce mode of a tablespace from a less
restrictive mode to a more restrictive one (for example, from S to U
or X, or U to X).  Quiesce modes can not be downgraded.  If a quiescer
requests a mode lower than one that is already held, the original
quiesce mode is maintained.

The quiesce mode, authorization ID, and the database agent ID of the
quiescer is recorded in the tablespace table so that the quiesce is
persistent.  When the transaction commits or rolls back, the
tablespaces for the table remain quiesced until the quiesce is
explicitly reset.

No tables can be changed while any tablespace for the table is
quiesced in SHARE or UPDATE mode.  An application that has the
tablespaces for a table quiesced in EXCLUSIVE mode has full
(exclusive) access to the table and the tablespaces.

There is a limit of five quiescers on a tablespace at any given time.
Since EXCLUSIVE is incompatible with any other mode, and UPDATE is
incompatible with another UPDATE, the five quiescer limit, if reached,
would consist of at least four SHARE modes and a maximum of one UPDATE
mode.

The tablename parameter in the QUIESCE TABLESPACES FOR TABLE command
should be described as follows:

    Specifies the unqualified table name.  The table cannot be a
    system catalog table.

    schema.tablename - Specifies the qualified table name.  If schema
    is not provided, the authorization ID used for the database
    connection will be used as the schema.  The table cannot be a
    system catalog table.


9.4  Command Reference


9.4.1  FORCE APPLICATION

The following corrects the parameter description for the FORCE
APPLICATION command:

The ALL parameter disconnects all users connected to any database
defined in the instance.


9.4.2  ROLLFORWARD DATABASE

The ROLLFORWARD DATABASE command AND STOP, and the STOP parameters are
not required for table space roll-forward.


9.4.3  EXPORT

The following corrects the parameter description for the EXPORT
command:

The MODIFIED BY parameter accepts LOBSINFILE for IXF filetypes.


9.4.4  QUIESCE TABLESPACES FOR TABLE

The following is a correction to the Usage notes:

When a quiesce request is received, the transaction requests a quiesce
mode of SHARE, UPDATE, or EXCLUSIVE for the tablespaces of the table.
The quiesce mode is granted only if there are no conflicting quiesce
modes held by other applications.

A quiescer can upgrade their quiesce mode of a tablespace from a less
restrictive mode to a more restrictive one (for example, from S to U
or X, or U to X).  Quiesce modes can not be downgraded.  If a quiescer
requests a mode lower than one that is already held, the original
quiesce mode is maintained.

The quiesce mode, authorization ID, and the database agent ID of the
quiescer is recorded in the tablespace table so that the quiesce is
persistent.  When the transaction commits or rolls back, the
tablespaces for the table remain quiesced until the quiesce is
explicitly reset.

No tables can be changed while any tablespace for the table is
quiesced in SHARE or UPDATE mode.  An application that has the
tablespaces for a table quiesced in EXCLUSIVE mode has full
(exclusive) access to the table and the tablespaces.

There is a limit of five quiescers on a tablespace at any given time.
Since EXCLUSIVE is incompatible with any other mode, and UPDATE is
incompatible with another UPDATE, the five quiescer limit, if reached,
would consist of at least four SHARE modes and a maximum of one UPDATE
mode.

The tablename parameter in the QUIESCE TABLESPACES FOR TABLE command
should be described as follows:

    Specifies the unqualified table name.  The table cannot be a
    system catalog table.

    schema.tablename - Specifies the qualified table name.  If schema
    is not provided, the authorization ID used for the database
    connection will be used as the schema.  The table cannot be a
    system catalog table.


9.4.5  RUNSTATS Enhancement

The new RUNSTATS enhancement allows the user to specify a specific
index for which the statistics should be collected as an alternative
to INDEXES ALL.  The following information will be added to the
Command Reference manual:

Wherever ---INDEXES ALL--- appears now in the syntax diagram it should
be replaced with:

      --------INDEXES ALL-----------
        |                        |
         -----INDEX index-name---

The following explains the new parameter:

AND INDEX INDEX-NAME Update statistics on both the table and its
          specified index "index-name", where index-name is a fully
          qualified name in the form:  schema.index-name.

FOR INDEX INDEX-NAME Update statistics for index index-name only. If
          statistics on the table have never been generated, the
          database manager calculates statistics on the table as well
          as on the index. The index-name is a fully qualified name in
          the form: schema.index-name.

This is an example of the new parameter: Collect distribution
statistics on index INDEX1 only:

  db2 runstats on table smith.table1 with distribution for index smith.index1


9.5  Call Level Interface Guide and Reference


9.5.1  SQLColAttributes - Get Column Attributes

In the "Function Arguments" section, the Data Type for the rgbDesc
argument is listed as 'SQLCHAR *'.  This is incorrect; the correct
type for the argument rgbDesc is 'SQLPOINTER'.


9.5.2  New CLI/ODBC Configuration Keyword

See section 8.3, "New CLI/ODBC Configuration Keywords in db2cli.ini"
for the new CLI/ODBC configuration keywords that are not listed in the
CLI Guide and Reference.


9.6  Database System Monitor Guide and Reference


9.6.1  db_conn_time Data Element

The "first database connect timestamp" (db_conn_time) element is
incorrectly described as being part of the Buffer Pool monitor group.
This element is only part of the Buffer Pool monitor group for table
space snapshots.  For Database and Table snapshots, this data element
is part of the Basic monitor group.


9.6.2  Buffer Pool Data Pages Written to Disk

In Chapter 5, "Database System Monitor Data Elements", in the sections
entitled "Buffer Pool Asynchronous Data Writes" and "Buffer Pool
Asynchronous Index Writes" which describe 'pool_async_data_writes' and
'pool_async_index_writes', the following phrase:

    The number of times a buffer pool data page was physically written
    to disk, by an asynchronous page cleaner

should read as follows in order to indicate that the write could also
have been performed by a prefetcher:

    The number of times a buffer pool data page was physically written
    to disk, either by an asynchronous page cleaner or by a
    prefetcher, which may have had to write dirty pages to disk in
    order to make space for the pages to prefetch


9.6.3  DBMON Element Formula

The formula associated with the Buffer Pool Victim Page Cleaners
Triggered (pool_drty_pg_steal_clns) data element is incorrect.  The
formula should be:

        buffer pool victim page cleaners triggered
      / ( buffer pool victim page cleaners triggered
        + buffer pool threshold cleaners triggered
        + buffer pool log space cleaners triggered)


9.6.4  Buffer Pool Threshold Cleaners Triggered

If this value is set too low, pages might be written out too early,
requiring them to be read back in.  If set too high, then too many
pages may accumulate, requiring users to write out pages
synchronously.


9.6.5  Event Start Time

The following sentence has been added to the description for the Event
Start Time:

This element, in the sqlm_evmon_start_event API structure indicates
the start of the event monitor.


9.6.6  Package Cache Inserts/Package Cache Lookups

The formula in the Usage sections for calculating the package cache
hit ratio must be updated as follows:

     1 - ( Package Cache Inserts / Package Cache Lookups )

If the hit ratio is high (more than 0.8), the cache is performing
well.  A smaller ratio may indicate that the package cache should be
increased.


9.6.7  Status of Database and Status of DB2 Instance

In the Usage section for Status of Database Instance, the following is
a correction:  "SQLM_DB2_ACTIVE is the only valid value for this
field."

In the Usage section for Status of Database, the following is a
correction:  "SQLM_DB_ACTIVE is the only valid value for this field."


9.7  Planning Guide


9.7.1  Segments Versus 4KB Pages

This section applies to the SQL Reference manual as well.

In the chapter entitled "Incompatibilities Between Releases", in the
"Configuration Parameters" section, under the heading "Segments Versus
4KB Pages", the following statement exists:

    All configuration parameters in OS/2 that were expressed in
    segments in Version 1 are now expressed in 4KB pages.

The following text expands on the previous sentence:

    For an application which makes a call to a configuration API that
    involves one of the following tokens names, the points listed
    below apply:

      SQLF_DBTN_DBHEAP
      SQLF_DBTN_APPLHEAPSZ
      SQLF_DBTN_STMTHEAP
      SQLF_DBTN_SORTHEAP

    1.  If the application was compiled against Version 1, then if the
        binary is run against either Version 1 or Version 2, the value
        specified will be treated as being specified in segments.

    2.  If the application is re-compiled against Version 2, the
        values specified will be treated by the Version 2 product as
        being specified in 4K pages.

    3.  If, however, the token names were not coded in the
        application, and instead the actual Version 1 token values
        were coded (for example, instead of coding with the token name
        SQLF_DBTN_DBHEAP, the Version 1 token value of 8 is used),
        then if compiled against either Version 1 or Version 2, these
        parameters will be treated as being specified in segments.
        (The token values for these tokens have changed since Version
        1).

In Version 2, in addition to being specified now in 4K pages, the
database configuration parameter sortheap on OS/2 has also changed
from being specified as a two-byte integer to being specified as a
four-byte integer.  If an application written in Version 1 code using
the token SQLF_DBTN_SORTHEAP is recompiled against Version 2, it is
treated as a two-byte integer as in Version 1 (although the units will
change from segments to 4KB pages).  However, the full range of values
will not be accessible to a two-byte integer.  Therefore, it is
recommended that the Version 2 token SQLF_DBTN_SORT_HEAP be used, and
the application code changed to reflect that the API will treat the
token SQLF_DBTN_SORT_HEAP as indicating a four-byte integer, in order
to migrate the application code from Version 1 to Version 2,

NOTE:  In Version 2, all code using the Version 2 token names (see the
API Reference) will be treated the same on UNIX and OS/2 platforms
with respect to the data type and the units.  (The ranges however may
differ).


9.7.2  BUFFPAGE and SORTHEAP

In the chapter entitled "Incompatibilities Between Releases", in the
"Configuration Parameters" section, under the heading "BUFFPAGE and
SORTHEAP", the following clarification should be added.  Also, please
note that the word "byte" should be "bit" in this section in the
Planning Guide.

Symptom:

    OS/2 - If an application was compiled against DB2 for OS/2 Version
    1 using the old tokens, the binary will run as expected against
    Version 2 as well.

    However, since the old tokens indicate that the parameter is to be
    treated as being specified as a 16 bit unsigned integer, the full
    Version 2 range of values for BUFFPAGE (up to 524288) will not be
    available.  Thus, if BUFFPAGE is updated (by a Version 2
    application or by a Version 2 CLP) to a value such as 100,000, and
    the Version 1 application is attempting to GET that value, it will
    not be able to reflect the true value.

    (Note that with the range in Version 2 for sortheap being 524288 4
    KB pages, and with SORTHEAP in DB2 for OS/2 Version 1 being
    specified in segments, this translates to a new range of up to
    32768 segments.  This value is in the range of an unsigned 16 bit
    integer, and hence the DB2 for OS/2 Version 1 binary should not
    have the same range restrictions for SORTHEAP as it does for
    BUFFPAGE.)

Response:

    For a Version 1 binary complied under DB2 for OS/2 Version 1, the
    values used for BUFFPAGE should be restricted to that which can be
    stored in an unsigned 16 bit integer.  For most situations this
    should be sufficient.

    When recompiling the application against Version 2 on any
    platform, use the new tokens for these parameters.


9.8  Configuration Parameters


9.8.1  DIR_CACHE

The DDCS User's Guide incorrectly refers to the DIR_CACHE
configuration parameter as DIRCACHE.

Please refer to the directory cache documentation in the Installing
and Using AIX Clients manual,  Appendix D, "Configuring the Client
Workstation", before attempting to catalog databases.


9.8.2  MAXAPPLS

The maximum value of MAXAPPLS is 5000 on UNIX** systems and 1500 on
OS/2 systems.  The prior value was 1000.  The following manuals
incorrectly show the prior maximum value of 1000:

o   DB2 for OS/2 Planning Guide
o   DB2 for AIX Planning Guide


9.8.3  REC_HIS_RETENTN

The Planning Guide (Appendix C) and Installation and Operation Guides
(Appendix D) indicate that the maximum value for the database
configuration parameter rec_his_retentn is 32767.  This is incorrect.
The correct value is 30000.


9.8.4  Configuration Parameters (YES/NO and ON/OFF Values)

A number of database configuration parameters (including logretain and
userexit) are described as having acceptable values of either
"Yes"/"No" or "On"/"Off" in the Online Help, and Planning Guide.  In
some cases, these do not correspond to what the Command Line Processor
(CLP) displays.

For example, the Planning Guide indicates that the acceptable value
for the database configuration parameter autorestart is either Yes or
No, whereas CLP displays it as being either ON or OFF.  In this
context "Yes" is to be considered synonymous with "On", and "No" with
"Off".


9.8.5  DFT_QUERYOPT

CONFIGURATION TYPE  Database

PARAMETER TYPE      Configurable

DEFAULT [RANGE]     5 [ 0-9 ]

UNIT OF MEASUREMENT Query optimization class (see below)

RELATED PARAMETERS  None

The query optimization class is used to direct the optimizer to use
different degrees of optimization in compiling SQL queries.
DFT_QUERYOPT has been added as a database configuration parameter to
provide additional flexibility in setting the default query
optimization class used when neither the SET CURRENT QUERY
OPTIMIZATION statement nor the QUERYOPT bind option are used
explicitly.

The query optimization classes currently defined are:

0         minimal query optimization

1         roughly comparable to DB2 Version 1

3         moderate query optimization

5         significant query optimization with heuristics to limit the
          effort expended on selecting an access plan.  This is the
          default.

7         significant query optimization

9         maximal query optimization

For additional information and guidance for selecting a suitable query
optimization class see the Administration Guide.

The API reference describes how a program can retrieve and modify
database configuration parameters.  Table 39 provides a list
describing each parameter.  The additional information for the default
query optimization class is:

PARAMETER NAME      dft_queryopt

TOKEN               SQLF_DBTN_DFT_QUERYOPT

TOKEN VALUE         57

DATA TYPE           SINT32

The Database Director does not support the update or the display of
this parameter.

9.8.6  LOGFILSIZ

The maximum value for this database configuration parameter has
changed to 65535 on all UNIX platforms (from a value of 16384).


9.9  Building Your Applications


9.9.1  C++ Type Decoration Consideration

When writing a stored procedure of a UDF using C++, you may want to
consider declaring the procedure of UDF as:

  extern "C" ...procedure or function declaration...

The extern "C" prevents type decoration or mangling of the function
name by the C++ compiler.  Without this declaration, you have to
include all the type decoration for the function name when you call
the stored procedure, or issue the CREATE FUNCTION statement.


9.10  Installation and Operation Guides

In Chapter 6, "Enabling Communications on a DB2 Server" in the section
entitled "Using a Server as a Gateway", the following sentence should
be removed, "However the double-hop gateway does not support NetBIOS
as an outbound communications protocol."  Hopping is now supported for
the NetBIOS protocol.  The sentence which follows should include
NetBIOS as an outbound communications protocol for OS/2.

In Appendix F:

o   Under Datetime Values:
    -   In the table "Formats for String Representations of Dates",
        change the Site-defined (Local) description of Date Format
        from "Depends on database country code" to "Depends on
        application country code".
    -   In the table "Formats for String Representations of Times",
        change the Site-defined (Local) description of Time Format
        from "Depends on database country code" to "Depends on
        application country code".
o   Under Date and Time Formats change the fourth list item (Output
    Date Format) preceding the table "Date and Time Formats by Country
    Code", from "The default output date format is equal to the local
    date format."  to "The default output date format is described in
    Table nn. Date and Time Formats by Country Code, under column
    Default Output Date Format"


9.11  SQL Reference


9.11.1  ALTER TABLE Notes Addition

The following bullet should be included with the "Notes" found in the
section on "ALTER TABLE":

o   Adding a column with a default value that involves an explicit
    value or an implicit or explicit datetime special register, will
    cause all packages with an insert usage on the object table to be
    invalidated.


9.11.2  SQL Communications Area (SQLCA)

Replace the existing text for the "Field values" column for the
SQLWARN1 entry in the "Fields of SQLCA" table, with the following:

Contains X or W if the value of a string column was truncated when
assigned to a host variable.  Contains N if the null terminator was
truncated.

The value of X is returned when all of the following conditions are
met:

o   a mixed code page connection exists where conversion of character
    string data from the database codepage to the application codepage
    may involve a change in the length of the data,

o   the cursor is blocked

o   an indicator variable was provided by the application.

The value returned in the indicator variable will be the length of the
resultant character string in the application's code page.

In all other cases involving data truncation, versus null terminator
truncation, W will be returned.  The value returned in the indicator
variable in this case will be the length of the resultant character
string in the code page of the select list item (either the
application's, the database's or none).


9.11.3  GROUP-BY and ORDER-BY Changes


9.11.3.1  Expressions Section

The following changes should be applied to the "Expressions" section
of the "SQL Reference Changes" section, for CASE Expressions.  Replace
the second paragraph with the following:

If the CASE expression is in a select list, a VALUES clause, an IN
predicate, a GROUP BY clause, or an ORDER BY clause, the
search-condition in a searched-when-clause cannot be a quantified
predicate, IN predicate using a fullselect, or an EXISTS predicate
(SQLSTATE: 42625).


9.11.3.2  Queries Section

In the select-clause section of the "Queries" section, replace the
first bullet in the "If GROUP BY or HAVING is used:" list with:

o   An expression X (not a column function) used in the select list
    must have a GROUP BY clause with:

    -   a grouping-expression that matches the portion of the X
        referencing columns of R (see group-by clause) or

    -   each column of R referenced in X as a separate
        grouping-expression.

GROUP-BY-CLAUSE:  Replace the text of the group-by-clause section of
the "Queries" section with the following:

+--------------------------------------------------------------------+
|                                                                    |
|              ,Ŀ                               |
|  GROUP BY  grouping-expression  |
|                                                                    |
+--------------------------------------------------------------------+

The GROUP BY clause specifies an intermediate result table that
consists of a grouping of the rows of R.  R is the result of the
previous clause of the subselect.

A grouping-expression is an expression used in defining the grouping
of R.  Each column-name included in grouping-expression must
unambiguously identify a column of R (SQLSTATE 42702 or 42703).  The
length attribute of each grouping-expression must not be more than 254
bytes (SQLSTATE 42907).  An grouping-expression cannot include a
scalar-fullselect (SQLSTATE 42822) or any function that is variant or
has an external action (SQLSTATE 42845).

The result of GROUP BY is a set of groups of rows.  In each group of
more than one row, all values of each grouping-expression are equal;
and all rows with the same set of values of the grouping-expressions
are in the same group.  For grouping, all null values from a
grouping-expression are considered equal.

A grouping-expression can be used(1) in a search condition in a HAVING
clause, in an expression in a SELECT clause or in a
sort-key-expression of an ORDER BY clause (see order-by clause for
details).  In each case, the reference specifies only one value for
each group.  For example, if the grouping-expression is col1+col2 then
an allowed expression in the select list would be col1+col2+3.
Associativity rules for expressions would disallow the similar
expression, 3+col1+col2, unless parentheses are used to ensure that
the corresponding expression is evaluated in the same order.  Thus,
3+(col1+col2) would also be allowed in the select list.

If the grouping-expression contains varying-length strings with
trailing blanks, the values in the group can differ in the number of
trailing blanks and may not all have the same length.  In that case, a
reference to the grouping-expression still specifies only one value
for each group, but the value for a group is chosen arbitrarily from
the available set of values.  Thus, the actual length of the result
value is unpredictable.

As noted, there are some cases where the GROUP BY clause cannot refer
directly to a column that is specified in the SELECT clause as an
expression (scalar-fullselect, variant or external action functions).
To group using such an expression, use a nested table expression or a
common table expression to first provide a result table with the
expression as a column of the result.  For an example using nested
table expressions, see Example 9.

The following example is to be added at the end of the examples
section.

Example 9:  Display the average education level and salary for 5
random groups of employees.

This query requires the use of a nested table expression to first set
a random value for each employee so that it can subsequently be used
in the GROUP BY clause.

    SELECT RANDID , AVG(EDLEVEL), AVG(SALARY)
      FROM (
            SELECT EDLEVEL, SALARY,
                   INTEGER(RAND()*5) AS RANDID
              FROM EMPLOYEE
           ) AS EMPRAND
      GROUP BY RANDID

ORDER-BY-CLAUSE:  Replace the text of the order-by-clause section of
the "Queries" section with the following:

+--------------------------------------------------------------------+
|                                                                    |
|              ,Ŀ                               |
|                          ASCĿ                                |
|  ORDER BY  sort-key  |
|                          DESC                                  |
|                                                                    |
| SORT-KEY:                                                          |
| simple-column-name Ĵ |
|    simple-integerĴ                                         |
|    sort-key-expression                                         |
|                                                                    |
+--------------------------------------------------------------------+

The ORDER BY clause specifies an ordering of the rows of the result
table.  If a single sort specification (one sort-key with associated
direction) is identified, the rows are ordered by the values of that
sort specification.  If more than one sort specification is
identified, the rows are ordered by the values of the first identified
sort specification, then by the values of the second identified sort
specification, and so on.  The length attribute of each sort-key must
not be more than 254 characters for a character column or 127
characters for a graphic column (SQLSTATE 42907).

A named column in the select list may be identified by a sort-key that
is a simple-integer or a simple-column-name.  An unnamed column in the
select list must be identified by an simple-integer or, in some cases,
by a sort-key-expression that matches the expression in the select
list (see details of sort-key-expression).  A column is unnamed if the
AS clause is not specified and it is derived from a constant, an
expression with operators, or a function.(2)

Ordering is performed in accordance with the comparison rules
described in Chapter 3.  The null value is higher than all other
values.  If the ORDER BY clause does not completely order the rows,
rows with duplicate values of all identified columns are displayed in
an arbitrary order.

For the purposes of the descriptions that follow, consider an ordering
subselect to be the fullselect of a select-statement that is a
subselect.

simple-column-name
    Usually identifies a column of the result table.  In this case,
    simple-column-name must be the column name of a named column in
    the select list.

    The simple-column-name may also identify a column name of a table,
    view or nested table identified in the FROM clause of an ordering
    subselect.  An error occurs if the ordering subselect:

    o   specifies DISTINCT in the select-clause (SQLSTATE 42822)
    o   produces a grouped result and the simple-column-name is not a
        grouping-expression (SQLSTATE 42803).

    Determining which column is used for ordering the result is
    described under "Column name in sort keys" (see "Notes").

simple-integer
    Must be greater than 0 and not greater than the number of columns
    in the result table (SQLSTATE 42805).  The integer n identifies
    the nth column of the result table.

sort-key-expression
    An expression that is not simply a column name or an unsigned
    integer constant.  The fullselect of the select-statement must be
    a subselect to use this form of sort-key.  The sort-key-expression
    cannot include a correlated scalar-fullselect (SQLSTATE 42703) or
    a function with an external action (SQLSTATE 42845).

    Any column-name within a sort-key-expression must conform to the
    rules described under "Column names in sort keys" (see "Notes").

    There are a number of special cases that further restrict the
    expressions that can be specified.

    o   DISTINCT is specified in the SELECT clause of the ordering
        subselect (SQLSTATE 42822).

        The sort-key-expression must match exactly with an expression
        in the select list of the ordering subselect
        (scalar-fullselects are never matched).

    o   The ordering subselect is grouped (SQLSTATE 42803).

        The sort-key-expression can:

        -   be an expression in the select list of the ordering
            subselect,
        -   include a grouping-expression from the GROUP BY clause of
            the ordering subselect
        -   include a column function, constant or host variable.

ASC
    Uses the values of the column in ascending order.  This is the
    default.

DESC
    Uses the values of the column in descending order.

NOTES

o   COLUMN NAMES IN SORT KEYS:

    -   The column name is qualified.

        The fullselect in the select-statement must be a subselect
        (SQLSTATE 42877).  The column name must unambiguously identify
        a column of some table, view or nested table in the FROM
        clause of the ordering subselect (SQLSTATE 42702).  The value
        of the column is used to compute the value of the sort
        specification.

    -   The column name is unqualified.

        --  The fullselect of the select-statement is a subselect.

            If the column name is identical to the name of more than
            one column of the result table, the column name must
            unambiguously identify a column of some table, view or
            nested table in the FROM clause of the ordering subselect
            (SQLSTATE 42702).  If the column name is identical to one
            column, that column is used to compute the value of the
            sort specification.  If the column name is not identical
            to a column of the result table, then it must
            unambiguously identify a column of some table, view or
            nested table in the FROM clause of the fullselect in the
            select-statement (SQLSTATE 42702).

        --  The fullselect of the select-statement is not a subselect
            (simple-column-name only).

            The column name must not be identical to the name of more
            than one column of the result table (SQLSTATE 42702).  The
            column name must be identical to exactly one column of the
            result table (SQLSTATE 42707) and this column is used to
            compute the value of the sort specification.

o   LIMITS:  The use of a sort-key-expression or a simple-column-name
    where the column is not in the select list may result in the
    addition of the column or expression to the temporary table used
    for sorting.  This may result in reaching the limit of the number
    of columns in a table or the limit on the size of a row in a
    table.  Exceeding these limits will result in an error if a
    temporary table is required to perform the sorting operation.

NOTES:
(1) In general, the grouping-expression must match part of the
    expression where it is used.  If the concatenation operator is
    used, the grouping-expression must be used exactly as the
    expression where it is used.

(2) The rules for determining the name of result columns for a
    fullselect that involves set operators (UNION, INTERSECT, or
    EXCEPT) can be found in 'fullselect' in the same chapter.



9.12  Application Programming Guide

The following information on the bottom of page 24, reads:

The host-language linker creates an executable application.  For
example,

o   With OS/2, the application can be an executable file or a dynamic
    link library.
o   With Windows applications, the application is an executable file.
o   With UNIX-based systems, the application can be an executable load
    module or a shared library.

It should read as follows:

The host-language linker creates an executable application.  For
example,

o   On OS/2 or Windows platforms, the application can be an executable
    file or a dynamic link library (DLL).
o   On UNIX-based systems, the application can be an executable load
    module or a shared library.

Note that although applications can be DLLs on Windows platforms, for
Windows 3.1 or Windows 95, the DLLs are loaded directly by the
application and not by the DB2 database manager.  On Windows NT, DLLs
can be loaded by the database manager.  Stored procedures, which are
normally built as DLLs (on OS/2 and Windows NT) or shared libraries
(on UNIX-based platforms) are unsupported on the Windows 3.1 and
Windows 95 platforms as they are client-only.  For information on
using stored procedures, refer to Chapter 5 in the DB2 Application
Programming Guide.


9.13  References to CompuServe

In the CompuServe section found in the introductions of the DB2
manuals, and at the end of the manuals in the section on contacting
IBM, please note the following corrections:

o   "Compuserve" should be "CompuServe".
o   "IBMDB2 Family Forum" should be the "IBM DB2 Family Forum".

9.14  Database Server Up and Running!

In Chapter 4, "Installing DB2 World Wide Web Connection On a Separate
Server", some option files are missing from the list.  It should be as
follows:

o   db2www.www.db2v2 (DB2 World Wide Web Connection for DB2 Version 2)
o   db2www.www.base (DB2 World Wide Web Connection Base)
o   db2www.www.icons (DB2 World Wide Web Connection Icons)
o   db2www.www.sample_html (DB2 World Wide Web Connection Sample HTML)
o   db2www.www.sample_db (DB2 World Wide Web Connection Sample
    Database)
o   db2www.www.sample_macros (DB2 World Wide Web Connection Sample
    Macros)

9.15  Messages Reference


9.15.1  New Messages

The following messages are to be added to the Messages Reference book.


SQL2548N  DATABASE CODEPAGE INDICATED IN BACKUP IMAGE DIFFERS FROM
          THAT OF THE CURRENT ON-DISK DATABASE.  THE RESTORE OPERATION
          HAS FAILED.

EXPLANATION:  The database contained in the backup image contains data
stored ina codepage different from that of the database into which the
data is being restored.

This problem can be caused in three ways:

1.  The database you are restoring into has a different codepage than
    that of the database in the backup image.

2.  The user is restoring into a new database from a session with a
    different codepage than the backup.

3.  The backup, image is corrupt, and contains invalid character set
    information.

USER RESPONSE:

1.  If restoring over an existing database, make sure that the
    codepage of the existing database matches that of the backup
    image.

2.  If restoring to a new database, make sure that the codepage of the
    session from which the restore command was issued is the same as
    that of the backup image.

3.  Contact IBM Service.

SQL0214N  AN EXPRESSION STARTING WITH "<EXPRESSION-START>" IN THE
          "<CLAUSE-TYPE>" CLAUSE IS NOT VALID.  REASON CODE =
          "<REASON-CODE>".

EXPLANATION:  The expression identified by the first part of the
expression "<expression-start>" in the "<clause-type>" clause is not
valid for the reason specified by the "<reason-code>" as follows:

1   The fullselect of the select-statement is not a subselect.
    Expressions are not allowed in the ORDER BY clause for this type
    of select-statement.  This reason code occurs only when
    "<clause-type>" is ORDER BY.

2   DISTINCT is specified in the select clause and the expression
    cannot be matched exactly with an expression in the select list.
    This reason code occurs only when "<clause-type>" is ORDER BY.

3   Grouping is caused by the presence of a column function in the
    ORDER BY clause.  This reason code occurs only when
    "<clause-type>" is ORDER BY.

4   Expression in a GROUP BY clause cannot be a scalar-fullselect.
    This reason code occurs only when "<clause-type>" is GROUP BY.

The statement cannot be processed.

USER RESPONSE:  Modify the select-statement based on the reason
specified by the "<reason-code>" as follows:

1   Remove the expression from the ORDER BY clause.  If attempting to
    reference a column of the result, change the sort key to the
    simple-integer or simple-column-name form.

2   Remove DISTINCT from the select clause or change the sort key to
    the simple-integer or simple-column-name form.

3   Add a GROUP BY clause or remove the column function from the ORDER
    BY clause.

4   Remove any scalar-fullselect from the GROUP BY clause.  If
    grouping is desired on a column of the result that is based on a
    scalar-fullselect use a nested table expression or a common table
    expression to first provide a result table with the expression as
    a column of the result.

SQLCODE:  -214

SQLSTATE:  42822


9.15.2  Changed Messages

The following is additional information for message SQL1419N:

EXPLANATION: The package "<pkgname>" can not be executed.  The package
was bound on a database manager level which lacks EUC (Extended Unix
Code) and non-SBCS character conversion support.  An attempt to
execute the package from one of these environments was detected.

USER RESPONSE: To execute the package in the current environment,
explicitly rebind the named package using either the REBIND or the
BIND command.  Otherwise, execute the package from the original
binding environment.

The following messages are changed as follows:


SQL0119N  AN EXPRESSION STARTING WITH "<EXPRESSION-START>" IS
          SPECIFIED IN A SELECT CLAUSE, HAVING CLAUSE, OR ORDER BY
          CLAUSE IS NOT SPECIFIED IN THE GROUP BY CLAUSE OR IT IS IN A
          SELECT CLAUSE, HAVING CLAUSE, OR ORDER BY CLAUSE WITH A
          COLUMN FUNCTION AND NO GROUP BY CLAUSE IS SPECIFIED.

EXPLANATION:  The SELECT statement has one of the following errors:

o   The identified expression and a column function are contained in
    the SELECT clause, HAVING clause, or ORDER BY clause but there is
    no GROUP BY clause
o   The identified expression is contained in the SELECT clause,
    HAVING CLAUSE, or ORDER BY clause but is not in the GROUP BY
    clause.

The identified expression is an expression that starts with
"<expression-start>".  The expression may be a single column name.

The statement cannot be processed.

USER RESPONSE:  Correct the statement by including the expression in
the GROUP BY clause that are in the SELECT clause, HAVING clause or
ORDER BY clause or by removing the column function from the SELECT
statement.

SQLCODE:  -119

SQLSTATE:  42803

SQL0120N  A WHERE CLAUSE, GROUP BY CLAUSE, SET CLAUSE, OR SET
          TRANSITION-VARIABLE STATEMENT CONTAINS A COLUMN FUNCTION.

EXPLANATION:  A WHERE clause can contain a column function only if
that clause appears within a subquery of a HAVING clause and the
argument of the column function is a correlated reference to a group.
A GROUP BY clause can contain a column function only if the argument
of the column function is a correlated reference to a column in a
different subselect than the one containing the GROUP BY clause.  A
SET clause of an UPDATE statement or a SET transition-variable
statement can only include a column function within a fullselect on
the right hand side of an assignment.

The statement cannot be processed.

USER RESPONSE:  Change the statement so that the column function is
not used or used only where it is supported.

SQLCODE:  -120

SQLSTATE:  42903

SQL0206N  "<NAME>" IS NOT A COLUMN IN AN INSERTED TABLE, UPDATED
          TABLE, OR ANY TABLE IDENTIFIED IN A FROM CLAUSE OR IS NOT A
          VALID TRANSITION VARIABLE FOR THE SUBJECT TABLE OF A
          TRIGGER.

EXPLANATION:  This error can occur in the following cases:

o   For an INSERT or UPDATE statement, the specified column is not a
    column of the table, or view that was specified as the object of
    the insert or update.
o   For a SELECT or DELETE statement, the specified column is not a
    column of any of the tables or views identified in a FROM clause
    in the statement.
o   For an ORDER BY clause, the specified column is a correlated
    column reference in a subselect, which is not allowed.
o   For a CREATE TRIGGER statement:
    -   A reference is made to a column of the subject table without
        using an OLD or NEW correlation name.
    -   The left hand side of an assignment in the SET
        transition-variable statement in the triggered action
        specifies an old transition variable where only a new
        transition variable is supported.

The statement cannot be processed.

USER RESPONSE:  Verify that the column and table names are specified
correctly in the SQL statement.  For a SELECT statement, ensure that
all the required tables are named in the FROM clause.  For a subselect
in an ORDER BY clause, ensure that there are no correlated column
references.  If a correlation name is used for a table, verify that
subsequent references use the correlation name and not the table name.

For a CREATE TRIGGER statement, ensure that only new transition
variables are specified on the left hand side of assignments in the
SET transition-variable statement and that any reference to columns of
the subject table have a correlation name specified.

SQLCODE:  -206

SQLSTATE:  42703

SQL0208N  THE ORDER BY CLAUSE IS NOT VALID BECAUSE COLUMN "<NAME>" IS
          NOT PART OF THE RESULT TABLE.

EXPLANATION:  The statement is not valid because a column "<name>"
specified in the ORDER BY list is not specified in the SELECT list and
is not in the result table.  Only columns in the result table can be
used to order that result when the fullselect of the select-statement
is not a subselect.

The statement cannot be processed.

USER RESPONSE:  To correct the syntax of the statement, either add the
specified column to the result table or delete it from the ORDER BY
clause.

SQLCODE:  -208

SQLSTATE:  42707

SQL0582N  A CASE EXPRESSION IN A SELECT LIST, VALUES CLAUSE, IN
          PREDICATE, OR ORDER BY CLAUSE CANNOT INCLUDE A QUANTIFIED
          PREDICATE, AN IN PREDICATE USING A FULLSELECT OR AN EXISTS
          PREDICATE.

EXPLANATION:  A search condition of a CASE expression is:

o   a quantified predicate (one using SOME, ANY, or ALL),
o   an IN predicate using a fullselect or
o   an EXISTS predicate

and the CASE expression is part of:

o   a select list
o   a VALUES clause
o   an IN predicate
o   an GROUP BY clause or
o   an ORDER BY clause.

Such CASE expressions are not supported.

The statement cannot be processed.

USER RESPONSE:  Remove the use of the quantified predicate, IN
predicate, or EXISTS predicate from the CASE expression.  In some
cases, it may be possible to write the query so that the CASE
expression is not part of the select list or an IN predicate.

SQLCODE:  -582

SQLSTATE:  42625

SQL0583N  THE USE OF FUNCTION "<FUNCTION.NAME>" IS INVALID BECAUSE IT
          IS VARIANT OR HAS AN EXTERNAL ACTION.

EXPLANATION:  The function "<function-name>" is defined as a variant
function or a function with an external action.  This type of function
is not supported in the context in which it is used.  The contexts in
which these are not valid are:

o   as the first operand of a BETWEEN predicate

o   in the expression prior to the first WHEN keyword in a
    simple-case-expression.

o   in an expression of a GROUP BY clause

o   in an expression of an ORDER BY clause (external action only)

The statement cannot be processed.

USER RESPONSE:  If the use of a variant or external action function
was not intended, substitute a function without these characteristics.
If the behaviour associated with the variant or external action
function is intentional, use the alternate form of the statements that
make that intent explicit.

o   Instead of the BETWEEN predicate, use the corresponding statement
    using the equivalent combination of comparison predicates (a>=b
    and a<=c instead of a between b and c).

o   Instead of a simple-when-clause, use the corresponding
    searched-when-clause where the function would get specified in
    each search-condition.

o   Remove the variant or external action function from the GROUP BY
    clause.  If grouping is desired on a column of the result that is
    based on a variant or external action function use a nested table
    expression or a common table expression to first provide a result
    table with the expression as a column of the result.

o   Remove the external action function from the ORDER BY clause.  If
    the column is part of the result set of the query, change the
    expression in the ORDER BY clause to the simple-integer or
    simple-column-name form of the sort key.

SQLCODE:  -583

SQLSTATE:  42845

======================================================
10.  DB2 World Wide Web Connection For AIX Information

10.1  Installation Notes

If you have a beta version of DB2 World Wide Web Connection installed
on your system, delete it before installing the version included in
Database Server.

Note:  Make sure you back up all html documents before deleting the
beta version of the product.

If you have installed the DB2 WWW Connection alpha release, remove the
line "set LIBPATH=$LIBPATH:<your CGI>" from .cshrc and .profile.

If your Web Server uses directories other than
/usr/lpp/internet/server_root/cgi-bin for Web Server CGI executable
programs, /usr/lpp/internet/server_root/pub for the Web Server
document root directory (where HTML source files are stored), and
/usr/lpp/internet/server_root/icons for Web Server image files that
are used in HTML files, you will need to do the following before
running DB2 WWW Connection:

        - Update your Web Server configuration file to use the above
          directories -OR-

        - Copy db2www and db2sql.bnd to your Web Server's directory that stores
          CGI executable programs.
        - Copy db2www.ini and all of the htm files to your Web Server's
          document root directory.
        - Copy all of the gif files to your Web Server's image directory
        - Create the tmplobs directory (under the document root directory) and
          allow your Web Server to have write access to this directory.


10.2  DB2 WWW Connection Configuration

Configuration information for DB2 WWW Connection is in the file
'db2www.ini', which resides in the Web Server's document root
directory (e.g. /usr/lpp/internet/server_root/pub).  Inside the file,
there are three entries:

        MACRO_PATH  -specifies where the directory for the macro files are
        BINDFILE    -specifies the location of the bind file for DB2 WWW
        DB2INSTANCE -specifies the DB2 instance owner of the tables being
                     queried


10.3  Usage Notes

o   Make sure that the Web Server and database connection are running

o   Make sure that the file db2www.ini in the 'pub' directory has the
    correct settings.

o   If necessary, verify that all DB2 WWW Connection macros (including
    the sample application macros that are shipped with the product)
    use the LOGIN and PASSWORD variables.  See the explanation under
    "Authentication" below to determine if this step is necessary or
    not.

o   If you use the BLOB and CLOB features of DB2 WWW, be sure to
    periodically remove old temporary files in tmplobs directory.

o   Since the file 'db2www.ini' is viewable by other people using a
    Web Browser, we recommend that appropriate access restrictions on
    that file be enforced using the access control protocol provided
    by your Web Server.

    Further security can be provided by adding encryption and a
    firewall.  Refer to your Web Server documentation for details.

o   A template macro file (template.d2w) is provided in the macro
    directory to help you get started writing your own macro files.


10.3.1  Authentication

DB2 WWW Connection uses the user ID specified with the macro variables
LOGIN and PASSWORD for database access authentication.  If these
variables are not specified, the user ID which started the Web Server
daemon is used for database access authentication.

For example, if the Web Server was started with the database
administrator's user ID and DB2 WWW Connection uses a macro file that
does not have the LOGIN and PASSWORD variables defined, the query will
still be successful because the database administrator has privileges
which give unlimited database access.

If your Web Server was started with a user ID that does not have
database access authority, you must specify the LOGIN and PASSWORD
macro variables in all macro files that are used.  Note that this
applies to the sample macros that are shipped with DB2 WWW Connection.
Since these macro files do not use the LOGIN and PASSWORD variables,
you must add these variables to the macro files.

If your Web Server was started with a user ID that has database access
authority, you will not need to use the LOGIN and PASSWORD variables
in your macro files.  However, verify that this user ID has the
necessary Web Server directory and file read/write privileges.


10.4  Using the Sample Application


10.4.1  Installation Notes

o   The db2data subdirectory (installed in /usr/lpp/internet/db2www)
    contains the necessary data files for installing the sample
    database, "celdial".  These data files were exported using the ixf
    format.

o   When following the instructions provided in the Up and Running!
    book to install the sample application, make sure that the user ID
    that you are using can become an instance owner user ID.  For more
    information on instance owners, refer to the Up and Running!.

o   If necessary, update the DB2 WWW Connection macros to use the
    LOGIN and PASSWORD variables.  See the explanation under
    "Authentication" to determine if this step is necessary or not.

o   Update your Web Server's configuration to recognize the .htm file
    extension as an HTML/Text file, or rename all .htm files that were
    shipped with DB2 WWW Connection to .html files.  Note that if you
    rename these files, you will also need to update the references to
    these files in the .htm and .d2w files.


10.4.2  DBCS Considerations When Using the Sample Application

If you are installing the sample application on a DBCS server machine,
add 'MODIFIED BY FORCEIN' to each IMPORT command in the appropriate
command file.  This modifier directs DB2 to accept the data with no
code page conversion.  For example, change the line:

 DB2 IMPORT FROM CUSTSHIP OF IXF CREATE INTO CUSTSHIP
to
 DB2 IMPORT FROM CUSTSHIP OF IXF MODIFIED BY FORCEIN CREATE INTO CUSTSHIP


=============================
11.  DDCS For AIX Information

11.1  Prerequisites


11.1.1  Need to Apply DB2 for MVS PTF to Use DB2DRDA as RTPN

If you want to use DCE directory services support in DB2 for AIX to
connect to DB2 for MVS, you must apply the DB2 for MVS PTF UN73393
that supports the use of DB2DRDA as the name of the remote transaction
program name (RTPN).


11.2  Documentation Changes


11.2.1  Installation Requirements

The DB2 Planning Guides for OS/2 and AIX contain out of date
information for memory and hard disk space requirements for DDCS
V2.3.1. Please refer to the information in Chapter 1 of the updated
DDCS Installation and Configuration Guides.

In Chapter 1, in the section entitled "Installation Requirements", the
bullet that says "An appropriate SNA product" is incorrect.  It should
read: "SNA Server for AIX V2.1 or higher".

Also, ignore the sub-bullets referencing the Encina PPC Gateway.


11.2.2  National Language (Code Page and Conversion) Information
Changes

Some of the information contained in the V2.1.0 DDCS User's Guide has
been superseded by updated versions of tables and other information
relating to National Language, and related considerations such as
character set conversion rules.  Please refer to updated information
in the DDCS Installation and Configuration Guide (S20H-4794-01).


11.2.3  OS/2 and UNIX-Based Databases

Throughout the DDCS manuals, references to OS/2 and UNIX-based
databases should be references to the DB2 Common Server Family of
Products instead.


11.2.4  SET CURRENT PACKAGESET Support

In the DDCS User's Guide in Chapter 7, "Programming in a DRDA
Environment", the following sentence should be included:

The DDCS support for the SET CURRENT PACKAGESET command is now
available for DB2 for MVS/ESA and DB2 for Common Servers.


11.2.5  DB2 for OS/400 Column Types and Length

In the DDCS User's Guide in Chapter 7, "Programming in a DRDA
Environment", in the section that describes DB2 for OS/400 Column
Types and Length, the following text should exist:

DB2 for OS/400 Version 3.1 supports the column types GRAPHIC and
VARGRAPHIC.  Please refer to your DRDA AS documentation for the most
up-to-date features supported by your DRDA Server.


11.2.6  Binding DDCS Utilities to an OS/400 Database

The following step is documented in the DDCS User's Guide in Chapter 4
to allow you to bind all the DDCS utilities to the DRDA server
database; however, an error occurs.  The error is a result of using
the GRANT bind option when binding a list of bind files.  The bind
receives a -901 sqlcode from the OS/400 database on the third bind
file in the list.

    db2 bind @ddcs400.lst blocking all sqlerror continue grant public
        messages ddcs400.msg


11.2.6.1  Possible Solutions

1.  PTF SF23634 is available for the OS/400 V3.1 database to fix this
    problem.

2.  Alternatively, use either of the following two methods:

    a.  Issue separate bind requests for each bind file in
        ddcs400.lst, (19 bind files resulting in 19 bind requests),
        for example:

             ===> connect step
                db2 connect to DBALIAS user USERID using PASSWORD
             ===> bind step
                db2 bind db2ajgrt.bnd blocking all sqlerror continue grant public
                    messages db2ajgrt.msg
                db2 bind db2clics.bnd blocking all sqlerror continue grant public
                    messages db2clics.msg
                    ...
                db2 bind db2uimpm.bnd blocking all sqlerror continue grant public
                    messages db2uimpm.msg
             ===> drop connection
                db2 connect reset

    b.  Issue the bind request against ddcs400.lst but omit the GRANT
        PUBLIC bind option.  As a separate step, grant execute
        permission to public on each of the packages.  Use the
        ddcspkgn utility to determine the package names of the bind
        files in ddcs400.lst.  An example is provided below.  Refer to
        Chapter 4 of the DDCS User's Guide for more details on this
        option.

             ===> connect step
                db2 connect to DBALIAS user USERID using PASSWORD
             ===> bind step
                db2 bind @ddcs400.lst blocking all sqlerror continue
                    messages ddcs400.msg
             ===> determine the package names of bind files in ddcs400.lst
                ddcspkgn @ddcs400.lst
             ===> grant step
                db2 grant execute on package SQLAB4C0 to public
                db2 grant execute on package SQLL14C0 to public
                    ...
                db2 grant execute on package SQLUF4C0 to public
             ===> drop connection
                db2 connect reset


11.2.7  Binding Utilities for Back-Level Clients

In the DDCS User's Guide, in Appendix D, "Binding Utilities for Back
Level Clients", the command to find out the package names for bind
files should read ddcspkgn @bindfile.lst, NOT ddcspkgn bindfile.lst.


11.2.8  Description of Environment Keywords

The description of the following environment keywords and their
respective values, in the IBM DDCS User's Guide is incomplete.

  DB2ACCOUNT     DB2BQTIME     DB2COMM
  DB2CHKPTR      DB2BQTRY      DB2DIRPATHNAME
  DB2DBDFT       DB2RQTIME     DB2CLIENTCOMM
  DB2INSTANCE    DB2IQTIME     DB2ROUTE
  DB2LOADREC     DB2OPTIONS    DB2INSPATH


11.2.9  DDCS (non-OS/2) Auto Disconnect Option Not Supported

In the DDCS User's Guide, in Chapter 3 "Updating Database Directories"
in the section entitled "Parameter String" under the heading "DCS
Directory", the description of INTERRUPT_ENABLED should read:

On non-OS/2 platforms, DDCS does not support the option of
automatically disconnecting when an application using it receives an
interrupt request.


11.2.10  SPM Instance Name

In Appendix D, "LU6.2 Sync Point Manager Considerations", in the
section "Installing the SPM", the DDCS Installation and Configuration
Guide for AIX refers to the "SPM database".  This should
read "SPM instance", as referred to in the DB2 Command Reference:

    Before issuing LIST DRDA INDOUBT TRANSACTIONS, the application
    must be connected to the Sync Point Manager (SPM) instance. Use
    the SPM_NAME database manager configuration parameter as the
    dbalias on the CONNECT statement.

Throughout the "Installing SPM" section in Appendix D, wherever the
words "SPM database" appear alone without the word "alias" immediately
following them, please replace the word "database" with the word
"instance".

The documentation will be changed in the next update of these
publications.


11.3  Syncpoint Manager (SPM)

If you have both a DB2 server and a DDCS gateway on the same machine,
then there are some coexistence considerations which affect the use of
LU names and TP names between the inbound DRDA AS support, and the
outbound DRDA2 AR support.


11.3.1  AIX SNA Server Coexistence Considerations

This section of the README is referenced by the DDCS for AIX
Installation and Configuration Guide in Appendix D (LU 6.2 Syncpoint
Manager Considerations), section "AIX SNA Server Coexistence
Considerations".

In order to use a node which has the DDCS for AIX V2.3.1 Syncpoint
Manager started as a DB2 for AIX V2.1.1 DRDA1 AS or as a database
server for clients accessing via APPC you must do the following:

On the DDCS for AIX Syncpoint Manager (SPM) Server Node:

o   You must install DB2 for AIX Server V2.1.1.

o   Ensure that there are no SNA Server/6000 LU 6.2 Transaction
    Program Name (TPN) definitions defined for the following
    transaction programs:

    -   07F6C4C2 (hex)

    -   07F6E2D5 (hex)

    -   06F2 (hex)

    -   06F2F0F1 (hex)

    -   DB2INTERRUPT (alphanumeric)

    -   DB2DRDA  (alphanumeric)

    -   TP name defined in the data base manager configuration
        parameter TPNAME.

You can validate this by setting the SPM_NAME to the correct LU name
and setting the DIAGLEVEL = 4 in the Database Manager Configuration.
When you issue db2start to initiate the SPM you should NOT see the
following message in the db2diag.log :

  common_communication  sqlccsnaconnmgr_spm_listener29 Probe:29
  DIA3002E Error encountered while trying to start "SPM" protocol support
  code from "ioctl(ALLOCATE_LISTEN)" was "OPTIONAL TPs NOT REGISTERED".

NOTE:  The above procedure assumes you have configured the Database
Manager (DBM) configuration parameter TPNAME.  It is permissible to
leave this parameter unconfigured, but if you do so you will always
get the DIA3002E message in db2diag.log.  In this case, before
attempting to validate your SPM configuration you may wish to
temporarily set a dummy value for TPNAME.  You can then reset TPNAME
to the default value if you wish, using the following command:

          db2 update dbm cfg using tpname NULL

On the Database Client Node:

Ensure all clients use the LU specified on the SPM node in the
Database Manager Configuration parameter SPM_NAME as their partner LU.


11.3.2  Prerequisite PTFs

AIX SNA/Server 2.1 PTFs
  PTF U437491 (fixes for APAR IX50393)
  PTF U437840 (fixes for APAR IX51831)
  PTF U440157 (fixes for APAR IX54025)

AIX SNA/Server 2.2 PTFs
  PTF U437857 (fixes for APAR IX50393)
  PTF U440318 (fixes for APAR IX51831)
  Fix for APAR IX54025 (PTF number not available at time of
                        printing)

AIX SNA/Server 3.1 PTFs
  PTF U440156 (fixes for APAR IX54025)

All DB2/MVS V3.1 systems
  PTFs UN73393 and UN76673 (fixes for APARs PN67179 and PN70102)

All DB2/MVS V4.1 systems
  PTF UN76674 (fixes for APAR PN70102)

All DB2/400 V3.1 systems
  PTF SF26564 (fixes for APAR SA46917)
  APAR SA48935 (no PTF available at time of printing README)
  PTF SF26804 (fixes for OS/400 V3R1M0, product 5763SS1)


11.3.3  AIX/SNA Server Operational Considerations

Terminating AIX/SNA server while the SPM is active causes the SPM to
stop.  Once AIX/SNA server is restarted, you must issue a db2stop and
db2start on the DDCS Multi-User Gateway in order to allow the SPM to
reinitialize.


11.4  Authentication Default

For any system database directory entry that DDCS uses for
establishing a connection, if the authentication parameter is not
specified, DDCS will use a default authentication of SERVER.

This default applies to the system database directory entry on the
DDCS machine.  In addition, this default applies to the system
database directory entry at the remote client in a multi-user gateway
DDCS environment.


11.5  Performance Troubleshooting

If DDCS for AIX users are experiencing a long response time during
large queries from DRDA AS hosts (that is, DB2 for MVS, SQL/DS, or
DRDA AS for DB2 for AIX), the following areas should be examined for
the possible cause of the performance problem:

1.  For queries which result in returning large data blocks from the
    DRDA host (usually 32K of data and above), ensure that the
    database manager configuration parameter RQRIOBLK is set to 32767.
    This can be done using the Command Line Processor (CLP) as
    follows:

         db2 update database manager configuration using RQRIOBLK 32767

2.  If VTAM is used in the connection to DRDA AS, look under "switched
    major node" configuration for the value of the PACING parameter.
    On the DDCS workstation, examine the communication setup of the
    "LU 6.2 Mode Profile" for IBMRDB mode definition.  In this
    definition, ensure the value for the "Receive pacing window"
    parameter is less than or equal to the PACING value defined on
    VTAM.  A common value for "Receive pacing window" on the DDCS
    workstation and "PACING" on VTAM is 8.

3.  Ensure the maximum RU size defined in the IBMRDB mode definition
    is not less than 4K.

4.  Consult with the VTAM administrator in your environment to ensure
    that VTAM is using "adaptive pacing" in LU-LU sessions with your
    DDCS workstation.


11.6  DDCS 2.3 Gateway Connection to DB2/MVS

This section documents important additional information about setting
up a working DDCS Gateway connection to DB2/MVS:

o   VTAM definitions required at your MVS host.
o   DB2/MVS configuration steps.

This information is not presently provided in "DDCS Installation and
Configuration" manuals.  The sample presented here illustrates a DDCS
for OS/2 scenario, but it can readily be used as a model to help you
connect other variants of DDCS to DB2 for MVS.

For example, if you are knowledgeable about IBM SNA Server for AIX,
and you follow the instructions for setting up SNA Server profiles
provided in "DDCS for AIX Installation and Customization Guide", the
documentation in this section will help you complete a working
connection between DDCS for AIX and DB2/MVS.

You must use your own values for elements such as network name, LU
name, etc., and we recommend that you use the planning worksheets
provided in Appendix A of the "DDCS Installation and Configuration
Guide" for your system.

For further information about DRDA Connectivity, we recommend that you
refer to "DRDA Connectivity Guide", SC26-4783.

Also, if you will use the LU6.2 Syncpoint Manager (SPM) function of
the DDCS Multi-User Gateway programs for OS/2 or AIX, it is
particularly important to refer to the SPM appendix in your "DDCS
Installation and Configuration Guide".  The examples documented in
this section do not include detailed steps required for SPM.


11.6.1  Summary of Steps

In order to setup the connection, you must complete the following
steps:

1.  At your DDCS Gateway:
    a.  Configure APPC.
    b.  Configure Database Manager - see 11.6.5, "Cataloging DB2
        Directory Entries at the Workstation".
    These steps are more completely documented in "Chapter 3:
    Configuring Your Network" of the "DDCS Installation and
    Configuration Guide" for your system.
2.  At your DB2/MVS host:
    a.  Configure VTAM - see 11.6.6, "Configuring VTAM".
    b.  Configure DB2/MVS - see 11.6.8, "Configuring DB2/MVS".


11.6.2  Products used in this example

The following products were used:

o   IBM PS/2 with Token-ring adapter
o   DB2 for OS/2 2.1
o   DDCS for OS/2 2.3
o   DB2/MVS 2.3
o   OS/2 Warp 3.0
o   IBM LAN Server 4.0
o   IBM Communications Manager/2 Version 1.11 (check your "DDCS
    Installation and Configuration Guide" for the right level if you
    will work with SPM).


11.6.3  Network Element Names

This example uses the following names:

  DDCS Gateway:
          - Network ID              : CAIBMOML
          - Local Node Name         : OMXRSA      (PU name)
          - Local Node ID           : 05D 30376

          - LU Name                 : OMXRSA0A
          - LU Alias                : OMXRSA0A

  HOST:
          - Network ID              : CAIBMOML
          - Node Name               : HOSTDB

          - LU Name                 : SFLU
          - LU Alias                : SFLU
          - LAN Destination Address : 400011528905 (Tic Address in NCP-NTRI)

  MODE DEFINITION:
          - Mode Name               : IBMRDB

  DB2/MVS:
          - Location                : SAN_FRANCISCO

  SECURITY:
          - Security Type           : Program
          - Authentication Type     : DCS


NOTE:  In this scenario, both USERID and password were only checked on
the Host.  If you use Authentication SERVER, which is the default,
then authentication will also take place at the Gateway.


11.6.4  Configuring SNA Communications

Regardless of which variant of DDCS you are working with, at this
point you should refer to "Chapter 3 Configuring your Network" and
"Appendix A Worksheets", in your "DDCS Installation and Configuration
Guide".

When you have completed SNA communications configuration tasks,
proceed to 11.6.5, "Cataloging DB2 Directory Entries at the
Workstation".


11.6.5  Cataloging DB2 Directory Entries at the Workstation

When you have configured your SNA subsystem, before you can to use the
DDCS connection, you may also need to catalog the database, the
workstation (node), and the DCS database at the DDCS workstation.


11.6.5.1  Cataloging the Workstation

1.  From an OS/2 prompt, issue the following command:

       DB2 CATALOG APPC NODE HOSTMVS REMOTE SFLUNODE SECURITY PROGRAM

    The node name (HOSTMVS) can be any name, but it must match the
    entry in the system database directory.
2.  If you have not previously logged on, you will be prompted for
    your USERID and Password.

    NOTES:

    a.  The Node Name must be unique in the Node Directory

    b.  The Node Name in the System Database Directory maps to the
        Node in the Node Directory.


You can verify the Node directory information using the following
command:

     DB2 LIST NODE DIRECTORY

The output will look like this:


   Node Directory

   Number of entries in the directory = 1

  Node 1 entry:

   Node name                      = HOSTMVS
   Comment                        =
   Protocol                       = APPC
   Symbolic destination name      = SFLUNODE
   Security type                  = PROGRAM


11.6.5.2  Cataloging the Database

1.  Use the following command:

       DB2 CATALOG DATABASE SFLUDB AS HOSTDB AT NODE HOSTMVS
       AUTHENTICATION DCS

    NOTES:

    a.  The Database name in the System Database Directory maps to the
        Local Database Name in the DCS Directory.

    b.  The Node Name in the System Database Directory maps to the
        Node Name in the Node Directory.

    c.  The Alias is the name used with the CONNECT statement.


You can verify the Database directory information using the following
command:

    DB2 LIST DATABASE DIRECTORY

The output will look like this:


   System Database Directory

   Number of entries in the directory = 1

  Database 1 entry:

   Database alias                  = HOSTDB
   Database name                   = SFLUDB
   Node name                       = HOSTMVS
   Database release level          = 6.00
   Comment                         =
   Directory entry type            = Remote
   Authentication                  = DCS


11.6.5.3  Cataloging the DCS Database

1.  Use the following DCS Database Catalog command:

       DB2 CATALOG DCS DATABASE SFLUDB AS SAN_FRANCISCO

    NOTES:

    a.  The local database name must be unique in the DCS directory.

    b.  The database name in the System Database Directory maps to the
        Local database name in the DCS Directory.

    c.  The target database name in the DCS directory maps to the DRDA
        AS location name (RDB_NAME).


11.6.5.4  Verify DCS Directory Information

You can verify your DCS directory information using the following
command:

     DB2 LIST DCS DIRECTORY

The output will look like this:


   Database Connection Services (DCS) Directory

   Number of entries in the directory = 1

  DCS 1 entry:

   Local database name                = SFLUDB
   Target database name               = SAN_FRANCISCO
   Application requestor name         =
   DCS parameters                     =
   Comment                            =
   DCS directory release level        = 0x0100


11.6.6  Configuring VTAM

To configure the VTAM host, you must prepare the necessary
definitions:

1.  The APPL name for the DB2 subsystem (SFLU in these examples).
2.  PU and LU definitions for the DDCS workstation (OMXRSA and
    OMXRSA0A respectively in these examples).
3.  The log mode entry to be used for the connection (IBMRDB in these
    examples).

Work with your VATM Administrator to determine the options to be used
on your system.  The following VTAM definitions correlate to
parameters used elsewhere in this sample scenario.


11.6.7  VTAM DB2 APPL Definition

Sample VTAM definition for the DB2 Application:

  ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--

  DB2APPLS VBUILD TYPE=APPL

  SFLU     APPL  APPC=YES,                                               X
                 AUTH=(ACQ),                                             X
                 AUTOSES=1,                                              X
                 DLOGMOD=IBMRDB,                                         X
                 DMINWNL=512,                                            X
                 DMINWNR=512,                                            X
                 DSESSLIM=2048,                                          X
                 EAS=6000,                                               X
                 MODETAB=RDBMODES,                                       X
                 PARSESS=YES,                                            X
                 PRTCT=SFLU,                                             X
                 MODETAB=RDBMODES,                                       X
                 SECACPT=ALREADYV,                                       X
                 SRBEXIT=YES,                                            X
                 VERIFY=NONE,                                            X
                 VPACING=8

NOTES:

1.  Continuations must begin in column 16.

2.  If you will use SPM, you must also include:

       SYNCLVL=SYNCPT


11.6.7.1  VTAM DB2 PU and LU definitions

Sample Switched Major Node Definition:

  ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--

          SWITCHED MAJOR NODE DEFINITION FOR PU OMXRSA and
          INDEPENDENT LU OMXRSA0A

  LOC300    VBUILD TYPE=LOCAL

  OMXRSA         ADDR=01, IDBLK=05D, IDNUM=30376, ANS=CONT, DISCNT=NO,   X
                 IRETRY=YES, ISTATUS=ACTIVE, MAXDATA=4302,MAXOUT=7,      X
                 MAXPATH=1,PUTYPE=2,SECNET=NO,MODETAB=RDBMODES           X
                 SSCPFM=USSSCS,PACING=0,VPACING=2

  OMXRSA0A  LOCADDR=000, MODETAB=RDBMODES, DLOGMODE=IBMRDB

  OTHERLU   LOCADDR=002


11.6.7.2  Sample Log Mode Definition

Sample Log Mode:


  ----+----1----+----2----+----3----+----4----+----5----+----6----+----7---

  RDBMODES MODTAB

  IBMRDB   MODEENT LOGMODE=IBMRDB,   DRDA DEFAULT MODE                   *
                 TYPE=0,             NEGOTIABLE BIND                     *
                 PSNDPAC=X'01',      PRIMARY SEND PACING COUNT           *
                 SSNDPAC=X'01',      SECONDARY SEND PACING COUNT         *
                 SRCVPAC=X'00',      SECONDARY RECEIVE PACING COUNT      *
                 RUSIZES=X'8989',    RUSIZES IN-4K    OUT-4K             *
                 FMPROF=X'13',       LU6.2 FM PROFILE                    *
                 TSPROF=X'07',       LU6.2 TS PROFILE                    *
                 PRIPROT=X'B0',      LU6.2 PRIMARY PROTOCOLS             *
                 SECPROT=X'B0',      LU6.2 SECONDARY PROTOCOLS           *
                 COMPROT=X'D0B1',    LU6.2 COMMON PROTOCOLS              *
                 PSERVIC=X'060200000000000000122F00'    LU6.2 LU TYPE

  SNASVCMG MODEENT LOGMODE=SNASVCMG, DRDA DEFAULT MODE                   *
                 PSNDPAC=X'00',      PRIMARY SEND PACING COUNT           *
                 SSNDPAC=X'02',      SECONDARY SEND PACING COUNT         *
                 SRCVPAC=X'00',      SECONDARY RECEIVE PACING COUNT      *
                 RUSIZES=X'8585',    RUSIZES IN-1K    OUT-1K             *
                 FMPROF=X'13',       LU6.2 FM PROFILE                    *
                 TSPROF=X'07',       LU6.2 TS PROFILE                    *
                 PRIPROT=X'B0',      LU6.2 PRIMARY PROTOCOLS             *
                 SECPROT=X'B0',      LU6.2 SECONDARY PROTOCOLS           *
                 COMPROT=X'D0B1',    LU6.2 COMMON PROTOCOLS              *
                 PSERVIC=X'060200000000000000000300'    LU6.2 LU TYPE

NOTE:  You must define SNASVCMG when using APPC.


11.6.8  Configuring DB2/MVS

Before you can use the DDCS connection, you need to configure DB2/MVS
to allow connections remote requests.  The example below suggests a
simple configuration.  Work with your DB2 Administrator to determine
the options to be used on your DB2/MVS system.


11.6.8.1  Updating the SYSIBM.SYSUSERNAMES Table


  COLUMN               EXAMPLE              REMARK
  ======               =======              ======
  Type                    I
  Authid               (blank)
  LU Name              OMXRSA0A             Must match the DDCS/2 g/w's LU name
  NewAuthID            (blank)
  Password             (blank)

  USERNAMES types are: O (outbound translation), I (inbound translation),
  B (both inbound and outbound) and blank (no authorization ids are
  translated, and no password is sent to the server).


You can use a DB2/MVS command such as the following to update this
table:

    INSERT INTO SYSIBM.SYSUSERNAMES VALUES('I','JASI','OMXRSA0A',' ',' ');


11.6.8.2  Update the SYSIBM.SYSLUNAMES Table


  COLUMN               EXAMPLE              REMARK
  ======               =======              ======
  LUNAME               OMXRSA0A             Must match the DDCS Gateway LU name
  SYSMODENAME           IBMRDB
  USERSECURITY            A
  ENCRYPTPSWDS            N
  MODESELECT              N
  USERNAMES               I


You can use a DB2/MVS command such as the following to update this
table:

    INSERT INTO SYSIBM.SYSLUNAMES VALUES('OMXRSA0A',' ','A','N',' ','I');


11.7  Connectivity Via DDCS (Thailand Users Only)

Please note that currently only connectivity between DB2 for OS/2 and
DB2 for AIX is supported.

Connectivity between the following is not supported due to the Thai
CCSID, 838, not being supported on the host:

    DB2 for OS/2 and DB2 for MVS via DDCS
    DB2 for OS/2 and DB2 for OS/400 via DDCS
    DB2 for OS/2 and DB2 for VM and VSE via DDCS

    DB2 for AIX and DB2 for MVS via DDCS
    DB2 for AIX and DB2 for OS/400 via DDCS
    DB2 for AIX and DB2 for VM and VSE via DDCS


11.8  DDCS User's Guide BIND Information

On Page 20 of "DDCS User's Guide", S20H-4793-00, Figure 4 "Bind Files
and Packages" contains information that has been superseded for DDCS
Version 2.3.1.  The respective "xxx" values for DB2 Version 2.1.1 and
DDCS Version 2.3.1 are as follows:

5W0       DB2 Client Application Enabler for Windows Version 2.1.1
5D0       DB2 Client Application Enabler for OS/2 Version 2.1.1
5C0       DB2 Client Application Enabler for AIX Version 2.1.1, also
          for HP-UX and Solaris.

For the complete updated text of this table please refer to the
appropriate "Installing and Using Clients" manual for your system.


11.9  Using DDCS with Bull SNA on AIX 4.1

If Bull DPX/20 SNA/20 Server is installed prior to installing
DDCS Multi-User Gateway Version 2.1.1 then DDCS is automatically
configured to use Bull SNA, otherwise DDCS is configured to work
with IBM SNA Server.

To determine if Bull SNA is installed on your AIX 4.1 system issue the
command:

  lslpp -l express.exsrv+dsk

If Bull SNA is installed then you will see output similar to the
following:

    Fileset                      Level  State      Description
    ----------------------------------------------------------------------
  Path: /usr/lib/objrepos
    express.exsrv+dsk          2.1.3.0  COMMITTED  EXPRESS SNA Server and
                                                   Integrated Desktop

If you install Bull SNA after installing DDCS Multi-User Gateway and
you want DDCS to use Bull SNA instead of IBM SNA Server then logon as
root and run the command:

              /usr/lpp/db2_02_01/cfg/db2cfgos


11.9.1  Installing Bull SNA Support with DB2/6000 Client or Gateway

If you wish to install the Bull DPX/20 SNA/20 Server, then you must
have the following:

SOFTWARE:

o   AIX V4.1.4

o   Express SNA Server V2.1.3

You will also need the Bull DPX/20 SNA/20 Server Configuration Guide.

Note:  The DB2/6000 Gateway when used with the Bull SNA server,
cannot have inbound APPC connections from remote clients.
It can only have outbound APPC connections to the host.

11.9.1.1  Configuring the Bull DPX/20 SNA/20 Server

The following is a sample configuration:

                 Client             Controller  Server (MVS)
                 -----------------  ----------  ------------
   Host name     robocop
   LU 6.2 name   SPIFNET.NYX1GW01   NYX         NYM2DB2

Use the command express to configure the following:

     Config         Express           Default configuration for EXPRESS
      Node          NYX1              SPIFNET.NYX1 (HOSTNAME=ROBOCOP)
       Indep. LUs   6.2 LUs Using All Stations
         LU         NYX1              Control Point LU
       Link         tok0.00001        Link (tok0)
        Station     MVS               To MVS from ROBOCOP
         LU         NYX1GW01          To MVS from ROBOCOP
          LU Pair   NYM2DB2           To MVS from ROBOCOP
           Mode     IBMRDB            IBMRDB

Default values are used for fields not listed.

   Defining hardware:

   System (hostname) = robocop
   Adapter and Port  = robocop.tok0
     MAC Address     = 400011529778

   Defining SNA node:

   Name          = NYX1
   Description   = SPIFNET.NYX1 (HOSTNAME=ROBOCOP)
   Network ID    = SPIFNET
   Control Point = NYX1
   XID Block     = 05D
   XID ID        = 29778

   Defining token ring link:

   Name            = tok0.00001
   Description     = Link (tok0)
   Connection Network name
     Network ID    = SPIFNET
     Control Point = NYX

   Defining token ring station:

   Name               = MVS
   Description        = To MVS from ROBOCOP
   Remote MAC address = 400009451902
   Remote Node name
     Network ID       = SPIFNET
     Control Point    = NYX

   Defining Local LU 6.2:

   Name        = NYX1GW01
   Description = To MVS from ROBOCOP
   Network ID  = SPIFNET
   LU name     = NYX1GW01

   Defining Remote LU 6.2:

   Name                 = NYM2DB2
   Description          = To MVS from ROBOCOP
   Network ID           = SPIFNET
   LU name              = NYM2DB2
   Remote Network ID    = SPIFNET
   Remote Control Point = NYX
   Uninterpreted Name   = NYM2DB2

   Defining Mode:

   Name             = IBMRDB
   Description      = IBMRDB
   Class of service = #CONNECT

   Defining Symbolic Destination Info:

   Name        = DB2CPIC
   Description = To MVS from ROBOCOP
   Partner LU  = SPIFNET.NYM2DB2
   Mode        = IBMRDB
   Local LU    = NYX1GW01
   Partner TP  = DB2DRDA

===============================
12.  Sample Tools and Utilities

A number of sample tools and utilities have been provided with this
product for your convenience. These samples are provided "as-is"
without any warranty of any kind.  However, if you encounter an error,
let us know.

The sample tools and utilities, except where noted, can be found in
the INSTHOME/sqllib/misc directory, where INSTHOME is the home
directory of the instance owner, after an instance has been created.

The following is a list of the sample tools and utilities provided:

Name          Description
----          -----------

db2batch      DB2 Dynamic SQL Statement Processor
              (Described in the Administration Guide)

db2bfd        DB2 Bind file description tool
              (Described in the Application Programming Guide)

db2cli        DB2 Interactive CLI (executable) for design and prototyping in CLI
              (Located in sqllib/samples/cli and described in INTCLI.DOC in same
              directory.)

db2evmon      Formats event monitor file and named pipe output, and writes it to
              standard out.
              (Described in the Performance Monitor Guide)

db2exfmt      Formats the contents of the Explain tables.
              Given a database name and other qualifying information,
              this tool will, query the Explain tables for information
              and format the results.
              (Located in sqllib/misc)
              Information about this utility is available by typing
              "db2exfmt -help" on a command line.

db2gov        DB2 Governor utility
              (Located in sqllib/adm)
              Periodically invokes DB2 Snapshot Monitor to find out what
              applications are using the database.  If any application is found that
              exceeds the limits specified in the Governor configuration files, that
              application is either terminated (FORCEd) or its priority is altered.
              Information about this utility is available by typing
              "db2gov -help" on a command line.

db2expln      DB2 SQL Explain Tool
              (Described in the Administration Guide)

db2ipxad      Returns the server's IPX/SPX** internetwork address for use by the
              user on a remote client machine who is cataloging an IPX/SPX node
              using direct addressing mode.
              (Mentioned in the Installing and Using OS/2 Clients and
              Installing and Using DB2 Clients for Windows manual)

db2look       DB2 statistics extraction tool
              (Described in the Administration Guide)

db2tbst       Takes a hexadecimal state value (as given from the
              "list tablespaces" command) and interprets the state.

              When you execute a DB2 command that leaves a tablespace in
              anything other than the normal state, using that
              tablespace may not be possible, but the cause of the
              problem is not always clear.  The "list tablespaces"
              command indicates the state in the form of a hexadecimal
              string which must be interpreted based on a combination
              of state values found in sqlutil.h.  Rather than perform
              this interpretation manually, the db2tbst applet may be
              used.  For example, if you enter db2tbst 0x000c,
              the following output is generated (in English only):

              State = Quiesced Exclusive
              + Load Pending

db2untag      Displays a container tag's information so that the sysadm can
              check the "owning" database.
              (Described in this README file in the section entitled
              Dealing with Container in Use Error Message -294)

dynexpln      Example of how to explain dynamic SQL using db2expln
              (Described in the Administration Guide)

explain.ddl   Sample DDL to create Explain tables
              (Described in the Administration Guide)

isql          Creates dummy tables to allow access from DB2/VM using ISQL.
              (Described in the Installation and Operation Guide)

lstaltsm      Sample DDL to retrieve alerts for Snapshot Monitor
              (Located in sqllib/samples/mon)
              (Described in the Database Director Getting Started)

sample.pv     Sample performance variable profile for Snapshot Monitor
              (Located in sqllib/samples/mon)
              (Described in the Database Director Getting Started)

sqldbsu       Creates dummy tables to allow access from DB2/VM using SQLDBSU.
              (Described in the Installation and Operation Guide)

storproc.ddl  Sample DDL to create stored procedures
              pseudo_catalog DB2CLI.PROCEDURES
              (Described in the Call Level Interface Guide and Reference)

storproc.dml  Sample DML to insert entries into stored procedure
              pseudo_catalog DB2CLI.PROCEDURES
              (Described in the Call Level Interface Guide and Reference)

vesampl.ddl   Sample DDL to export snapshots for Visual Explain
              (Located in sqllib/samples/ve)
              (Described in the Database Director Getting Started)


========================================
13.  Limitations in Documented Functions

This section identifies limitations that exist in the current release.


13.1  Transaction Manager Database Considerations

When Distributed Unit of Work (DUOW) is used, DB2 for AIX and DDCS for
AIX need to have a Transaction Manager (TM) database created.  While
this database is very much like any other DB2 database, there are
certain restrictions and considerations that should be taken into
account:

o   This is a system database for use by DB2.  It is recommended that
    it not be used for storing any other data.
o   The name of this database should not be made known to the general
    user population.
o   This database should not be accessed by DRDA client systems.
o   This database should not be catalogued in the DCS directory.
o   When the DDCS for AIX product is installed without DB2 for AIX,
    DDCS License Terms prohibit the use of this database for storing
    user data.


13.2  Recursive SQL Incompatibility

To correct a Version 2.1.0 memory overwrite problem, some recursive
SQL statements which use CONCAT with LOB fields in their SELECT lists
may no longer be valid.


13.3  Command and API Limitations

The following limitation exists for version 2.1.1:

o   When attempting to restore from tape, the tape drive must be
    configured with the same block size as the tape drive used to
    create the backup image.  So, the tape block factor (operating
    system parameter) should not be changed between backup and restore
    to/from tape.

o   The precompiler OPTLEVEL option indicates whether the precompiler
    is to optimize initialization of internal SQLDAs when host
    variables are used in SQL statements. The use of OPTLEVEL 1 to
    turn on SQLDA optimization has been disabled due to potential
    problems it may cause.  This is done at the runtime level, so that
    existing applications precompiled with OPTLEVEL 1 do not have to
    be reprecompiled. However, no SQLDA optimization will take place.
    This is OPTLEVEL 0 behaviour.


13.3.1  Remote Administration Command

The remote administration command LIST HISTORY ALL requires that the
client attach to the node first. Without attaching to the node first,
the command returns a 1427N (An instance attachment does not exist).


13.4  Call Level Interface Limitations


13.4.1  Limited Support for SQLDriverConnect on Motif Systems

In the Call Level Interface Guide and Reference, in Chapter 5,
"Functions", the SQLDriverConnect function is described.  This
function cannot display a dialog window in Motif (or Xwindows)
environments in Version 2.1.  (Motif is the GUI environment used by
UNIX environments.)  In Motif environments, the SQLDriverConnect
function will ignore the hwindow and fDriverCompletion arguments, and
always attempt to connect with the provided connection string.


13.5  WCHARTYPE CONVERT Precompile Option Limitation

In the Application Programming Guide, in Chapter 10, "Programming in C
and C++", under the heading "The WCHARTYPE Precompiler Option", the
WCHARTYPE CONVERT precompile option is described.

The WCHARTYPE CONVERT precompile option is not currently supported in
programs executing from the DB2 V2.1 Windows client.  In these cases
the default (WCHARTYPE NOCONVERT) should be used.


13.6  Using DB2 with an XA-Compliant Transaction Manager

When using Encina for transaction processing with DB2 through the
TM-XA interface, please note the following:

o   Encina nested transactions are not currently supported by the DB2
    XA interface.  If possible, avoid their use.  If their use cannot
    be avoided, make sure that SQL work is done in only one member of
    the Encina transaction family.
o   If a thread of control is associated with a particular transaction
    and intends to switch the association to a different transaction,
    it can do so only after resolving (committing or aborting) the
    transaction with which it is currently associated.


13.7  DB2 SNMP Subagent

The function of the DB2 SNMP Subagent is not currently available on
AIX.

This function is currently documented in the Problem Determination
Guide and in the Installation and Operation Guide.


13.8  Database Director Limitations

The Database Director cannot be used to manage DRDA servers.

The following 4 configuration parameters are not supported by the
Database Director:

adsm_password
adsm_nodename
adsm_owner
dft_queryopt

The main window of the Database Director has a 'Selected' menu in the
menu bar.  The 'Open as' item in this menu is disabled because it does
not work properly.  The identical function is available from the
pop-up menus in the window.


13.8.1  Mount Container

Under rare circumstances, it is possible that the DBA Utilities will
not return from an attempt to mount a file system to a container.  The
problem only occurs if resources are sufficient for the creation of
the file system, but insufficient for mounting.  If you experience
this problem, it is likely that you have marginal resources remaining
in the volume group you are creating the file system on.  To solve
this problem, exit the Database Director and re-attempt the action
using a volume group with more available resource.


13.8.2  Restriction for Visual Explain

The following restrictions apply to Visual Explain:

o   Connectivity between AIX clients and OS/2 servers and OS/2 clients
    and AIX servers is not supported.  You will not be able to invoke
    the access plan graph.

o   The client used to display an access plan graph must use the same
    code page as the database to which it is connected.

o   If you have created a snapshot in one code page, and are viewing
    the Access Plan graph for that snapshot in another code page, you
    will see unreadable characters for the names of database objects
    such as tables, columns, indices.

o   You can only display the Access Plan graph overview window once
    for every Access plan graph.  The overview menu item is grayed out
    and the overview icon is disabled once the overview window is
    opened the first time.


13.8.2.1  Snapshot Monitor

o   There is no limit to the number of performance variables that can
    be displayed on performance graphs on AIX and OS/2. However, the
    AIX graph can differentiate between 63 performance variables
    before it starts reusing the same combinations of line colors and
    point markers.  The limit for the OS/2 graph is 56 performance
    variables.  However, if you plan to change either the scale or
    threshold of a displayed performance variable on a graph on either
    platform, limit the number of displayed performance variables to
    20.  This limit becomes evident when using the "Change" menu
    action from the "Performance variable" pull down.

o   If you monitor in a code page that differs from the code page of
    the database, no performance data will be returned for monitored
    tables and table spaces, unless their names have the same
    representation in both code pages.

If you are using a DBCS version of the DB2 server, you will not be
able to put DBCS labels and performance variable names (including the
name, group name and description) in the variable profile of the
Performance Monitor.

Also, the IBM-supplied labels on the Performance Graph View will be
displayed in English.

The 2 labels are:

    x axis ... "Local time"
    y axis ... "Percent of SCALE"


13.8.2.2  Event Analyzer

When analyzing a trace and connecting to a remote AIX database, to
obtain static text using the -conn and -db options, you need to set
the database manager authentication parameter to 'client'.

If you have created an event monitor trace in one code page and
analyze it in a different code page, you may see unreadable characters
for the names of database objects such as packages, tables, and table
spaces.


13.9  Online Backup and Load with COPY NO option

At the end of a LOAD with the COPY NO option, the tablespace(s) are
put into Backup Pending state. Before backing up the loaded
tablespaces, all connections to the database must be terminated.  This
can be performed by issuing FORCE APPLICATION ALL and/or DEACTIVATE
DATABASE.

If an online backup is in progress, do not start a LOAD with the COPY
NO option.


==================
14.  Miscellaneous

14.1  DB2 Family Newsletter

For the latest information about the DB2 family of products, you may
subscribe to the "DB2 Family Newsletter" (English only).  Simply send
your request in a FAX to 1-905-316-4733, and include the following
information:

    Name
    Company name
    Full mailing address
    Telephone number
    DB2 products you currently use

-------------------------------------------------------------------

*  are trademarks or registered trademarks of IBM Corporation.

** are trademarks or registered trademarks of their respective owners.

-------------------------------------------------------------------

***********************************************************************
**                                                                   **
**  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1996.  **
**                    ALL RIGHTS RESERVED.                           **
**                                                                   **
***********************************************************************
 2608        179596      2844        834096583   2379        200         644         7   fixinfo `
********************************************************************
 Product Name : Database Server for AIX Version 4
 Package Name : U443307  (04.01.0001.3000) 
 Packaged By  : Jennifer Gibbs
 Package Date : April 30, 1996
 Build Level  : gold960316 
********************************************************************
 
APAR #  Defect Abstract
------- ------ -----------------------------------------------------
IX55458 39807   BACKUP WITHOUT PROMPTING fails when one device fills
IX56212 41038   multiple connect deadlock because we need to revoke 
IX56308 41300   DB2/6000 AS ABENDS when executes SELECT with a lot o
IX56408 41486   SQL2054N restoring V1 backup to V2 instance
IX56523 41659   Select statement causes signal #11 in sqlisr2
IX56584 41767   SQL0804 is return when updating a table on DB2/MVS
IX56633 41468   Missing +F sqlgmf and -ldb2gmf from db2mkrts.args fi
IX56664 41477   create db, TEMPSPACE was created as SMS while specif
IX56905 42348   DDCS Gateway looping 100% cpu with a certain select 
IX56928 42275   Activating db will causes exclusive connection to wo
IX57031 42454   SQL1035N from connect after activate/backup
IX57283 42909   Long field data corrupted when multiple processes wr
JR08866 41023   DDCS returns +100 for 2nd fetch when 1st fetch retur
JR08871 41093   CAE/WIN 2.1 generates a wrong qry for SQLTables for 
JR08880 41285   DB2/2 2.1.1 looking for APPC.DLL when Dos DB Req. tr
JR08890 41478   logging to remote database using ddcs or appc return
JR08891 41385   LOAD traps on OS/2 in sqlu_getfree
JR08892 41851   sql1002 from call to sqlecatd in down-level binary a
JR08893 40986   db2uexit indicator parameter should be 2
JR08895 41577   Engine crashes when using INTEGER on char column > 5
JR08898 41482   Add additional error checking and error mapping to s
JR08901 41741   optimization level 5 can choose bad access plan
JR08904 41777   The rexx api sqluimpr does not set the host varible 
JR08904 42395   fix code for the import API
JR08906 41802   OS/2 applications using sqlestrd get -1246 when issu
JR08912 41933   the rexx api sqluhops returns SQL2032
JR08915 41976   SQL0804N INSERTING BLOB from ODBC app
JR08916 41981   Behaviour of sqlurllf API not correct in DB2/2.
JR08917 42016   DB2NAME gets truncated when it is saved to DB2CLI.IN
JR08919 42072   SQLUB_PARM_CHECK action for sqlubkup API 'breaks' DB
JR08924 42210   Optimization level 5 takes too long
JR08925 42239   LOAD REPLACE gets SQL0901N reason -2551
JR08932 42634   SQL30082 rc=0 mapped to SQL1403 for NON v2.1.1 CAE c
JR08940 42523   SYS3175 in sqle_database_commit at CONNECT RESET

2608        182306      176890      834096576   2379        200         644         11  lpp.fixinfo `
********************************************************************
 Product Name : Database Server for AIX Version 4
 Package Name : U443307  (04.01.0001.3000) 
 Packaged By  : Jennifer Gibbs
 Package Date : April 30, 1996
 Build Level  : gold960316 
********************************************************************
 
APAR #  Defect Abstract
------- ------ -----------------------------------------------------
IX55458 39807   BACKUP WITHOUT PROMPTING fails when one device fills
IX56212 41038   multiple connect deadlock because we need to revoke 
IX56308 41300   DB2/6000 AS ABENDS when executes SELECT with a lot o
IX56408 41486   SQL2054N restoring V1 backup to V2 instance
IX56523 41659   Select statement causes signal #11 in sqlisr2
IX56584 41767   SQL0804 is return when updating a table on DB2/MVS
IX56633 41468   Missing +F sqlgmf and -ldb2gmf from db2mkrts.args fi
IX56664 41477   create db, TEMPSPACE was created as SMS while specif
IX56905 42348   DDCS Gateway looping 100% cpu with a certain select 
IX56928 42275   Activating db will causes exclusive connection to wo
IX57031 42454   SQL1035N from connect after activate/backup
IX57283 42909   Long field data corrupted when multiple processes wr
JR08866 41023   DDCS returns +100 for 2nd fetch when 1st fetch retur
JR08871 41093   CAE/WIN 2.1 generates a wrong qry for SQLTables for 
JR08880 41285   DB2/2 2.1.1 looking for APPC.DLL when Dos DB Req. tr
JR08890 41478   logging to remote database using ddcs or appc return
JR08891 41385   LOAD traps on OS/2 in sqlu_getfree
JR08892 41851   sql1002 from call to sqlecatd in down-level binary a
JR08893 40986   db2uexit indicator parameter should be 2
JR08895 41577   Engine crashes when using INTEGER on char column > 5
JR08898 41482   Add additional error checking and error mapping to s
JR08901 41741   optimization level 5 can choose bad access plan
JR08904 41777   The rexx api sqluimpr does not set the host varible 
JR08904 42395   fix code for the import API
JR08906 41802   OS/2 applications using sqlestrd get -1246 when issu
JR08912 41933   the rexx api sqluhops returns SQL2032
JR08915 41976   SQL0804N INSERTING BLOB from ODBC app
JR08916 41981   Behaviour of sqlurllf API not correct in DB2/2.
JR08917 42016   DB2NAME gets truncated when it is saved to DB2CLI.IN
JR08919 42072   SQLUB_PARM_CHECK action for sqlubkup API 'breaks' DB
JR08924 42210   Optimization level 5 takes too long
JR08925 42239   LOAD REPLACE gets SQL0901N reason -2551
JR08932 42634   SQL30082 rc=0 mapped to SQL1403 for NON v2.1.1 CAE c
JR08940 42523   SYS3175 in sqle_database_commit at CONNECT RESET

5996        188400      179596      834096565   2379        200         644         7   lpp.doc `
========================================================================
Database Server for AIX Version 4 Service Package U443307

Installation Instructions

Special Note to Non-English Customers
-------------------------------------

   If you are using a locale other than En_US/en_US, a new process has
   been put into place that affects the way you will install your 
   Service Pack language option updates. We have removed the language
   updates from our Service Packs and have provided installp images
   (*.pkg files) instead. This was done in order to decrease the size
   of our updatep images allowing customers to obtain our Service
   Packs more easily via our ftp site. In this way, you will only be
   required to download the language updates that you need rather than
   all of them. 

   The following chart illustrates what *.pkg files have been provided
   for each locale. Please ensure that you install these along with
   the U443307 update.
   -----------------------------------------
   | locale | doc*.pkg | msg*.pkg | ps*.pkg |      
   |--------|----------|----------|---------|
   | Fr_FR  |    y     |     y    |    y    |
   | fr_FR  |    n     |     y    |    n    |
   | De_DE  |    y     |     y    |    y    |
   | de_DE  |    n     |     y    |    n    |
   | Es_ES  |    y     |     y    |    y    |
   | es_ES  |    n     |     y    |    n    |
   | It_IT  |    y     |     y    |    y    |
   | it_IT  |    n     |     y    |    n    |
   | Ja_JP  |    y     |     y    |    n    |
   | ja_JP  |    n     |     y    |    n    |
   | ko_KR  |    y     |     y    |    y    |
   | zh_CN  |    y     |     y    |    y    |
   | pt_BR  |    y     |     y    |    y    |
   -----------------------------------------

   Also Note: If for any reason, you reject U443307, please ensure
   that you use your previous level of doc, msg, and ps files and
   NOT the updated versions which have a signature of 4.1.1.2.

Installation Considerations
---------------------------

   U443307 requires the following to already be installed on the
   machine:  

   04.01.0001.0002 Initial release of Database Server for AIX Version 4
   
   Use 'lslpp -l product_name' to list the level of Database Server on 
   the machine; product_name should be the name of an installable option
   such as db2_02_01.db2.rte.

   For more detailed information regarding this update, please refer
   to the README located under /usr/lpp/db2_02_01/Readme/<language 
   option> after installation. <language option> refers to one of
   option> En_US, Fr_FR, Ja_JP, etc.
   
Applying the PTF 
----------------

   For each instance:
   
     o  Ensure that all applications that are executing in the
        instance have stopped.

     o  Terminate all command line processor sessions (db2 terminate) 

     o  Ensure the instance has stopped (db2stop) 
   
     o  Stop the DB2 license daemon (db2licd end) 

   After each of your instances have stopped, run `/usr/sbin/slibclean`
   to remove the old versions of the libraries from memory.  For more
   information about slibclean, please refer to the man pages.

   Install the selected updates using either SMIT or installp.

     Place the db2_02_01.<option>.3000 update images and any *.pkg images
     in a directory <dir>. Run `/usr/sbin/inutoc .` as root in <dir> to
     regenerate the .toc file, and then issue the following:

      installp -qaXgd <dir> all

   Note: AIX 4.1 automatically installs options in COMMIT state.
   
   You will need to run the db2iupdt command to update your
   instances with the new executables. You will have to run this for
   each instance: 
   
   /usr/lpp/db2_02_01/instance/db2iupdt "instance name" [-u udfName]

   The -u parameter is optional. It allows you to define a user name
   (udfName) under which fenced user defined functions will run.
   
   AIX CICS users must perform the following three steps as documented
   in the CICS/6000 Administration Guide in section entitled:
   "Configuration steps for Database 2". 

     1) Create a DB2/6000 shared object from libdb2.a

     2) Build DB2 Switchload file and place in proper directory as
        defined by the XA definition for the database(s) which use the
        switch load file.

     3) If cobol, then re-run cicsmkcobol.

   Warning: If at a later time you add DB2 for AIX to a machine where
            the db2_02_01.client.3000 update is installed you must then 
            install the db2_02_01.db2.rte.3000 update. Otherwise the 
            software will be in an inconsistent state.

Rebinding
---------

   Due to the fact that many bind files have changed since
   04.01.0001.0002, it is NECESSARY that you rebind your bind
   files with their new package names. This can be done using the
   following instructions:

   If you use CAE for AIX, SDK for AIX, or DB2 for AIX, issue the
   following commands to re-bind the new bind files against each of
   your databases:

      1. db2 terminate
      2. db2 connect to <alias>
      3. db2 bind $INSTHOME/sqllib/bnd/@db2ubind.lst blocking all \ 
         grant public
      4. db2 terminate

    If you use DDCS for AIX to connect to a host database, you must
    re-bind ddcsmvs.lst, ddcs400.lst or ddcsvm.lst depending on whether
    the host is MVS , VM or VSE,  or AS/400 as follows:

       1. db2 terminate
       2. db2 connect to <alias> user <userID> using <passwd>
       3. db2 bind $INSTHOME/sqllib/bnd/@<ddcsxxx>.lst blocking all \
          sqlerror continue messages ddcs.msg grant public
       4. db2 terminate

   Where:

     <alias>   is the name of a database alias.
     <userID>  is the userID used to connect to the database.
     <passwd>  is the password associated with <userID>
     $INSTHOME is the absolute path of the database instance's home
               directory.

    Please refer to the manual "Distributed Database Connection
    Services User's Guide for common servers Version 2.3", Chapter 4
    for more details. 

223         0           182306      0           0           0           0           0   `
8           68          678         1168        1684        2844        176890      179596      182306      copyright db2_02_01.sdk.c.al db2_02_01.sdk.c.size db2_02_01.sdk.c.inventory lpp.README fixinfo lpp.fixinfo lpp.doc  of DatkD H  $        W
 R1R1ZU1         Y  W
     ./usr/lpp/db2_02_01/include/sql.h c/4.1.                    $          /******************************************************************************
** 
** Source File Name: SQL
** 
** (C) COPYRIGHT International Business Machines Corp. 1987, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function = Include File defining:
**              System Constants
**              National Language Support Information
**              SQLCA / SQLDA Constants
**              Interface to BINDER and PRECOMPILER
**              Error Message Retrieval Interface
**              Authorization Constants
** 
** Operating System: AIX
** 
*******************************************************************************/
#ifndef SQL_H_SQL
#define SQL_H_SQL

#ifdef __cplusplus
extern "C" {
#endif


/* Note: _SQLOLDCHAR defaults to 'char'.  See sqlsystm.h for details.         */

#include <stddef.h>                    
#include "sqlsystm.h"                  /* System dependent defines  */

#ifndef SQLCODE
#include "sqlca.h"                     /* Required include file    */
#endif

#pragma options align=power

/* System Constants                                                           */

#ifndef   SQL_RC_OK
#define SQL_RC_OK              0       /* successful execution                */
#endif

#define SQL_KEYPMAX            16      /* Maximum nbr of key parts in Index   */
#define SQL_KEYLMAX            255     /* Maximum key length                  */
#define SQL_SORTFLDLMT         254     /* Maximum size of field for sort      */
#define SQL_MAXRECL            4005    /* Maximum record length               */
#define SQL_MAXTABLES          15      /* Maximum nbr of tables in a SELECT   */
#define SQL_MAXSEL_ITEMS       255     /* Maximum nbr of items in a SELECT    */
#define SQL_MAXVARS_STMT       32767   /* Maximum nbr of Host Vars per stmt   */
#define SQL_MAXCOLS            255     /* Maximum nbr of columns in a table   */
#define SQL_MAXPARMS           90      /* Maximum nbr of parms in a function  */
#define SQL_MAX_STMT_SIZ       32765   /* Maximum statement size              */

#define SQL_SMALL_LENGTH       2       /* Size of a SMALLINT                  */
#define SQL_MAXSMALLVAL        32767   /* Maximum value of a SMALLINT         */
#define   SQL_MINSMALLVAL (-(SQL_MAXSMALLVAL)-1) /* Minimum value of a SMALLINT */
#define SQL_INT_LENGTH         4       /* Size of an INTEGER                  */
#define SQL_MAXINTVAL          2147483647 /* Maximum value of an INTEGER      */
#define   SQL_MININTVAL (-(SQL_MAXINTVAL)-1) /* Minimum value of an INTEGER  */
#define SQL_FLOAT_LENGTH       8       /* Size of a FLOAT                     */
#define SQL_DEFDEC_PRECISION   5       /* Default precision for DECIMAL       */
#define SQL_DEFDEC_SCALE       0       /* Default scale for DECIMAL           */
#define SQL_MAXDECIMAL         31      /* Maximum scale/prec. for DECIMAL     */
#define SQL_DEFCHAR            1       /* Default length for a CHAR           */
#define SQL_DEFWCHAR           1       /* Default length for a graphic        */
#define SQL_MAXCHAR            254     /* Maximum length of a CHAR            */
#define SQL_MAXLSTR            255     /* Maximum length of an LSTRING        */
#define SQL_MAXVCHAR           (SQL_MAXRECL-5) /* Maximum length of a         */
                                       /* VARCHAR                             */
#define SQL_MAXVGRAPH          2000    /* Maximum length of a VARGRAPHIC      */
#define SQL_MAXBLOB            2147483647 /* Max. length of a BLOB host var   */
#define SQL_MAXCLOB            2147483647 /* Max. length of a CLOB host var   */
#define SQL_MAXDBCLOB          1073741823 /* Max. length of an DBCLOB host    */
                                       /* var                                 */
#define SQL_LOBLOCATOR_LEN     4       /* Length of a LOB locator host var    */
#define SQL_LOBFILE_LEN        267     /* Length of a LOB file host var       */
#define SQL_VCHAROH            4       /* Overhead for VARCHAR in record      */
#define SQL_LONGMAX            32700   /* Maximum length of a LONG VARCHAR    */
#define SQL_LONGGRMAX          16350   /* Max. length of a LONG VARGRAPHIC    */
#define SQL_LVCHAROH           24      /* Overhead for LONG VARCHAR in        */
                                       /* record                              */
#define SQL_LOBCHAROH          312     /* Overhead for LOB in record          */
#define SQL_BLOB_MAXLEN        2147483647 /* BLOB maximum length, in bytes    */
#define SQL_CLOB_MAXLEN        2147483647 /* CLOB maximum length, in chars    */
#define SQL_DBCLOB_MAXLEN      1073741823 /* maxlen for dbcs lobs             */
#define SQL_TIME_LENGTH        3       /* Size of a TIME field                */
#define SQL_TIME_STRLEN        8       /* Size of a TIME field output         */
#define SQL_TIME_MINSTRLEN     5       /* Size of a non-USA TIME field        */
                                       /* output without seconds              */
#define SQL_DATE_LENGTH        4       /* Size of a DATE field                */
#define SQL_DATE_STRLEN        10      /* Size of a DATE field output         */
#define SQL_STAMP_LENGTH       10      /* Size of a TIMESTAMP field           */
#define SQL_STAMP_STRLEN       26      /* Size of a TIMESTAMP field output    */
#define SQL_STAMP_MINSTRLEN    19      /* Size of a TIMESTAMP field output    */
                                       /* without microseconds                */
#define SQL_BOOLEAN_LENGTH     1       /* Size of a BOOLEAN field             */
#define SQL_IND_LENGTH         2       /* Size of an indicator value          */

#define SQL_MAX_PNAME_LENGTH   254     /* Max size of Stored Proc Name        */
#define SQL_LG_IDENT           18      /* Maximum length of Long Identifer    */
#define SQL_SH_IDENT           8       /* Maximum length of Short Identifer   */
#define SQL_MN_IDENT           1       /* Minimum length of Identifiers       */
#define SQL_MAX_VAR_NAME       30      /* Max size of Host Variable Name      */
#define SQL_KILO_VALUE         1024    /* # of bytes in a kilobyte            */
#define SQL_MEGA_VALUE         1048576 /* # of bytes in a megabyte            */
#define SQL_GIGA_VALUE         1073741824 /* # of bytes in a gigabyte         */

#define SQLB_MAX_CONTAIN_NAME_SZ 256   /* size of container name for api's    */
                                       /* (includes 1 byte for C NULL         */
                                       /* terminator)                         */

/* Codepages                                                                  */
#define SQL_CP_367             367     /* Codepage 367 - EUC single byte      */
#define SQL_CP_437             437     /* Codepage 437 - US, Europe           */
#define SQL_CP_813             813     /* Codepage 813 - AIX Greece           */
#define SQL_CP_819             819     /* Codepage 819 - ISO 8859-1           */
#define SQL_CP_850             850     /* Codepage 850 - International PC     */
#define SQL_CP_855             855     /* Codepage 855 - OS2 Cyrillic         */
#define SQL_CP_852             852     /* Codepage 852 - OS2 Latin2           */
#define SQL_CP_857             857     /* Codepage 857 - OS2 Turkey           */
#define SQL_CP_860             860     /* Codepage 860 - Portuguese           */
#define SQL_CP_862             862     /* Codepage 862 - OS2 Hebrew           */
#define SQL_CP_863             863     /* Codepage 863 - Canadian-French      */
#define SQL_CP_864             864     /* Codepage 863 - OS2 Arabic           */
#define SQL_CP_865             865     /* Codepage 865 - Norway, Denmark      */
#define SQL_CP_866             866     /* Codepage 866 - Russia               */
#define SQL_CP_869             869     /* Codepage 869 - OS2 Greece           */
#define SQL_CP_874             874     /* Codepage 874 - OS2/AIX Thailand     */
#define SQL_CP_891             891     /* Codepage 891 - Korean               */
#define SQL_CP_897             897     /* Codepage 897 - Japanese             */
#define SQL_CP_903             903     /* Codepage 903 - Chinese              */
#define SQL_CP_904             904     /* Codepage 904 - Taiwan               */
#define SQL_CP_912             912     /* Codepage 912 - AIX Latin2           */
#define SQL_CP_915             915     /* Codepage 915 - AIX Cyrillic         */
#define SQL_CP_916             916     /* Codepage 916 - AIX Hebrew           */
#define SQL_CP_920             920     /* Codepage 920 - AIX Turkey           */
#define SQL_CP_1004            1004    /* Codepage 1004 - MS-WINDOWS          */
#define SQL_CP_1040            1040    /* Codepage 1040 - Extended Korean     */
#define SQL_CP_1041            1041    /* Codepage 1041 - Extended Japanese   */
#define SQL_CP_1042            1042    /* Codepage 1042 - Extended Chinese    */
#define SQL_CP_1043            1043    /* Codepage 1043 - Extended Taiwan     */
#define SQL_CP_1046            1046    /* Codepage 1046 - AIX Arabic          */
#define SQL_CP_1051            1051    /* Codepage 1051 - HP Roman8           */
#define SQL_CP_1088            1088    /* Codepage 1088 - Korea Std           */
#define SQL_CP_1089            1089    /* Codepage 1089 - AIX Arabic          */
#define SQL_CP_1114            1114    /* Codepage 1114 - Taiwan Big-5        */
#define SQL_CP_1115            1115    /* Codepage 1115 - China GB            */
#define SQL_CP_1250            1250    /* Codepage 1250 - Windows Latin-2     */
#define SQL_CP_1251            1251    /* Codepage 1251 - Windows Cyrillic    */
#define SQL_CP_1252            1252    /* Codepage 1252 - Windows Latin-1     */
#define SQL_CP_1253            1253    /* Codepage 1253 - Windows Greek       */
#define SQL_CP_1254            1254    /* Codepage 1254 - Windows Turkish     */
#define SQL_CP_1255            1255    /* Codepage 1255 - Windows Hebrew      */
#define SQL_CP_1256            1256    /* Codepage 1256 - Windows Arabic      */
#define SQL_CP_1275            1275    /* Codepage 1275 - Mac Latin-1         */
#define SQL_CP_1280            1280    /* Codepage 1280 - Mac Greek           */
#define SQL_CP_1281            1281    /* Codepage 1281 - Mac Turkish         */
#define SQL_CP_1282            1282    /* Codepage 1282 - Mac Latin-2         */
#define SQL_CP_1283            1283    /* Codepage 1283 - Mac Cyrillic        */

/* DBCS Codepages                                                             */
#define SQL_CP_926             926     /* Codepage 926 - Korean               */
#define SQL_CP_951             951     /* Codepage 951 - New Korean           */
#define SQL_CP_301             301     /* Codepage 301 - Japanese             */
#define SQL_CP_928             928     /* Codepage 928 - Chinese              */
#define SQL_CP_927             927     /* Codepage 927 - Taiwan               */
#define SQL_CP_941             941     /* Codepage 941 - Japanese             */
#define SQL_CP_947             947     /* Codepage 947 - Taiwan Big-5         */
#define SQL_CP_971             971     /* Codepage 971 - Korean 5601          */
#define SQL_CP_1380            1380    /* Codepage1380 - China GB             */
#define SQL_CP_1382            1382    /* Codepage1382 - Simp Chinese GB      */
#define SQL_CP_13488           13488   /* Codepage13488 - UCS-2               */

/* Combined Codepages                                                         */
#define SQL_CP_934             934     /* Codepage 891 + 926 - Korean         */
#define SQL_CP_949             949     /* CP 1088 + 951 - Korean Std          */
#define SQL_CP_932             932     /* Codepage 897 + 301 - Japanese       */
#define SQL_CP_936             936     /* Codepage 903 + 928 - Chinese        */
#define SQL_CP_938             938     /* Codepage 904 + 927 - Taiwan         */
#define SQL_CP_944             944     /* Codepage 1040 + 926 - Ext.Korean    */
#define SQL_CP_942             942     /* Codepage 1041 + 301 - Ext.Japanese  */
#define SQL_CP_943             943     /* Codepage 1041 + 941 - Ext.Japanese  */
#define SQL_CP_946             946     /* Codepage 1042 + 928 - Ext.Chinese   */
#define SQL_CP_948             948     /* Codepage 1043 + 927 - Ext.Taiwan    */
#define SQL_CP_950             950     /* Codepage 1114 + 947 - Taiwan Big5   */
#define SQL_CP_954             954     /* Codepage 954 + 13488 - euc Japan    */
#define SQL_CP_964             964     /* Codepage 964 + 13488 - euc Taiwan   */
#define SQL_CP_970             970     /* Codepage  367 + 971 - Korean 5601   */
#define SQL_CP_1381            1381    /* Codepage 1115 +1380 - China GB      */
#define SQL_CP_1383            1383    /* Codepage  367 +1382 - Chinese GB    */

/* Datastream Types                                                           */
#define SQL_SBC_PC             0       /* Single byte PC                      */
#define SQL_JPN_PC             1       /* Japanese-PC                         */
#define SQL_CHN_PC             2       /* Chinese-PC                          */
#define SQL_KOR_PC             3       /* Korean-PC                           */
#define SQL_KSC_PC             4       /* New Korean-PC                       */
#define SQL_KR5_PC             5       /* Korean 5601                         */
#define SQL_TWN_PC             6       /* Taiwan Big-5                        */
#define SQL_CGB_PC             7       /* China GB                            */
#define SQL_CGBA_PC            8       /* China GB on AIX                     */
#define SQL_EUCJP_PC           9       /* Japan euc                           */
#define SQL_EUCTW_PC           10      /* Taiwan euc                          */
#define SQL_UCS2_PC            11      /* UCS-2                               */
#define SQL_UNKN_PC            255     /* Unknown                             */

/* AIX codeset & locale lengths                                               */
#define SQL_CODESET_LEN        9
#define SQL_LOCALE_LEN         5

/* SQLCA Constants                                                            */
#ifndef SQL_RC_INVALID_SQLCA
#endif

/* Size of SQLCA                                                              */
#define SQLCA_SIZE             sizeof(struct sqlca)

/* SQL Error message token delimiter                                          */
#define SQL_ERRMC_PRES ((char) 0xFF) /* delimiter for string entry */

/* Offset in SQLERRD - Diagnostic information                                 */
#define SQL_ERRD_RC            0       /* return code                         */
#define SQL_ERRD_REAS          1       /* reason code                         */
#define SQL_ERRD_CNT           2       /* nbr rows inserted/updated/deleted   */
#define SQL_ERRD_OPT_CARD      2       /* optimizer estimate of # rows        */
#define SQL_ERRD_OPTM          3       /* obsolete -- do not use --           */
#define SQL_ERRD_OPT_TOTCOST   3       /* optimzer estimate of total cost     */
#define SQL_ERRD_DCNT          4       /* nbr of cascaded deletes/updates     */
#define SQL_ERRD_LINE          4       /* line number for recompile error     */
#define SQL_ERRD_DIAG          5       /* diagnostics                         */

/* Indexes in SQLWARN - Warning flags                                         */
#define SQL_WARN_ANY           0       /* composite - set if any warnings     */
#define SQL_WARN_TRUNC         1       /* string column truncated             */
#define SQL_WARN_NUL           2       /* null values eliminated              */
#define SQL_WARN_MISM          3       /* nbr of columns/host vars mismatch   */
#define SQL_WARN_ALLR          4       /* no WHERE clause in update/delete    */
#define SQL_WARN_DATE          6       /* date has been truncated             */
#define SQL_WARN_SUB           8       /* character conversion substitution   */
#define SQL_WARN_SQLCA         10      /* SQLCA conversion error              */

/* Values for Warning flags in SQLWARN                                        */
#define SQL_WARNING            'W'     /* warning indicator                   */
#define SQL_NULL_TRN           'N'     /* null terminator truncated warning   */
#define SQL_TRN_APP_LEN        'X'     /* truncation warning with             */
                                       /* application context length          */
                                       /* returned in sqlind                  */
#define SQL_NO_WARN            ' '     /* no warning indicator                */

/* SQLDA Constants                                                            */

/* Increment for type with null indicator                                     */
#define SQL_TYP_NULINC         1

/* Variable Types                                                             */
#define SQL_TYP_DATE           384     /* DATE                                */
#define SQL_TYP_NDATE          (SQL_TYP_DATE+SQL_TYP_NULINC)

#define SQL_TYP_TIME           388     /* TIME                                */
#define SQL_TYP_NTIME          (SQL_TYP_TIME+SQL_TYP_NULINC)

#define SQL_TYP_STAMP          392     /* TIMESTAMP                           */
#define SQL_TYP_NSTAMP         (SQL_TYP_STAMP+SQL_TYP_NULINC)

#define SQL_TYP_CGSTR          400     /* C NUL-terminated graphic str        */
#define SQL_TYP_NCGSTR         (SQL_TYP_CGSTR+SQL_TYP_NULINC)

#define SQL_TYP_BLOB           404     /* BLOB - varying length string        */
#define SQL_TYP_NBLOB          (SQL_TYP_BLOB+SQL_TYP_NULINC)

#define SQL_TYP_CLOB           408     /* CLOB - varying length string        */
#define SQL_TYP_NCLOB          (SQL_TYP_CLOB+SQL_TYP_NULINC)

#define SQL_TYP_DBCLOB         412     /* DBCLOB - varying length string      */
#define SQL_TYP_NDBCLOB        (SQL_TYP_DBCLOB+SQL_TYP_NULINC)

#define SQL_TYP_VARCHAR        448     /* VARCHAR(i) - varying length string  */
                                       /* (2 byte length)                     */
#define SQL_TYP_NVARCHAR       (SQL_TYP_VARCHAR+SQL_TYP_NULINC)

#define SQL_TYP_CHAR           452     /* CHAR(i) - fixed length string       */
#define SQL_TYP_NCHAR          (SQL_TYP_CHAR+SQL_TYP_NULINC)

#define SQL_TYP_LONG           456     /* LONG VARCHAR - varying length       */
                                       /* string                              */
#define SQL_TYP_NLONG          (SQL_TYP_LONG+SQL_TYP_NULINC)

#define SQL_TYP_CSTR           460     /* varying length string for C (null   */
                                       /* terminated)                         */
#define SQL_TYP_NCSTR          (SQL_TYP_CSTR+SQL_TYP_NULINC)

#define SQL_TYP_VARGRAPH       464     /* VARGRAPHIC(i) - varying length      */
                                       /* graphic string (2 byte length)      */
#define SQL_TYP_NVARGRAPH      (SQL_TYP_VARGRAPH+SQL_TYP_NULINC)

#define SQL_TYP_GRAPHIC        468     /* GRAPHIC(i) - fixed length graphic   */
                                       /* string                              */
#define SQL_TYP_NGRAPHIC       (SQL_TYP_GRAPHIC+SQL_TYP_NULINC)

#define SQL_TYP_LONGRAPH       472     /* LONG VARGRAPHIC(i) - varying        */
                                       /* length graphic string               */
#define SQL_TYP_NLONGRAPH      (SQL_TYP_LONGRAPH+SQL_TYP_NULINC)

#define SQL_TYP_LSTR           476     /* varying length string for Pascal    */
                                       /* (1-byte length)                     */
#define SQL_TYP_NLSTR          (SQL_TYP_LSTR+SQL_TYP_NULINC)

#define SQL_TYP_FLOAT          480     /* FLOAT - 8-byte floating point       */
#define SQL_TYP_NFLOAT         (SQL_TYP_FLOAT+SQL_TYP_NULINC)

#define SQL_TYP_DECIMAL        484     /* DECIMAL (m,n)                       */
#define SQL_TYP_NDECIMAL       (SQL_TYP_DECIMAL+SQL_TYP_NULINC)

#define SQL_TYP_ZONED          488     /* Zoned Decimal -> DECIMAL (m,n)      */
#define SQL_TYP_NZONED         (SQL_TYP_ZONED+SQL_TYP_NULINC)

#define SQL_TYP_INTEGER        496     /* INTEGER - 4-byte signed integer     */
#define SQL_TYP_NINTEGER       (SQL_TYP_INTEGER+SQL_TYP_NULINC)

#define SQL_TYP_SMALL          500     /* SMALLINT - 2-byte signed integer    */
#define SQL_TYP_NSMALL         (SQL_TYP_SMALL+SQL_TYP_NULINC)

#define SQL_TYP_NUMERIC        504     /* NUMERIC -> DECIMAL (m,n)            */
#define SQL_TYP_NNUMERIC       (SQL_TYP_NUMERIC+SQL_TYP_NULINC)

#define SQL_TYP_BLOB_FILE      804     /* BLOB File - Binary Large Object     */
                                       /* File                                */
#define SQL_TYP_NBLOB_FILE     (SQL_TYP_BLOB_FILE+SQL_TYP_NULINC)

#define SQL_TYP_CLOB_FILE      808     /* CLOB File - Char Large Object File  */
#define SQL_TYP_NCLOB_FILE     (SQL_TYP_CLOB_FILE+SQL_TYP_NULINC)

#define SQL_TYP_DBCLOB_FILE    812     /* DBCLOB File - Double Byte Char      */
                                       /* Large Object File                   */
#define SQL_TYP_NDBCLOB_FILE   (SQL_TYP_DBCLOB_FILE+SQL_TYP_NULINC)

#define SQL_TYP_BLOB_LOCATOR   960     /* BLOB locator                        */
#define SQL_TYP_NBLOB_LOCATOR  (SQL_TYP_BLOB_LOCATOR+SQL_TYP_NULINC)

#define SQL_TYP_CLOB_LOCATOR   964     /* CLOB locator                        */
#define SQL_TYP_NCLOB_LOCATOR  (SQL_TYP_CLOB_LOCATOR+SQL_TYP_NULINC)

#define SQL_TYP_DBCLOB_LOCATOR 968     /* DBCLOB locator                      */
#define SQL_TYP_NDBCLOB_LOCATOR (SQL_TYP_DBCLOB_LOCATOR+SQL_TYP_NULINC)

#define SQL_LOBTOKEN_LEN       SQL_LOBLOCATOR_LEN
#define SQL_TYP_BLOB_TOKEN     SQL_TYP_BLOB_LOCATOR
#define SQL_TYP_NBLOB_TOKEN    SQL_TYP_NBLOB_LOCATOR
#define SQL_TYP_CLOB_TOKEN     SQL_TYP_CLOB_LOCATOR
#define SQL_TYP_NCLOB_TOKEN    SQL_TYP_NCLOB_LOCATOR
#define SQL_TYP_DBCLOB_TOKEN   SQL_TYP_DBCLOB_LOCATOR
#define SQL_TYP_NDBCLOB_TOKEN  SQL_TYP_NDBCLOB_LOCATOR
#define SQL_NCLOB_MAXLEN       SQL_DBCLOB_MAXLEN
#define SQL_LOBHANDLE_LEN      SQL_LOBTOKEN_LEN
#define SQL_TYP_BLOB_HANDLE    SQL_TYP_BLOB_TOKEN
#define SQL_TYP_NBLOB_HANDLE   SQL_TYP_NBLOB_TOKEN
#define SQL_TYP_CLOB_HANDLE    SQL_TYP_CLOB_TOKEN
#define SQL_TYP_NCLOB_HANDLE   SQL_TYP_NCLOB_TOKEN
#define SQL_TYP_DBCLOB_HANDLE  SQL_TYP_DBCLOB_TOKEN
#define SQL_TYP_NDBCLOB_HANDLE SQL_TYP_NDBCLOB_TOKEN

/* Return Codes for sqlabndx and sqlaprep                                     */
#define SQLA_RC_OPT_IGNORED    20      /* The option(s) specified are not     */
                                       /* supported by the target  database   */
                                       /* and will be ignored                 */
#define SQLA_RC_BINDWARN       25      /* Bind execution succeeded with       */
                                       /* warnings.                           */
#define SQLA_RC_PREPWARN       25      /* Precompilation succeeded with       */
                                       /* warnings.                           */
#define SQLA_RC_BINDERROR      -1      /* Bind execution failed               */
#define SQLA_RC_PREPERROR      -1      /* Precompilation failed               */
#define SQLA_RC_BAD_BINDNAME   -2      /* Invalid bind file                   */
#define SQLA_RC_BAD_DBNAME     -3      /* Invalid database                    */
#define SQLA_RC_BAD_MSGNAME    -5      /* Invalid message file                */
#define SQLA_RC_BAD_FORMAT     -6      /* Invalid format                      */
#define SQLA_RC_OPEN_ERROR     -31     /* Error opening list file             */
#define SQLA_RC_MFILE_OPEN_ERR -35     /* Error opening message file          */
#define SQLA_RC_FILE_NAME_BAD  -36     /* Source file name is invalid         */
#define SQLA_RC_BAD_BNDFILE    -39     /* Bind file corrupted                 */
#define SQLA_RC_LIST_ERROR     -40     /* Bind list errors                    */
#define SQLA_RC_INTERRUPT      -94     /* Interrupt                           */
#define SQLA_RC_OSERROR        -1086   /* System error                        */
#define SQLA_RC_PREP_BIND_BUSY -1392   /* Prep/Bind already in use            */
#define SQLA_RC_OPTION_LEN_BAD -4903   /* Invalid parm. length                */
#define SQLA_RC_OPTION_PTR_BAD -4904   /* Invalid parm. ptr                   */
#define SQLA_RC_OPTION_SIZE_BAD -4905  /* Invalid parm. size                  */
#define SQLA_RC_OPTION_DATA_BAD -4917  /* Invalid parm. data                  */
#define SQLA_RC_OPTION_INVALID -4930   /* Invalid option or option value      */
#define SQLA_RC_SDK_LICENSE    -8005   /* No SDK/6000 license                 */

/* Values used for the date/time format parameter of sqlabind() ** OBSOLETE   */
/* **                                                                         */
#define SQL_FMT_DEF            "DEF"   /* FORMAT = Default for Country Code   */
#define SQL_FMT_USA            "USA"   /* FORMAT = USA                        */
#define SQL_FMT_EUR            "EUR"   /* FORMAT = EUR                        */
#define SQL_FMT_ISO            "ISO"   /* FORMAT = ISO                        */
#define SQL_FMT_JIS            "JIS"   /* FORMAT = JIS                        */
#define SQL_FMT_LOC            "LOC"   /* FORMAT = LOCAL                      */

/* The size of a date/time format buffer                                      */
#define SQL_FMT_LENGTH         3

/* Structures used system wide                                                */

#ifndef SQL_SQLDBCHAR_DEFN
#define SQL_SQLDBCHAR_DEFN
  typedef unsigned short sqldbchar;
#endif

SQL_STRUCTURE sqlchar                  /* General-purpose VARCHAR for         */
                                       /* casting                             */
{
        short                  length;
        _SQLOLDCHAR            data[1];
};

SQL_STRUCTURE sqlgraphic               /* General-purpose VARGRAPHIC for      */
                                       /* casting                             */
{
        short                  length;
#ifdef SQL_WCHART_CONVERT
        wchar_t                data[1];
#else
        sqldbchar              data[1];
#endif
};

SQL_STRUCTURE sqllob                   /* General-purpose LOB for casting     */
{
        unsigned long          length;
        char                   data[1];
};

SQL_STRUCTURE sqldbclob                /* General-purpose DBCLOB for casting  */
{
        unsigned long          length;
#ifdef SQL_WCHART_CONVERT
        wchar_t                data[1];
#else
        sqldbchar              data[1];
#endif
};

SQL_STRUCTURE sqlfile                  /* File reference structure for LOBs   */
{
        unsigned long          name_length;
        unsigned long          data_length;
        unsigned long          file_options;
        char                   name[255];
};

/* Values used for file_options in the sqlfile structure                      */
#define SQL_FILE_READ          2       /* Input file to read from             */
#define SQL_FILE_CREATE        8       /* Output file - new file to be        */
                                       /* created                             */
#define SQL_FILE_OVERWRITE     16      /* Output file - overwrite existing    */
                                       /* file or create a new file if it     */
                                       /* doesn't exist                       */
#define SQL_FILE_APPEND        32      /* Output file - append to an          */
                                       /* existing file or create a new file  */
                                       /* if it doesn't exist                 */

/* Structure used to store binder options when calling sqlabndr()             */
/* or sqlabndx() or to store precompile options when calling                  */
/* sqlaprep().                                                                */

#define sqlbindopt sqloptions

#ifndef SQL_BIND_OPTS

SQL_STRUCTURE sqloptheader     /* Header for sqlopt structure */
{
   unsigned long allocated; /* Number of options allocated */
   unsigned long used; /* Number of options used */
};

SQL_STRUCTURE sqloptions       /* bind/prep option          */
{
   unsigned long type; /* Type  of bind/prep option */
   unsigned long val; /* Value of bind/prep option */
};

SQL_STRUCTURE sqlopt
{
   SQL_STRUCTURE sqloptheader header;     /* Header for sqlopt structure */
   SQL_STRUCTURE sqloptions   option[1];  /* Array of bind/prep options  */
};

#define SQL_BIND_OPTS
#endif

/* Values used for option[n].type in the sqloptions structure                 */
/* of sqlabndx() and sqlaprep().                                              */
#define SQL_DATETIME_OPT       1       /* Option for date/time format - bind  */
                                       /* and precompile option               */
#define SQL_STANDARDS_OPT      2       /* Option for standards level          */
                                       /* compliance - precompile option      */
                                       /* only                                */
#define SQL_ISO_OPT            4       /* Option for isolation level - bind   */
                                       /* and precompile option               */
#define SQL_BLOCK_OPT          5       /* Option for record blocking - bind   */
                                       /* and precompile option               */
#define SQL_GRANT_OPT          6       /* Option for granting privileges -    */
                                       /* bind option only                    */
#define SQL_FLAG_OPT           8       /* Option for the Flagger -            */
                                       /* precompile option only              */
#define SQL_CONNECT_OPT        16      /* Specifies whether one or multiple   */
                                       /* connections are allowed             */
                                       /* similtaneously within a unit of     */
                                       /* work.                               */
#define SQL_RULES_OPT          17      /* Specifies the set of rules used     */
                                       /* for connection to multiple          */
                                       /* databases within a single unit of   */
                                       /* work                                */
#define SQL_DISCONNECT_OPT     18      /* Specifies which of multiple         */
                                       /* databases connected to will be      */
                                       /* disconnected when a COMMIT or       */
                                       /* ROLLBACK is issued.                 */
#define SQL_SYNCPOINT_OPT      19      /* Specifies what syncpoint option     */
                                       /* (for example one phase or two       */
                                       /* phase) will be used                 */
#define SQL_BIND_OPT           20      /* Option to create a bind file -      */
                                       /* precompile option only              */
#define SQL_SAA_OPT            21      /* Option specifies SAA/non-SAA        */
                                       /* compatibility - FORTRAN precompile  */
                                       /* option only                         */
#define SQL_PKG_OPT            23      /* Option to create a package with a   */
                                       /* specific name - precompile option   */
                                       /* only                                */
#define SQL_OPTIM_OPT          24      /* Option to specify SQLDA             */
                                       /* optimization - precompile option    */
                                       /* only                                */
#define SQL_SYNTAX_OPT         25      /* Option to not create a package or   */
                                       /* bind file - precompile option only  */
#define SQL_SQLERROR_OPT       SQL_SYNTAX_OPT /* Indicates under what         */
                                       /* conditions a package will be be     */
                                       /* created - bind and precompile       */
                                       /* option                              */
#define SQL_LINEMACRO_OPT      26      /* Option to suppress #line macro      */
                                       /* generation in modified source file  */
                                       /* - C precompile option only          */
#define SQL_NO_OPT             27      /* 'No-op' option - ignore this entry  */
                                       /* in the option array - bind and      */
                                       /* precompile option                   */
#define SQL_LEVEL_OPT          30      /* Level of a module - precompile      */
                                       /* option only                         */
#define SQL_COLLECTION_OPT     31      /* Package collection identifier -     */
                                       /* precompile option only              */
#define SQL_VERSION_OPT        32      /* Package version identifier -        */
                                       /* precompile option only              */
#define SQL_OWNER_OPT          33      /* Package owner authorization         */
                                       /* identifier - bind and precompile    */
                                       /* option                              */
#define SQL_SCHEMA_OPT         SQL_OWNER_OPT /* Synonym for owner - bind and  */
                                       /* precompile option                   */
#define SQL_QUALIFIER_OPT      34      /* Authorization identifier that is    */
                                       /* to be used as a qualifier for       */
                                       /* unqualified objects - bind and      */
                                       /* precompile option                   */
#define SQL_CATALOG_OPT        SQL_QUALIFIER_OPT /* Synonym for qualifier -   */
                                       /* bind and precompile option          */
#define SQL_TEXT_OPT           35      /* Package description - bind and      */
                                       /* precompile option                   */
#define SQL_VALIDATE_OPT       40      /* Indicates when object validation    */
                                       /* occurs - bind and precompile        */
                                       /* option                              */
#define SQL_EXPLAIN_OPT        41      /* Determines whether information      */
                                       /* will be produced about how the SQL  */
                                       /* statements in a package will be     */
                                       /* executed - bind and precompile      */
                                       /* option                              */
#define SQL_ACTION_OPT         42      /* Indicates whether a package is to   */
                                       /* be added or replaced - bind and     */
                                       /* precompile option                   */
#define SQL_REPLVER_OPT        44      /* Replaces a specific version of a    */
                                       /* package - bind and precompile       */
                                       /* option                              */
#define SQL_RETAIN_OPT         45      /* Indicates whether EXECUTE           */
                                       /* authorities are to be preserved     */
                                       /* when a package is replaced - bind   */
                                       /* and precompile option               */
#define SQL_RELEASE_OPT        46      /* Indicates whether resources are     */
                                       /* released at each COMMIT or when     */
                                       /* the application  terminates - bind  */
                                       /* and precompile option               */
#define SQL_DEGREE_OPT         47      /* Specifies whether or not the query  */
                                       /* is executed using I/O parallelism   */
                                       /*  bind and precompile option         */
#define SQL_STRDEL_OPT         50      /* Designates whether an apostrophe    */
                                       /* or quote will be used as a string   */
                                       /* delimiter - bind and precompile     */
                                       /* option                              */
#define SQL_DECDEL_OPT         51      /* Designates whether a period or      */
                                       /* comma will be used as a decimal     */
                                       /* point indicator - bind and          */
                                       /* precompile option                   */
#define SQL_CHARSUB_OPT        55      /* Designates default character        */
                                       /* subtype that is to be used for      */
                                       /* column definitions in the CREATE    */
                                       /* and ALTER TABLE SQL statements -    */
                                       /* bind and precompile option          */
#define SQL_CCSIDS_OPT         56      /* Designates what CCSID will be used  */
                                       /* for single byte characters for      */
                                       /* character column definitions        */
                                       /* without a specific CCSID clause in  */
                                       /* the CREATE and ALTER TABLE SQL      */
                                       /* statements - bind and precompile    */
                                       /* option                              */
#define SQL_CCSIDM_OPT         57      /* Designates what CCSID will be used  */
                                       /* for mixed byte characters for       */
                                       /* character column definitions        */
                                       /* without a specific CCSID clause in  */
                                       /* the CREATE and ALTER TABLE SQL      */
                                       /* statements - bind and precompile    */
                                       /* option                              */
#define SQL_CCSIDG_OPT         58      /* Designates what CCSID will be used  */
                                       /* for double byte characters for      */
                                       /* character column definitions        */
                                       /* without a specific CCSID clause in  */
                                       /* the CREATE and ALTER TABLE SQL      */
                                       /* statements - bind and precompile    */
                                       /* option                              */
#define SQL_DEC_OPT            59      /* Specifies maximum precision to be   */
                                       /* used in decimal arithmetic          */
                                       /* operations - bind and precompile    */
                                       /* option                              */
#define SQL_WCHAR_OPT          60      /* Specifies handling of graphic       */
                                       /* vars. - precompile only             */
#define SQL_DYNAMICRULES_OPT   61      /* Specifies which authorization       */
                                       /* identifier to use when dynamic SQL  */
                                       /* in a package is executed. Owner of  */
                                       /* package or authid executing         */
                                       /* package - bind and precompile       */
                                       /* option                              */
#define SQL_INSERT_OPT         62      /* Buffers VALUE inserts - bind and    */
                                       /* precompile option for DB2/PE        */
                                       /* servers only                        */
#define SQL_EXPLSNAP_OPT       63      /* Capture explain snapshot - bind     */
                                       /* and precompile option               */
#define SQL_FUNCTION_PATH      64      /* Path for user-defined function      */
                                       /* resolution - bind and precompile    */
                                       /* option                              */
#define SQL_SQLWARN_OPT        65      /* Disable prepare-time SQL warnings   */
                                       /*  bind and precompile option         */
#define SQL_QUERYOPT_OPT       66      /* Set query optimization class -      */
                                       /* bind and precompile option          */
#define SQL_TARGET_OPT         67      /* Target compiler - precompile        */
                                       /* option                              */
#define SQL_PREP_OUTPUT_OPT    68      /* Name of precompiler output file -   */
                                       /* precompile option                   */

/* Values used for option[n].val when option[n].type is                       */
/* SQL_DATETIME_OPT. These can also be used for the date/time                 */
/* format parameter of sqlabind().                                            */

#define SQL_DATETIME_DEF       48      /* FORMAT = Default for Country Code   */
#define SQL_DATETIME_USA       49      /* FORMAT = USA                        */
#define SQL_DATETIME_EUR       50      /* FORMAT = EUR                        */
#define SQL_DATETIME_ISO       51      /* FORMAT = ISO                        */
#define SQL_DATETIME_JIS       52      /* FORMAT = JIS                        */
#define SQL_DATETIME_LOC       53      /* FORMAT = LOCAL                      */

/* The following constants are here for backwards compatbility with earlier   */
/* releases.                                                                  */

#define SQL_FRMT_OPT           SQL_DATETIME_OPT
#define SQL_FMT_0              SQL_DATETIME_DEF
#define SQL_FMT_1              SQL_DATETIME_USA
#define SQL_FMT_2              SQL_DATETIME_EUR
#define SQL_FMT_3              SQL_DATETIME_ISO
#define SQL_FMT_4              SQL_DATETIME_JIS
#define SQL_FMT_5              SQL_DATETIME_LOC

/* Values used for option[n].val when option[n].type is SQL_STANDARDS_OPT.    */
#define SQL_SAA_COMP           0       /* SAA Level 1 Database CPI            */
#define SQL_MIA_COMP           1       /* MIA                                 */

/* Values used for option[n].val when option[n].type is SQL_ISO_OPT           */
#define SQL_REP_READ           0       /* Repeatable read level               */
#define SQL_CURSOR_STAB        1       /* Cursor stability level              */
#define SQL_UNCOM_READ         2       /* Uncommitted read level              */
#define SQL_READ_STAB          3       /* Read stability level                */
#define SQL_NO_COMMIT          4       /* No Commit level      l              */

/* Values used for option[n].val when option[n].type is SQL_BLOCK_OPT         */
#define SQL_BL_UNAMBIG         0       /* Block Unambiguous cursors           */
#define SQL_BL_ALL             1       /* Block All cursors                   */
#define SQL_NO_BL              2       /* Block No cursors                    */

/* Values used for option[n].val when option[n].type is SQL_FLAG_OPT          */
#define SQL_MVSDB2V23_SYNTAX   4       /* Flagger check against MVS           */
#define SQL_MVSDB2V31_SYNTAX   5       /* DB2 V2.3, V3.1 or V4.1 SQL          */
#define SQL_MVSDB2V41_SYNTAX   6       /* syntax                              */

/* Values used for option[n].val when option[n].type is SQL_SAA_OPT.          */
#define SQL_SAA_NO             0       /* SQLCA definition not SAA            */
                                       /* compatible                          */
#define SQL_SAA_YES            1       /* SQLCA definition is SAA compatible  */

/* Values used for option[n].val when option[n].type is SQL_OPTIM_OPT.        */
#define SQL_DONT_OPTIMIZE      0       /* Do not optimize SQLDA               */
                                       /* initialization                      */
#define SQL_OPTIMIZE           1       /* Optimize SQLDA initialization       */

/* Values used for option[n].val when option[n].type is SQL_SYNTAX_OPT.       */
#define SQL_NO_SYNTAX_CHECK    0       /* Create a package and/or a bind      */
                                       /* file                                */
#define SQL_SYNTAX_CHECK       1       /* Do not create a package or bind     */
                                       /* file                                */

/* Values used for option[n].val when option[n].type is SQL_LINEMACRO_OPT.    */
#define SQL_NO_LINE_MACROS     0       /* Do not generate #line macros in     */
                                       /* modified source file                */
#define SQL_LINE_MACROS        1       /* Generate #line macros in modified   */
                                       /* source file                         */

/* Values used for option[n].val when option[n].type is SQL_WCHAR_OPT.        */
#define SQL_WCHAR_NOCONVERT    0       /* graphic variable not converted      */
#define SQL_WCHAR_CONVERT      1       /* graphic variable converted          */

/* Maximum sqlchar length for option[n].val when option[n].type is SQL_LEVEL  */
/* OPT                                                                        */
#define SQL_MAX_LEVEL          8

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* COLLECTION_OPT                                                             */
#define SQL_MAX_COLLECTION     8

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* VERSION_OPT                                                                */
#define SQL_MAX_VERSION        254

/* Maximum sqlchar length for option[n].val when option[n].type is SQL_OWNER  */
/* OPT                                                                        */
#define SQL_MAX_OWNER          8

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* SCHEMA_OPT                                                                 */
#define SQL_MAX_SCHEMA         SQL_MAX_OWNER

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* QUALIFIER_OPT                                                              */
#define SQL_MAX_QUALIFIER      18

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* CATALOG_OPT                                                                */
#define SQL_MAX_CATALOG        SQL_MAX_QUALIFIER

/* Maximum sqlchar length for option[n].val when option[n].type is SQL_TEXT   */
/* OPT                                                                        */
#define SQL_MAX_TEXT           255

/* Values used for option[n].val when option[n].type is SQL_VALIDATE_OPT      */
#define SQL_VALIDATE_BIND      0       /* Validate objects during BIND        */
#define SQL_VALIDATE_RUN       1       /* Validate objects during execution   */

/* Values used for option[n].val when option[n].type is SQL_EXPLAIN_OPT       */
#define SQL_EXPLAIN_NO         0       /* No Explain output saved             */
#define SQL_EXPLAIN_YES        1       /* Explain output saved                */
#define SQL_EXPLAIN_ALL        2       /* Explain output saved for all        */
                                       /* static and dynamic statements       */

/* Values used for option[n].val when option[n].type is SQL_ACTION_OPT        */
#define SQL_ACTION_ADD         0       /* Package is to be added              */
#define SQL_ACTION_REPLACE     1       /* Package is to be replaced           */

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* REPLVER_OPT                                                                */
#define SQL_MAX_REPLVER        254

/* Values used for option[n].val when option[n].type is SQL_SQLERROR_OPT      */
#define SQL_SQLERROR_NOPACKAGE SQL_NO_SYNTAX_CHECK /* Do not create a         */
                                       /* package if errors are encountered   */
#define SQL_SQLERROR_CHECK     SQL_SYNTAX_CHECK /* Do not create a package    */
#define SQL_SQLERROR_CONTINUE  2       /* Create a package even if errors     */
                                       /* are encountered                     */

/* Values used for option[n].val when option[n].type is SQL_RETAIN_OPT        */
#define SQL_RETAIN_NO          0       /* Do not preserve EXECUTE             */
                                       /* authorities when a package is       */
                                       /* replaced                            */
#define SQL_RETAIN_YES         1       /* Preserve EXECUTE authorities when   */
                                       /* a package is replaced               */

/* Values used for option[n].val when option[n].type is SQL_RELEASE_OPT       */
#define SQL_RELEASE_COMMIT     0       /* Release resources at COMMIT         */
#define SQL_RELEASE_DEALLOCATE 1       /* Release resources when the program  */
                                       /* terminates                          */

/* Values used for option[n].val when option[n].type is SQL_STRDEL_OPT        */
#define SQL_STRDEL_APOSTROPHE  0       /* Apostrophe string delimiter         */
#define SQL_STRDEL_QUOTE       1       /* Quote string delimiter              */

/* Values used for option[n].val when option[n].type is SQL_DECDEL_OPT        */
#define SQL_DECDEL_PERIOD      0       /* Period is used as a decimal point   */
                                       /* indicator in decimal and floating   */
                                       /* point literals                      */
#define SQL_DECDEL_COMMA       1       /* Comma is used as a decimal point    */
                                       /* indicator in decimal and floating   */
                                       /* point literals                      */

/* Values used for option[n].val when option[n].type is SQL_CHARSUB_OPT       */
#define SQL_CHARSUB_DEFAULT    0       /* Use the target system defined       */
                                       /* default for all new character       */
                                       /* columns for which an explicit       */
                                       /* subtype is not specified            */
#define SQL_CHARSUB_BIT        1       /* Use the BIT character subtype for   */
                                       /* all new character columns for       */
                                       /* which an explicit subtype is not    */
                                       /* specified                           */
#define SQL_CHARSUB_SBCS       2       /* Use the SBCS character subtype for  */
                                       /* all new character columns for       */
                                       /* which an explicit subtype is not    */
                                       /* specified                           */
#define SQL_CHARSUB_MIXED      3       /* Use the mixed character subtype     */
                                       /* for all new character columns for   */
                                       /* which an explicit subtype is not    */
                                       /* specified                           */

/* Values used for option[n].val when option[n].type is SQL_DEC_OPT           */
#define SQL_DEC_15             15      /* 15 bit precision is used in         */
                                       /* decimal arithmetic operations       */
#define SQL_DEC_31             31      /* 31 bit precision is used in         */
                                       /* decimal arithmetic operations       */

/* Values used for option[n].val when option[n].type is SQL_DEGREE_OPT        */
#define SQL_DEGREE_1           1       /* Prohibits parallel I/O operations   */
#define SQL_DEGREE_ANY         0       /* Allows the target database system   */
                                       /* to determine the degree of          */
                                       /* parallel I/O operations             */
#define SQL_MAX_DEGREE_VAL     32767   /* Maximum value                       */

/* The next four option values (for CONNECT type, SQLRULES, DISCONNECT and    */
/* SYNCPOINT) are used not only by the precompiler but also by the sqlesetc   */
/* and sqleqryc APIs.                                                         */

/* Values used for option[n].val when option[n].type is SQL_CONNECT_OPT       */
#define SQL_CONNECT_1          1       /* Indicates that only one connection  */
                                       /* to a database can exist at any      */
                                       /* given time.                         */
#define SQL_CONNECT_2          2       /* Indicates that multiple             */
                                       /* connections can exist               */
                                       /* simultaneously, with one being      */
                                       /* active and the others dormant.      */

/* Values used for option[n].val when option[n].type is SQL_RULES_OPT         */
#define SQL_RULES_DB2          1       /* Indicates that CONNECT TO can be    */
                                       /* used to make a dormant connection   */
                                       /* the current connection.             */
#define SQL_RULES_STD          2       /* Indicates that CONNECT TO is not    */
                                       /* valid for making a dormant          */
                                       /* connection current, and SET         */
                                       /* CONNECTION must be used instead.    */

/* Values used for option[n].val when option[n].type is SQL_DISCONNECT_OPT    */
#define SQL_DISCONNECT_EXPL    1       /* Indicates that all connections      */
                                       /* marked by the RELEASE statement     */
                                       /* will be the only connections        */
                                       /* released when a COMMIT is issued.   */
#define SQL_DISCONNECT_COND    2       /* Indicates that all connections      */
                                       /* that do not have open WITH HOLD     */
                                       /* cursors will be the only            */
                                       /* connections released when a COMMIT  */
                                       /* is issued.                          */
#define SQL_DISCONNECT_AUTO    3       /* Indicates that all connections      */
                                       /* will be released when a COMMIT is   */
                                       /* issued.                             */

/* Values used for option[n].val when option[n].type is SQL_SYNCPOINT_OPT     */
#define SQL_SYNC_ONEPHASE      1       /* Do not use a transaction manager    */
                                       /* to perform two phase commit, but    */
                                       /* enforce that there is only one      */
                                       /* database is updated when multiple   */
                                       /* databases are accessed within a     */
                                       /* single transaction.                 */
#define SQL_SYNC_TWOPHASE      2       /* Use a transaction manager to        */
                                       /* coordinate two phase commit.        */
#define SQL_SYNC_NONE          0       /* No update enforcement or two phase  */
                                       /* commit protocol will be used.       */

/* Values used for option[n].val when option[n].type is SQL_DYNAMICRULES_OPT  */
#define SQL_DYNAMICRULES_RUN   0       /* Dynamic SQL in package will use     */
                                       /* authid of person running the        */
                                       /* package                             */
#define SQL_DYNAMICRULES_BIND  1       /* Dynamic SQL in package will use     */
                                       /* authid of person who owns the       */
                                       /* package                             */

/* Values used for option[n].val when option[n].type is SQL_INSERT_OPT        */
#define SQL_INSERT_DEF         0       /* Do not buffer VALUE inserts         */
#define SQL_INSERT_BUF         1       /* Buffer VALUE inserts                */

/* Values used for option[n].val when option[n].type is SQL_EXPLSNAP_OPT      */
#define SQL_EXPLSNAP_NO        0       /* No Explain snapshot saved           */
#define SQL_EXPLSNAP_YES       1       /* Explain snapshot saved              */
#define SQL_EXPLSNAP_ALL       2       /* Explain snapshot saved for all      */
                                       /* static and dynamic statements       */

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* FUNCTION_PATH                                                              */
#define SQL_MAX_FUNCPATH       254

/* Values used for option[n].val when option[n].type is SQL_SQLWARN_OPT       */
#define SQL_SQLWARN_NO         0       /* Suppress prepare-time warning       */
                                       /* SQLCODEs                            */
#define SQL_SQLWARN_YES        1       /* Permit prepare-time warning         */
                                       /* SQLCODEs                            */

/* Values used for option[n].val when option[n].type is SQL_QUERYOPT_OPT      */
#define SQL_QUERYOPT_0         0       /* Class 0 query optimization          */
#define SQL_QUERYOPT_1         1       /* Class 1 query optimization          */
#define SQL_QUERYOPT_3         3       /* Class 3 query optimization          */
#define SQL_QUERYOPT_5         5       /* Class 5 query optimization          */
#define SQL_QUERYOPT_9         9       /* Class 9 query optimization          */

/* Maximum sqlchar length for option[n].val when option[n].type is SQL        */
/* TARGET_OPT                                                                 */
#define SQL_MAX_TARGET_LEN     32

/* Binder Interface Parameters/Return Codes                                   */

SQL_API_RC SQL_API_FN                      /* Bind                            */
  sqlabndx (
        _SQLOLDCHAR * pBindFileName,       /* bind file name                  */
        _SQLOLDCHAR * pMsgFileName,        /* message file                    */
        struct sqlopt * pBindOptions,      /* bind options                    */
        struct sqlca * pSqlca);            /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Rebind                          */
  sqlarbnd (
        char * pPackageName,               /* package name                    */
        struct sqlca * pSqlca,             /* SQLCA                           */
        void * pReserved);                 /* reserved                        */

SQL_API_RC SQL_API_FN                      /* Precompile Program              */
  sqlaprep (
        _SQLOLDCHAR * pProgramName,        /* source file name                */
        _SQLOLDCHAR * pMsgFileName,        /* message file name               */
        struct sqlopt * pPrepOptions,      /* precompile options              */
        struct sqlca * pSqlca);            /* SQLCA                           */

/* Generic Interfaces to the Binder and Precompiler                           */

SQL_API_RC SQL_API_FN                      /* Bind                            */
  sqlgbndx (
        unsigned short MsgFileNameLen,     /* message file name length        */
        unsigned short BindFileNameLen,    /* bind file name length           */
        struct sqlca * pSqlca,             /* SQLCA                           */
        struct sqlopt * pBindOptions,      /* binder options                  */
        _SQLOLDCHAR * pMsgFileName,        /* message file                    */
        _SQLOLDCHAR * pBindFileName);      /* bind file name                  */

SQL_API_RC SQL_API_FN                      /* Rebind                          */
  sqlgrbnd (
        unsigned short PackageNameLen,     /* package name length             */
        char * pPackageName,               /* package name                    */
        struct sqlca * pSqlca,             /* SQLCA                           */
        void * pReserved);                 /* reserved                        */

SQL_API_RC SQL_API_FN                      /* Precompile Program              */
  sqlgprep (
        unsigned short MsgFileNameLen,     /* message file name length        */
        unsigned short ProgramNameLen,     /* source file name length         */
        struct sqlca * pSqlca,             /* SQLCA                           */
        struct sqlopt * pPrepOptions,      /* precompile options              */
        _SQLOLDCHAR * pMsgFileName,        /* message file name               */
        _SQLOLDCHAR * pProgramName);       /* source file name                */

/* Error/SQLSTATE Message Retrieval Interface Parameters/Return Codes         */

/* Get Error Message Macro                                                    */
#define  sqlaintp(msgbuf,bufsize,linesize,sqlcaptr) \
sqlaintp_api(msgbuf,bufsize,linesize, \
(char *)"db2sql.mo", sqlcaptr)
SQL_API_RC SQL_API_FN                      /* Get Error Message               */
  sqlaintp_api (
        char * pBuffer,                    /* buffer for message text         */
        short BufferSize,                  /* buffer size                     */
        short LineWidth,                   /* line width                      */
        char * pMsgFileName,               /* message file                    */
        struct sqlca * pSqlca);            /* SQLCA                           */

/* Generic Interface to Error Message Retrieval                               */
SQL_API_RC SQL_API_FN                      /* Get Error Message               */
  sqlgintp (
        short BufferSize,                  /* buffer size                     */
        short LineWidth,                   /* line width                      */
        struct sqlca * pSqlca,             /* SQLCA                           */
        _SQLOLDCHAR * pBuffer);            /* buffer                          */

SQL_API_RC SQL_API_FN                      /* Sqlstate Message Retrieval      */
  sqlogstt (
        char * pBuffer,                    /* buffer for message text         */
        short BufferSize,                  /* buffer size                     */
        short LineWidth,                   /* line width                      */
        char * pSqlstate);                 /* sqlstate                        */

/* Generic Interface to SQLSTATE Message Retrieval                            */
SQL_API_RC SQL_API_FN                      /* Sqlstate Message Retrieval      */
  sqlggstt (
        short BufferSize,                  /* buffer size                     */
        short LineWidth,                   /* line width                      */
        char * pSqlstate,                  /* sqlstate                        */
        char * pBuffer);                   /* buffer                          */

/* Return Codes for sqlaintp/sqlogstt                                         */
#define SQLA_ERR_BADCC         -1      /* insufficient memory for msg file    */
#define SQLA_ERR_NOCOD         -2      /* no error code in SQLCA              */
#define SQLA_ERR_NOMSG         -3      /* message file inaccessible or        */
                                       /* incorrect                           */
#define SQLA_ERR_BADLL         -4      /* specified line length negative      */
#define SQLA_ERR_BADCA         -5      /* invalid sqlca/buffer addr/length    */

/* Administrative/Database Authorizations returned from Get Administrative    */
/* Authorizations function                                                    */
/* Authorizations granted explicitly to user                                  */
#define SQL_SYSADM             0x1     /* SYSADM Authority                    */
#define SQL_DBADM              0x2     /* DBADM Authority                     */
#define SQL_CREATETAB          0x4     /* CREATETAB Privilege                 */
#define SQL_BINDADD            0x8     /* BINDADD Privilege                   */
#define SQL_CONNECT            0x10    /* CONNECT Privilege                   */
#define SQL_CREATE_NOT_FENC    0x20    /* CREATE_NOT_FENCED Privilege         */
#define SQL_SYSCTRL            0x40    /* SYSCTRL Authority                   */
#define SQL_SYSMAINT           0x80    /* SYSMAINT Authority                  */

/* Composite of authorizations granted explicitly to user, to groups of       */
/* which user is a member, and to PUBLIC                                      */
#define SQL_SYSADM_GRP         (SQL_SYSADM << 8)
#define SQL_DBADM_GRP          (SQL_DBADM << 8)
#define SQL_CREATETAB_GRP      (SQL_CREATETAB << 8)
#define SQL_BINDADD_GRP        (SQL_BINDADD << 8)
#define SQL_CONNECT_GRP        (SQL_CONNECT << 8)
#define SQL_CREATE_NOT_FENC_GRP (SQL_CREATE_NOT_FENC << 8)
#define SQL_SYSCTRL_GRP        (SQL_SYSCTRL << 8)
#define SQL_SYSMAINT_GRP       (SQL_SYSMAINT << 8)

/* Table/View Authorizations/Dependencies Bit definitions in                  */
/* SYSTABAUTH.TABAUTH and SYSPLANDEP.TABAUTH                                  */
#define SQL_TAB_CTL            0x1     /* Control Authority                   */
#define SQL_TAB_ALT            0x2     /* Alter Privilege                     */
#define SQL_TAB_DEL            0x4     /* Delete Privilege/Dependency         */
#define SQL_TAB_IDX            0x8     /* Index Privilege                     */
#define SQL_TAB_INS            0x10    /* Insert Privilege/Dependency         */
#define SQL_TAB_SEL            0x20    /* Select Privilege/Dependency         */
#define SQL_TAB_UPD            0x40    /* Update Privilege/Dependency         */
#define SQL_TAB_REF            0x80    /* Reference Privilege                 */
#define SQL_TAB_KEY            0x2000  /* Key Dependency                      */
#define SQL_TAB_CAS            0x4000  /* Cascade Dependency                  */

/* Definitions for application remote interface                               */
#define SQLZ_DISCONNECT_PROC   1       /* Unload Progam                       */
#define SQLZ_HOLD_PROC         2       /* Keep program loaded                 */
/******************************************************************************
** 
** The following functions and symbols are obsolete and may not be
** supported in future releases. The obsolete functions are provided
** for backward compatibility and exported from DB2API.LIB. All 
** applications should be migrated to use new APIs.
*******************************************************************************/
#define SQLA_RC_BAD_PASSWD     -4      /* Invalid password                    */
#define SQL_MAXSTMTS           32767   /* Maximum statements (see SQL         */
                                       /* reference)                          */
#define SQL_MAXVARS            32767   /* Maximum host variables per          */
                                       /* precompile unit (see SQL            */
                                       /* reference)                          */
#pragma options align=reset

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQL */
mk K  $        2 R1R1ZU1         z  2     ./usr/lpp/db2_02_01/include/sqlaprep.h .                    $          /******************************************************************************
** 
** Source File Name: SQLAPREP
** 
** (C) COPYRIGHT International Business Machines Corp. 1988, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function = Include File defining:
**              Global equates, structures, and prototypes for
**              Precompiler and Runtime Command Interfaces
** 
** Operating System = AIX
** 
*******************************************************************************/
#ifndef SQL_H_SQLAPREP
#define SQL_H_SQLAPREP

#ifdef __cplusplus
extern "C" {
#endif


/* Required Include Files                                                     */
#include "sqlsystm.h"              /* System dependent defines  */
#include "sqlca.h"
#include "sqlenv.h"
#include "sqladef.h"

#pragma options align=power

/* Macro used to calculate size of a precompiler option array, an input       */
/* parameter of SQLAINIT.                                                     */
#define SQLA_NUM_OPTIONS(n) (sizeof(struct sqla_options_header) + \
(n)*sizeof(struct sqla_option)        )

/* Values used for option[n].type, an input parameter of SQLAINIT.            */
#define SQLA_FORMAT            SQL_FRMT_OPT      /* Option: date/time format  */
#define SQLA_ACCESS_PLAN       2                 /* Option: access plan       */
                                                 /* creation                  */
#define SQLA_BIND_FILE         3                 /* Option: bind file         */
                                                 /* creation                  */
#define SQLA_ISOLATION         SQL_ISO_OPT       /* Option: isolation level   */
#define SQLA_BLOCK             SQL_BLOCK_OPT     /* Option: record blocking   */
#define SQLA_FLAG_OPT          SQL_FLAG_OPT      /* Flagger option            */
#define SQLA_STDS_LEVEL        7                 /* Option: standards         */
                                                 /* compliance                */
#define SQLA_LEVEL_OPT         SQL_LEVEL_OPT     /* Level of a module         */
#define SQLA_COLLECTION_OPT    SQL_COLLECTION_OPT /* Package collection id    */
#define SQLA_VERSION_OPT       SQL_VERSION_OPT   /* Package version id        */
#define SQLA_OWNER_OPT         SQL_OWNER_OPT     /* Package owner auth id     */
#define SQLA_SCHEMA_OPT        SQL_SCHEMA_OPT    /* Synonym for owner         */
#define SQLA_QUALIFIER_OPT     SQL_QUALIFIER_OPT /* Authorization identifier  */
                                                 /* that is to be used as     */
                                                 /* qualifier for             */
                                                 /* unqualified objects       */
#define SQLA_CATALOG_OPT       SQL_CATALOG_OPT   /* Synonym for qualifier.    */
#define SQLA_TEXT_OPT          SQL_TEXT_OPT      /* Package description       */
#define SQLA_VALIDATE_OPT      SQL_VALIDATE_OPT  /* Indicates when object     */
                                                 /* validation occurs         */
#define SQLA_EXPLAIN_OPT       SQL_EXPLAIN_OPT   /* Determines whether        */
                                                 /* information will be       */
                                                 /* produced about how the    */
                                                 /* SQL statements in a       */
                                                 /* package will be executed  */
#define SQLA_ACTION_OPT        SQL_ACTION_OPT    /* Indicates whether a       */
                                                 /* package is to be added    */
                                                 /* or replaced               */
#define SQLA_SQLERROR_OPT      SQL_SYNTAX_OPT    /* Indicates under what      */
                                                 /* conditions a package      */
                                                 /* will be created           */
#define SQLA_REPLVER_OPT       SQL_REPLVER_OPT   /* Replaces a specific       */
                                                 /* version of a package      */
#define SQLA_RETAIN_OPT        SQL_RETAIN_OPT    /* Indicates whether         */
                                                 /* EXECUTE authorities are   */
                                                 /* to be preserved when a    */
                                                 /* package is replaced       */
#define SQLA_RELEASE_OPT       SQL_RELEASE_OPT   /* Indicates whether         */
                                                 /* resources are released    */
                                                 /* at each COMMIT or when    */
                                                 /* the application           */
                                                 /* terminates                */
#define SQLA_DEGREE_OPT        SQL_DEGREE_OPT    /* Specifies whether or not  */
                                                 /* the query is executed     */
                                                 /* using I/O parallelism     */
#define SQLA_STRDEL_OPT        SQL_STRDEL_OPT    /* Designates whether an     */
                                                 /* apostrophe or quote will  */
                                                 /* be used as a string       */
                                                 /* delimiter                 */
#define SQLA_DECDEL_OPT        SQL_DECDEL_OPT    /* Designates whether a      */
                                                 /* period or comma will be   */
                                                 /* used as a decimal point   */
                                                 /* indicator                 */
#define SQLA_CHARSUB_OPT       SQL_CHARSUB_OPT   /* Designates default        */
                                                 /* character subtype that    */
                                                 /* is to be used for column  */
                                                 /* definitions in the        */
                                                 /* CREATE and ALTER TABLE    */
                                                 /* SQL statements            */
#define SQLA_CCSIDS_OPT        SQL_CCSIDS_OPT    /* Designates what CCSID     */
                                                 /* will be used for single   */
                                                 /* byte characters for       */
                                                 /* character column          */
                                                 /* definitions without a     */
                                                 /* specific CCSID clause in  */
                                                 /* the CREATE and ALTER      */
                                                 /* TABLE SQL statements      */
#define SQLA_CCSIDM_OPT        SQL_CCSIDM_OPT    /* Designates what CCSID     */
                                                 /* will be used for mixed    */
                                                 /* byte characters for       */
                                                 /* character column          */
                                                 /* definitions without a     */
                                                 /* specific CCSID clause in  */
                                                 /* the CREATE and ALTER      */
                                                 /* TABLE SQL statements      */
#define SQLA_CCSIDG_OPT        SQL_CCSIDG_OPT    /* Designates what CCSID     */
                                                 /* will be used for double   */
                                                 /* byte characters for       */
                                                 /* character column          */
                                                 /* definitions without a     */
                                                 /* specific CCSID clause in  */
                                                 /* the CREATE and ALTER      */
                                                 /* TABLE SQL statements      */
#define SQLA_DEC_OPT           SQL_DEC_OPT       /* Specifies the maximum     */
                                                 /* precision to be used in   */
                                                 /* decimal arithmetic        */
                                                 /* operations                */
#define SQLA_CONNECT_OPT       SQL_CONNECT_OPT   /* Specifies whether one or  */
                                                 /* multiple connections can  */
                                                 /* exist at the same time.   */
#define SQLA_SQLRULES_OPT      SQL_RULES_OPT     /* Specifies the set of      */
                                                 /* rules used for            */
                                                 /* connection to multiple    */
                                                 /* databases within a        */
                                                 /* single unit of work       */
#define SQLA_DISCONNECT_OPT    SQL_DISCONNECT_OPT /* Specifies which          */
                                                 /* databases disconnected    */
                                                 /* when a COMMIT or          */
                                                 /* ROLLBACK is issued.       */
#define SQLA_SYNCPOINT_OPT     SQL_SYNCPOINT_OPT /* Specifies what syncpoint  */
                                                 /* option (for example one   */
                                                 /* or two phase) will be     */
                                                 /* used.                     */
#define SQLA_DYNAMICRULES_OPT  SQL_DYNAMICRULES_OPT /* Specifies which        */
                                                 /* authorization identifier  */
                                                 /* to use when dynamic SQL   */
                                                 /* in a package is           */
                                                 /* executed. Owner of        */
                                                 /* package or authid         */
                                                 /* executing package.        */
#define SQLA_INSERT            SQL_INSERT_OPT    /* Buffers VALUE inserts -   */
                                                 /* bind and precompile       */
                                                 /* option for DB2/PE         */
                                                 /* servers only              */
#define SQLA_EXPLSNAP_OPT      SQL_EXPLSNAP_OPT  /* Capture explain snapshot  */
                                                 /* - bind and precompile     */
                                                 /* option                    */
#define SQLA_FUNCTION_PATH     SQL_FUNCTION_PATH /* Path for user-defined     */
                                                 /* function resolution -     */
                                                 /* bind and precompile       */
                                                 /* option                    */
#define SQLA_SQLWARN_OPT       SQL_SQLWARN_OPT   /* Disable prepare-time SQL  */
                                                 /* warnings - bind and       */
                                                 /* precompile option         */
#define SQLA_QUERYOPT_OPT      SQL_QUERYOPT_OPT  /* Set query optimization    */
                                                 /* class -bind and           */
                                                 /* precompile option         */
#define SQLA_TARGET_OPT        SQL_TARGET_OPT    /* Target compiler           */
                                                 /* precompile option         */
#define SQLA_PREP_OUTPUT_OPT   SQL_PREP_OUTPUT_OPT /* Name of precompiler     */
                                                 /* output file - precompile  */
                                                 /* option                    */
#define SQLA_TOKEN_USE_INITIALIZED_OPT 1000      /* Internal use only         */

/* Values used for option[n].val when option[n].type is SQLA_FORMAT in        */
/* the Precompiler Option Array.                                              */
#define SQLA_POA_DEF           0       /* Default date/time format            */
#define SQLA_POA_USA           1       /* USA date/time format                */
#define SQLA_POA_EUR           2       /* European date/time format           */
#define SQLA_POA_ISO           3       /* International date/time format      */
#define SQLA_POA_JIS           4       /* Japanese date/time format           */
#define SQLA_POA_LOC           5       /* Local date/time format              */

/* Values used for option[n].val when option[n].type is SQLA_ACCESS_PLAN in   */
/* the Precompiler Option Array.                                              */
#define SQLA_CREATE_PLAN       1       /* Create an access plan               */
#define SQLA_NO_PLAN           0       /* Do not create an access plan        */
#define SQLA_NO_PLAN_SYNTAX    3       /* Set ocb->syntax to TRUE             */

/* Values used for option[n].val when option[n].type is SQLA_BIND_FILE in     */
/* the Precompiler Option Array.                                              */
#define SQLA_CREATE_BIND_FILE  1       /* Create a bind file                  */
#define SQLA_NO_BIND_FILE      0       /* Do not create a bind file           */

/* Values used for option[n].val when option[n].type is SQLA_ISOLATION in     */
/* the Precompiler Option Array.                                              */
#define SQLA_REPEATABLE_READ   SQL_REP_READ      /* RR isolation level        */
#define SQLA_CURSOR_STABILITY  SQL_CURSOR_STAB   /* CS Isolation level        */
#define SQLA_UNCOMMITTED_READ  SQL_UNCOM_READ    /* UR Isolation level        */
#define SQLA_READ_STABILITY    SQL_READ_STAB     /* RS Isolation level        */
#define SQLA_NO_COMMIT         SQL_NO_COMMIT     /* NC Isolation level        */

/* Values used for option[n].val when option[n].type is SQLA_BLOCK in         */
/* the Precompiler Option Array.                                              */
#define SQLA_BLOCK_UNAMBIG     SQL_BL_UNAMBIG
#define SQLA_BLOCK_ALL         SQL_BL_ALL
#define SQLA_NO_BLOCK          SQL_NO_BL

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* LEVEL_OPT                                                                  */
#define SQLA_MAX_LEVEL         SQL_MAX_LEVEL

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* COLLECTION_OPT                                                             */
#define SQLA_MAX_COLLECTION    SQL_MAX_COLLECTION

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* VERSION_OPT                                                                */
#define SQLA_MAX_VERSION       SQL_MAX_VERSION

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* OWNER_OPT                                                                  */
#define SQLA_MAX_OWNER         SQL_MAX_OWNER

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* SCHEMA_OPT                                                                 */
#define SQLA_MAX_SCHEMA        SQLA_MAX_OWNER

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* QUALIFIER_OPT                                                              */
#define SQLA_MAX_QUALIFIER     SQL_MAX_QUALIFIER

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* CATALOG_OPT                                                                */
#define SQLA_MAX_CATALOG       SQLA_MAX_QUALIFIER

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA_TEXT  */
/* OPT                                                                        */
#define SQLA_MAX_TEXT          SQL_MAX_TEXT

/* Values used for option[n].val when option[n].type is SQLA_VALIDATE_OPT.    */
#define SQLA_VALIDATE_BIND     SQL_VALIDATE_BIND /* Validate objects during   */
                                                 /* BIND                      */
#define SQLA_VALIDATE_RUN      SQL_VALIDATE_RUN  /* Validate objects during   */
                                                 /* execution                 */

/* Values used for option[n].val when option[n].type is SQLA_EXPLAIN_OPT.     */
#define SQLA_EXPLAIN_NO        SQL_EXPLAIN_NO    /* No EXPLAIN output         */
                                                 /* produced                  */
#define SQLA_EXPLAIN_YES       SQL_EXPLAIN_YES   /* EXPLAIN output produced   */
#define SQLA_EXPLAIN_ALL       SQL_EXPLAIN_ALL   /* EXPLAIN output produced   */
                                                 /* for all static and        */
                                                 /* dynamic statements.       */

/* Values used for option[n].val when option[n].type is SQLA_ACTION_OPT.      */
#define SQLA_ACTION_ADD        SQL_ACTION_ADD    /* Package is added          */
#define SQLA_ACTION_REPLACE    SQL_ACTION_REPLACE /* Package is replaced      */

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* REPLVER_OPT                                                                */
#define SQLA_MAX_REPLVER       SQL_MAX_REPLVER

/* Values used for option[n].val when option[n].type is SQLA_SQLERROR_OPT.    */
#define SQLA_SQLERROR_NOPACKAGE SQL_NO_SYNTAX_CHECK /* Do not create a        */
                                                 /* package if errors are     */
                                                 /* encountered               */
#define SQLA_SQLERROR_CHECK    SQL_SYNTAX_CHECK  /* Do not create a package   */
#define SQLA_SQLERROR_CONTINUE SQL_SQLERROR_CONTINUE /* Create a package      */
                                                 /* even if errors are        */
                                                 /* encountered               */

/* Values used for option[n].val when option[n].type is SQLA_RETAIN_OPT.      */
#define SQLA_RETAIN_NO         SQL_RETAIN_NO     /* Do not preserve EXECUTE   */
                                                 /* authorities when a        */
                                                 /* package is replaced       */
#define SQLA_RETAIN_YES        SQL_RETAIN_YES    /* Preserve EXECUTE          */
                                                 /* authorities when a        */
                                                 /* package is replaced       */

/* Values used for option[n].val when option[n].type is SQLA_RELEASE_OPT.     */
#define SQLA_RELEASE_COMMIT    SQL_RELEASE_COMMIT /* Release resources at     */
                                                 /* COMMIT                    */
#define SQLA_RELEASE_DEALLOCATE SQL_RELEASE_DEALLOCATE /* Release resources   */
                                                 /* when a program            */
                                                 /* terminates                */

/* Values used for option[n].val when option[n].type is SQLA_STRDEL_OPT.      */
#define SQLA_STRDEL_APOSTROPHE SQL_STRDEL_APOSTROPHE /* Apostrophe string     */
                                                 /* delimiter                 */
#define SQLA_STRDEL_QUOTE      SQL_STRDEL_QUOTE  /* Quote string delimiter    */

/* Values used for option[n].val when option[n].type is SQLA_DECDEL_OPT.      */
#define SQLA_DECDEL_PERIOD     SQL_DECDEL_PERIOD /* Period is used as a       */
                                                 /* decimal point indicator   */
                                                 /* in decimal and floating   */
                                                 /* point literals            */
#define SQLA_DECDEL_COMMA      SQL_DECDEL_COMMA  /* Comma is used as a        */
                                                 /* decimal point indicator   */
                                                 /* in decimal and floating   */
                                                 /* point literals            */

/* Values used for option[n].val when option[n].type is SQLA_CHARSUB_OPT.     */
#define SQLA_CHARSUB_DEFAULT   SQL_CHARSUB_DEFAULT /* Use the target system   */
                                                 /* defined default for all   */
                                                 /* new character columns     */
                                                 /* for which an explicit     */
                                                 /* subtype is not specified  */
#define SQLA_CHARSUB_BIT       SQL_CHARSUB_BIT   /* Use the bit character     */
                                                 /* subtype for all new       */
                                                 /* character columns for     */
                                                 /* which an explicit         */
                                                 /* subtype is not specified  */
#define SQLA_CHARSUB_SBCS      SQL_CHARSUB_SBCS  /* Use the SBCS character    */
                                                 /* subtype for all new       */
                                                 /* character columns for     */
                                                 /* which an explicit         */
                                                 /* subtype is not specified  */
#define SQLA_CHARSUB_MIXED     SQL_CHARSUB_MIXED /* Use the mixed character   */
                                                 /* subtype for all new       */
                                                 /* character columns for     */
                                                 /* which an explicit         */
                                                 /* subtype is not specified  */

/* Values used for option[n].val when option[n].type is SQLA_DEC_OPT.         */
#define SQLA_DEC_15            SQL_DEC_15        /* 15 bit precision is used  */
                                                 /* in decimal arithmetic     */
                                                 /* operations                */
#define SQLA_DEC_31            SQL_DEC_31        /* 31 bit precision is used  */
                                                 /* in decimal arithmetic     */
                                                 /* operations                */

/* Values used for option[n].val when option[n].type is SQLA_DEGREE_OPT.      */
#define SQLA_DEGREE_1          SQL_DEGREE_1      /* Prohibits parallel I/O    */
                                                 /* operations                */
#define SQLA_DEGREE_ANY        SQL_DEGREE_ANY    /* Allows the target         */
                                                 /* database system to        */
                                                 /* determine the degree of   */
                                                 /* parallel I/O operations   */
#define SQLA_MAX_DEGREE_VAL    SQL_MAX_DEGREE_VAL /* Maximum value            */

/* Values used for option[n].val when option[n].type is SQLA_CONNECT_OPT.     */
#define SQLA_CONNECT_1         SQL_CONNECT_1     /* Indicates that only one   */
                                                 /* connection to a database  */
                                                 /* can exist at any given    */
                                                 /* time.                     */
#define SQLA_CONNECT_2         SQL_CONNECT_2     /* Indicates that multiple   */
                                                 /* connections can exist     */
                                                 /* simultaneously, with one  */
                                                 /* being active and the      */
                                                 /* others dormant.           */

/* Values used for option[n].val when option[n].type is SQLA_RULES_OPT.       */
#define SQLA_RULES_DB2         SQL_RULES_DB2     /* Indicates that CONNECT    */
                                                 /* TO can be used to make a  */
                                                 /* dormant connection the    */
                                                 /* current connection.       */
#define SQLA_RULES_STD         SQL_RULES_STD     /* Indicates that CONNECT    */
                                                 /* TO is not valid for       */
                                                 /* making a dormant          */
                                                 /* connection current,and    */
                                                 /* SET CONNECTION must be    */
                                                 /* used instead.             */
/* Values used for option[n].val when option[n].type is SQLA_DISCONNECT_OPT.  */
#define SQLA_DISCONNECT_EXPL   SQL_DISCONNECT_EXPL /* Indicates that all      */
                                                 /* connections marked by     */
                                                 /* the RELEASE statement     */
                                                 /* will be the only          */
                                                 /* connections released      */
                                                 /* when a COMMIT or          */
                                                 /* ROLLBACK is issued.       */
#define SQLA_DISCONNECT_COND   SQL_DISCONNECT_COND /* Indicates that all      */
                                                 /* connections which don't   */
                                                 /* have open WITH HOLD       */
                                                 /* cursors will be the only  */
                                                 /* connections released      */
                                                 /* when a COMMIT or          */
                                                 /* ROLLBACK is issued.       */
#define SQLA_DISCONNECT_AUTO   SQL_DISCONNECT_AUTO /* Indicates that all      */
                                                 /* connections will be       */
                                                 /* released when a COMMIT    */
                                                 /* or ROLLBACK is issued.    */

/* Values used for option[n].val when option[n].type is SQLA_SYNCPOINT_OPT.   */
#define SQLA_SYNC_ONEPHASE     SQL_SYNC_ONEPHASE /* Do not use a transaction  */
                                                 /* manager to perform two    */
                                                 /* phase commit,but enforce  */
                                                 /* that there is only one    */
                                                 /* database is updated when  */
                                                 /* multiple databases are    */
                                                 /* accessed within a single  */
                                                 /* transaction.              */
#define SQLA_SYNC_TWOPHASE     SQL_SYNC_TWOPHASE /* Use a transaction         */
                                                 /* manager to coordinate     */
                                                 /* two phase commit.         */
#define SQLA_SYNC_NONE         SQL_SYNC_NONE     /* No two-phase commit and   */
                                                 /* no single updater         */
                                                 /* enforcement.              */

/* Values used for option[n].val when option[n].type is SQLA_DYNAMICRULES     */
/* OPT.                                                                       */
#define SQLA_DYNAMICRULES_RUN  SQL_DYNAMICRULES_RUN /* Dynamic SQL in         */
                                                 /* package will use authid   */
                                                 /* of person running the     */
                                                 /* package                   */
#define SQLA_DYNAMICRULES_BIND SQL_DYNAMICRULES_BIND /* Dynamic SQL in        */
                                                 /* package will use authid   */
                                                 /* of person who owns the    */
                                                 /* package                   */

/* Values used for option[n].val when option[n].type is SQLA_FLAG_OPT inthe   */
/* Precompiler Option Array.                                                  */
#define SQLA_DB2V23_SYNTAX     SQL_MVSDB2V23_SYNTAX
#define SQLA_DB2V31_SYNTAX     SQL_MVSDB2V31_SYNTAX
#define SQLA_DB2V41_SYNTAX     SQL_MVSDB2V41_SYNTAX

/* Values used for option[n].val when option[n].type is SQLA_EXPLSNAP_OPT in  */
/* the Precompiler Option array                                               */
#define SQLA_EXPLSNAP_NO       SQL_EXPLSNAP_NO   /* Do not save explain       */
                                                 /* snapshot                  */
#define SQLA_EXPLSNAP_YES      SQL_EXPLSNAP_YES  /* Save explain snapshot     */
#define SQLA_EXPLSNAP_ALL      SQL_EXPLSNAP_ALL  /* Save explain snapshot     */
                                                 /* for all static and        */
                                                 /* dynamic statements        */

/* Maximum sqlchar length for option[n].val when option[n].type is SQLA       */
/* FUNCTION_PATH                                                              */
#define SQLA_MAX_FUNCPATH      SQL_MAX_FUNCPATH

/* Values used for option[n].val when option[n].type is SQLA_SQLWARN_OPT in   */
/* the Precompiler Option array                                               */
#define SQLA_SQLWARN_NO        SQL_SQLWARN_NO    /* Suppress prepare-time     */
                                                 /* warning SQLCODEs          */
#define SQLA_SQLWARN_YES       SQL_SQLWARN_YES   /* Permit prepare-time       */
                                                 /* warning SQLCODEs          */

/* Values used for option[n].val when option[n].type is SQLA_QUERYOPT_OPT in  */
/* the Precompiler Option array                                               */
#define SQLA_QUERYOPT_0        SQL_QUERYOPT_0    /* Class 0 query             */
                                                 /* optimization              */
#define SQLA_QUERYOPT_1        SQL_QUERYOPT_1    /* Class 1 query             */
                                                 /* optimization              */
#define SQLA_QUERYOPT_3        SQL_QUERYOPT_3    /* Class 3 query             */
                                                 /* optimization              */
#define SQLA_QUERYOPT_5        SQL_QUERYOPT_5    /* Class 5 query             */
                                                 /* optimization              */
#define SQLA_QUERYOPT_9        SQL_QUERYOPT_9    /* Class 9 query             */
                                                 /* optimization              */

/* Values used for option[n].val when option[n].type is SQLA_INSERT_OPT       */
#define SQLA_INSERT_DEF        SQL_INSERT_DEF    /* Do not buffer VALUE       */
                                                 /* inserts                   */
#define SQLA_INSERT_BUF        SQL_INSERT_BUF    /* Buffer VALUE inserts      */

/* Maximum target string length in option[n].val when option[n].type is SQLA  */
/* TARGET_OPT                                                                 */
#define SQLA_MAX_TARGET_LEN    SQL_MAX_TARGET_LEN

/* Values used for option[n].val when option[n].type is SQLA_STDS_LEVEL       */
/* inthe Precompiler Option Array.                                            */
#define SQLA_STND_NONE         0                 /* No compliance required    */
#define SQLA_STND_MIA          1                 /* Comply with MIA standard  */

/* Values used for location, an input parameter of SQLAAHVR.                  */
#define SQLA_DECLARE_SECT      0       /* Add host var found in a declare     */
                                       /* section                             */
#define SQLA_SQL_STMT          1       /* Add host var found in an SQL        */
                                       /* statement                           */

/* Values assigned to task[n].func, an output parameter of SQLACMPL.          */
#define SQLA_START             0       /* Generate a call to sqlastrt         */
#define SQLA_DECLARE           1       /* Begin or end parsing hvar           */
                                       /* declarations                        */
#define SQLA_INCLUDE           2       /* Generate code for an SQLCA or       */
                                       /* SQLDA                               */
#define SQLA_ALLOC_INPUT       3       /* Allocate an input SQLDA using       */
                                       /* SQLAALOC                            */
#define SQLA_ALLOC_OUTPUT      4       /* Allocate an output SQLDA using      */
                                       /* SQLAALOC                            */
#define SQLA_SETS              5       /* Register a host variable using      */
                                       /* SQLASETS                            */
#define SQLA_USDA_INPUT        6       /* Register an input user-defined      */
                                       /* SQLDA                               */
#define SQLA_USDA_OUTPUT       7       /* Register an output user-defined     */
                                       /* SQLDA                               */
#define SQLA_CALL              8       /* Generate a call to SQLACALL         */
#define SQLA_DEALLOC           9       /* Generate a call to SQLADLOC         */
#define SQLA_STOP              10      /* Generate a call to SQLASTOP         */
#define SQLA_SQLERROR          11      /* Generate code for WHENEVER          */
                                       /* SQLERROR                            */
#define SQLA_SQLWARNING        12      /* Generate code for WHENEVER          */
                                       /* SQLWARNING                          */
#define SQLA_NOT_FOUND         13      /* Generate code for WHENEVER NOT      */
                                       /* FOUND                               */
#define SQLA_INC_TEXTFILE      14      /* Process an INCLUDE text-file stmt   */
#define SQLA_BEGIN_COMPOUND    15      /* Begin Compound SQL block            */
#define SQLA_CMPD              16      /* Generate a call to SQLACMPD         */
#define SQLA_CMPD_TEST         17      /* Generate a conditional branch       */
                                       /* around subsequent Compound SQL      */
                                       /* substatements.                      */
#define SQLA_CMPD_MARK         18      /* Generate a target label for gotos   */
                                       /* from cmpd_test (optional)           */
#define SQLA_NEXT_SUBSTATEMENT 19      /* Request the outer precompiler to    */
                                       /* get the next triggered SQL          */
                                       /* statement                           */

/* Values returned in task[n].val when task[n].func is SQLA_DECLARE.          */
/* This is an output parameter of SQLACMPL.                                   */
#define SQLA_BEGIN             0
#define SQLA_END               1

/* Values returned in task[n].val when task[n].func is SQLA_INCLUDE.          */
/* This is an output parameter of SQLACMPL.                                   */
#define SQLA_SQLCA             10
#define SQLA_SQLDA             11

/* Values returned in task[n].val when task[n].func is SQLA_CALL.             */
/* This is an output parameter of SQLACMPL.                                   */
#define SQLA_CLOSE             20
#define SQLA_COMMIT            21
#define SQLA_DESCRIBE          22
#define SQLA_EXECIMMD          23
#define SQLA_EXECUTE           24
#define SQLA_FETCH             25
#define SQLA_OPEN              26
#define SQLA_PREPARE           27
#define SQLA_ROLLBACK          28
#define SQLA_CONNECT           29
#define SQLA_CMPDEXEC          30      /* Atomic Compound SQL call            */
#define SQLA_FREE_LOB_LOCATORS 37      /* SQL free locators call              */
#define SQLA_CMPDEXEC_NA       38      /* Not Atomic Compound SQL call        */
#define SQLA_DUOW              40
#define SQLA_CLOSE_REL         41      /* Close Cursor with Release           */
#define SQLA_CALLPROC          42      /* Stored Procedure SQL call           */
#define SQLA_SET_CURRENT_PKGSET 43     /* Set Current Packageset              */
#define SQLA_EXECIMMD_ASYNC    44
#define SQLA_EXECUTE_ASYNC     45
#define SQLA_FETCH_ASYNC       46
#define SQLA_OPEN_ASYNC        47
#define SQLA_CALLPROC_ASYNC    48
#define SQLA_CMPDEXEC_ASYNC    49
#define SQLA_DESCRIBE_ASYNC    50
#define SQLA_PREPARE_ASYNC     51

/* Values assigned to token[n].use, an output parameter of SQLACMPL.          */
#define SQLA_INPUT_HVAR        0       /* Input host var, no indicator var    */
#define SQLA_INPUT_WITH_IND    1       /* Input host var followed by          */
                                       /* indicator var                       */
#define SQLA_OUTPUT_HVAR       2       /* Output host var, no indicator var   */
#define SQLA_OUTPUT_WITH_IND   3       /* Output host var followed by         */
                                       /* indicator var                       */
#define SQLA_INDICATOR         4       /* Indicator variable                  */
#define SQLA_USER_SQLDA        5       /* SQLDA structure                     */
#define SQLA_INVALID_USE       6       /* Host variable type does not match   */
                                       /* use                                 */
#define SQLA_INVALID_ID        7       /* Host variable token ID is not       */
                                       /* valid                               */
#define SQLA_LITERAL           8       /* Literal string                      */
#define SQLA_MULTIPLE_STRUCT_FIELD 9   /* Host var was one of several fields  */
                                       /* expanded from a structure           */
                                       /* reference                           */
#define SQLA_ATOMIC_FIELD      10      /* Host var was either atomic or a     */
                                       /* single field from a structure       */
                                       /* reference                           */

/* Values assigned to stmt_type, an output parameter of SQLACMPL.             */
#define SQLA_TYPE_NULL_CONNECT                   0
#define SQLA_TYPE_CONN_EXCL_NO_PWD               1
#define SQLA_TYPE_CONN_EXCL_PWD                  2
#define SQLA_TYPE_CONNECT_RESET                  3
#define SQLA_TYPE_CONN_SHARE_NO_PWD              4
#define SQLA_TYPE_CONN_SHARE_PWD                 5
#define SQLA_TYPE_CONNECT_USERID                 6
#define SQLA_TYPE_BEGIN                          10
#define SQLA_TYPE_BEGIN_COMPOUND                 12
#define SQLA_TYPE_CALLPROC                       13
#define SQLA_TYPE_CLOSE                          15
#define SQLA_TYPE_COMMIT                         20
#define SQLA_TYPE_CONNECT_1                      21
#define SQLA_TYPE_CONNECT_2                      22
#define SQLA_TYPE_DISCONNECT_DBNAME              23
#define SQLA_TYPE_DISCONNECT_CURRENT             24
#define SQLA_TYPE_DISCONNECT_ALL                 25
#define SQLA_TYPE_RELEASE_DBNAME                 26
#define SQLA_TYPE_RELEASE_CURRENT                27
#define SQLA_TYPE_RELEASE_ALL                    28
#define SQLA_TYPE_SET_CONNECTION                 29
#define SQLA_TYPE_DECLARE_SELECT                 30
#define SQLA_TYPE_DECLARE_SNAME                  40
#define SQLA_TYPE_DESCRIBE                       50
#define SQLA_TYPE_END                            60
#define SQLA_TYPE_END_COMPOUND                   65
#define SQLA_TYPE_EXECUTE                        70
#define SQLA_TYPE_EXECUTE_IMM                    80
#define SQLA_TYPE_FETCH                          90
#define SQLA_TYPE_FREE_LOB_LOCATOR               95
#define SQLA_TYPE_INCLUDE_SQLCA                  100
#define SQLA_TYPE_INCLUDE_SQLDA                  110
#define SQLA_TYPE_INCLUDE_TEXTFILE               115
#define SQLA_TYPE_OPEN                           120
#define SQLA_TYPE_PREPARE                        130
#define SQLA_TYPE_ROLLBACK                       140
#define SQLA_TYPE_SELECT                         150
#define SQLA_TYPE_SELECT_INTO                    160
#define SQLA_TYPE_SET_CURRENT_PKGSET             163
#define SQLA_TYPE_WHEN_NOT_FOUND                 170
#define SQLA_TYPE_WHEN_SQLERROR                  180
#define SQLA_TYPE_WHEN_SQLWARNING                190
#define SQLA_TYPE_OTHER                          200

/* Values used for term_option, an input parameter of SQLAFINI.               */
#define SQLA_SAVE              1       /* Save the access plan and/or bind    */
                                       /* file                                */
#define SQLA_DISCARD           0       /* Discard the access plan and/or      */
                                       /* bind file                           */

/* Miscellaneous Constants                                                    */

#define SQL_MAX_FILE_NAME_LENGTH 128   /* size of SQLAINIT file name buffer   */

#define SQL_CMPL_BUFSIZ        128     /* size of SQLACMPL output buffers     */
#define SQL_PID_LENGTH         40      /* length of precompiler pid           */
#define SQLA_FLAG_MAXMSGS      10      /* Message array length same as SQLH   */
                                       /* MAXMSGS                             */
#define SQLA_FLAG_VERSION      1       /* Current SQL Flagger version         */

/* Return codes from Precompiler Services and Runtime Services functions.     */
#define SQLA_SQLCA_BAD         -1      /* sqlca pointer/length invalid        */
#define SQLA_CHECK_SQLCA       0       /* check sqlca completion status       */

/* Values returned in sqlca.sqlcode by Precompiler or Runtime Services        */
#define SQLA_RC_OK                     SQL_RC_OK
#define SQLA_RC_OPTION_IGNORED         20
#define SQLA_RC_CHAR_BAD               SQL_RC_E007
#define SQLA_RC_STRING_NOT_TERMINATED  SQL_RC_E010
#define SQLA_RC_EMPTY_DEL_IDENT        SQL_RC_E013
#define SQLA_RC_BFILE_OPEN_ERROR       -31
#define SQLA_RC_BFILE_DISK_ERROR       -32
#define SQLA_RC_SECTION_LIMIT          -51
#define SQLA_RC_MEMORY_BAD             -83
#define SQLA_RC_SNAME_DUP              -85
#define SQLA_RC_NO_STRUCT              -87
#define SQLA_RC_AMBIG_HOSTVAR          -88
#define SQLA_RC_STMT_LIMIT             SQL_RC_E101
#define SQLA_RC_NUMBER_BAD             SQL_RC_E103
#define SQLA_RC_STMT_SYNTAX_BAD        SQL_RC_E104
#define SQLA_RC_GSTRING_BAD            SQL_RC_E105 /* DBCS only               */
#define SQLA_RC_IDENTIFIER_LIMIT       SQL_RC_E107
#define SQLA_RC_QUALIFIER_BAD          SQL_RC_E108
#define SQLA_RC_DDSBAD                 SQL_RC_E142
#define SQLA_RC_DDSIGN                 SQL_RC_W143
#define SQLA_RC_DDSWRN                 SQL_RC_W143
#define SQLA_RC_KEYWORD_BAD            SQL_RC_E199
#define SQLA_RC_HVAR_NOT_DEC           -306
#define SQLA_RC_HVAR_DUP_NAME          -307
#define SQLA_RC_HVAR_LIMIT             -308
#define SQLA_RC_STMT_HVAR_LIMIT        -310
#define SQLA_RC_HVAR_USE_BAD           -324
#define SQLA_RC_CURSOR_DUP             -505
#define SQLA_RC_STMT_MODIFY_ALL        513
#define SQLA_RC_INVALID_TRIGGER_STMT   SQL_RC_E751
#define SQLA_RC_SQLDA_SQLD_ERR         SQL_RC_E804
#define SQLA_RC_SQLVAR_TYPE_ERR        SQL_RC_E804
#define SQLA_RC_DISK_FULL              SQL_RC_E968
#define SQLA_RC_CMPD_NESTED            -4010
#define SQLA_RC_CMPD_INVALID_STMT      -4011
#define SQLA_RC_CMPD_INVALID_COMMIT    -4012
#define SQLA_RC_CMPD_INVALID_END       -4013
#define SQLA_RC_INVALID_CMPD_SYNTAX    -4014
#define SQLA_RC_FATAL_ERROR            -4901
#define SQLA_RC_PARM_CHARS_BAD         -4902
#define SQLA_RC_PARM_LENGTH_BAD        SQLA_RC_OPTION_LEN_BAD
#define SQLA_RC_PARM_POINTER_BAD       SQLA_RC_OPTION_PTR_BAD
#define SQLA_RC_PARM_RANGE_BAD         SQLA_RC_OPTION_SIZE_BAD
#define SQLA_RC_HVAR_SQLTYPE_BAD       -4911
#define SQLA_RC_HVAR_SQLLEN_BAD        -4912
#define SQLA_RC_HVAR_TOKEN_ID_DUP      -4913
#define SQLA_RC_HVAR_TOKEN_ID_BAD      -4914
#define SQLA_RC_INIT_DUP               -4915
#define SQLA_RC_INIT_REQUIRED          -4916
#define SQLA_RC_OPTION_BAD             SQLA_RC_OPTION_DATA_BAD
#define SQLA_RC_TERM_OPTION_BAD        -4918
#define SQLA_RC_TASK_ARRAY_LIMIT       -4919
#define SQLA_RC_TOKEN_ARRAY_LIMIT      -4920
#define SQLA_RC_OPTION_GEN_INVALID     SQLA_RC_OPTION_INVALID
#define SQLA_RC_STMT_CLAUSE_BAD        -4940       /* Prep version of -109    */
#define SQLA_RC_STMT_BLANK             -4941       /* Prep version of -198    */
#define SQLA_RC_SELECT_HVAR_TYPE_BAD   -4942       /* Prep version of -303    */
#define SQLA_RC_SELECT_LIST_BAD        4943        /* Prep version of -313    */
#define SQLA_RC_COLUMN_NOT_NULLABLE    -4944       /* Prep version of -407    */
#define SQLA_RC_STMT_MARKER_BAD        -4945       /* Prep version of -418    */
#define SQLA_RC_CURSOR_NOT_DECLARED    -4946       /* Prep version of -504    */
#define SQLA_RC_NO_USERDA_IN_CMPD      -4950
#define SQLA_RC_SQLDA_ID_BAD           -4951
#define SQLA_RC_SQLVAR_INDEX_BAD       -4952
#define SQLA_RC_CALL_TYPE_BAD          -4953
#define SQLA_RC_SECTION_BAD            -4954

/* Temporary value used in sqlca.sqlcode after an SQLAALOC function. Runtime  */
/* code can check sqlca.sqlcode to determine whether or not the SQLASETV      */
/* function needs to be called to initialize the sqlda sqlvar elements.       */
#define SQLA_RC_SQLVARS_SET    4959    /* sqlvars already initialized         */

/* Errors that cause Precompiler Services to enter the fatal error state.     */
/* After encountering one of these types of errors, Precompiler Services      */
/* requires an SQLAFINI and SQLAINIT call before it will continue.            */

#define SQLA_RC_INV_INSERT               SQL_RC_E803
#define SQLA_RC_INV_SQLDA_ADR            SQL_RC_E822
#define SQLA_RC_SYS_ERROR                SQL_RC_E902
#define SQLA_RC_DEADLOCK_ERR             SQL_RC_E911
#define SQLA_RC_FAT_SYS_ERR              SQL_RC_E912
#define SQLA_RC_TOO_MANY_LKS             SQL_RC_E930
#define SQLA_RC_STORAGE_ERR              SQL_RC_E954
#define SQLA_RC_DB_HEAP_ERR              SQL_RC_E956
#define SQLA_RC_TOOMANY_OFLS             SQL_RC_E958
#define SQLA_RC_TOOMANY_FILES            SQL_RC_E960
#define SQLA_RC_LOG_FULL                 SQL_RC_E964
#define SQLA_RC_FILE_SYS_FULL            SQL_RC_E968
#define SQLA_RC_READ_ONLY_FIL            SQL_RC_E970

#define SQLA_RC_INCORRECT_DSK            -972
#define SQLA_RC_DB_DRV_LOCKED            -974
#define SQLA_RC_DRV_DOOR_OPEN            -976
#define SQLA_RC_DISK_WRT_PRO             -978
#define SQLA_RC_FILESYSTEM_ACCESS        -10019

#define SQLA_RC_DISK_ERROR               SQL_RC_E980
#define SQLA_RC_DISK_ERR                 SQL_RC_E982
#define SQLA_RC_COMM_RB_ERR              SQL_RC_E984
#define SQLA_RC_CAT_FILE_ERR             SQL_RC_E985
#define SQLA_RC_TAB_FILE_ERR             SQL_RC_E986
#define SQLA_RC_INDEX_ERR                SQL_RC_E990
#define SQLA_RC_REL_NUM_BAD              SQL_RC_E992
#define SQLA_RC_AGENT_GONE               SQLE_RC_AGENT_GONE
#define SQLA_RC_CTRL_BREAK               -4994   /* Prep version of -952      */
#define SQLA_RC_CODEPAGE_BAD             -4995   /* Country info not found    */
#define SQLA_RC_SQLUSER_BAD              -4997   /* Prep version of -1046     */
#define SQLA_RC_DB_DISCONNECTED          -4998   /* Prep version of -1049     */
#define SQLA_RC_INTERNAL_ERR             -4999   /* Precompiler Services err  */

/******************************************************************************
** Target API constants for sqlaopts()
*******************************************************************************/
#define SQLAO_PREP_SVCS_API              0       /* Precompiler Services API  */
                                                 /* (sqlainit)                */

SQL_API_RC SQL_API_FN                            /* Parse an option string    */
                                                 /* and produce an option     */
                                                 /* array                     */
  sqlaopts (
        void *,                                  /* option string             */
        struct sqlopt *,                         /* option array              */
        void *,                                  /* database name (sqlainit   */
                                                 /* only)                     */
        void *,                                  /* userid (sqlainit only)    */
        void *,                                  /* password (sqlainit only)  */
        void *,                                  /* message file name         */
        void *,                                  /* package name (sqlainit    */
                                                 /* only)                     */
        void *,                                  /* bind file name (sqlainit  */
                                                 /* only)                     */
        long,                                    /* target API                */
        void *,                                  /* memory handle             */
        struct sqlca *);                         /* SQLCA                     */

SQL_API_RC SQL_API_FN                            /* Frees any memory          */
                                                 /* allocated by sqlaopts     */
  sqlaopts_free (
        void *,                                  /* memory handle returned    */
                                                 /* by sqlaopts               */
        struct sqlca *);                         /* SQLCA                     */

/******************************************************************************
** Precompiler Services Structures
*******************************************************************************/

/* Precompiler Option Array.  Used with SQLAINIT.                             */

SQL_STRUCTURE sqla_options_header
{
        unsigned long               allocated;
        unsigned long               used;
};

SQL_STRUCTURE sqla_option
{
        unsigned long               type;
        unsigned long               val;
};

SQL_STRUCTURE sqla_options
{
        struct sqla_options_header  header;
        struct sqla_option          option[1];
};

/* Program ID.  Used by Precompiler Services and Runtime Services             */
SQL_STRUCTURE sqla_program_id
{
        unsigned short    length;
        unsigned short    rp_rel_num;
        unsigned short    db_rel_num;
        unsigned short    bf_rel_num;
        char              sqluser[8];
        char              planname[8];
        char              contoken[8];
        char              buffer[8];
};

/* Indexes into the buffer field, showing the information it provides         */
#define SQLA_PGMID_STD         0
#define SQLA_PGMID_CONNECT     1
#define SQLA_PGMID_SQLRULES    2
#define SQLA_PGMID_DISCONNECT  3
#define SQLA_PGMID_SYNCPOINT   4
#define SQLA_INT_TO_ASCII_DIFF 48

/* Number of DUOW connection options                                          */
#define SQLA_PGMID_CONNOPTS    4

/* Precompiler Task Array.  Used with SQLACMPL.                               */

SQL_STRUCTURE sqla_tasks_header
{
        unsigned long               allocated;
        unsigned long               used;
};

SQL_STRUCTURE sqla_task
{
        unsigned long               func;
        unsigned long               val;
};

SQL_STRUCTURE sqla_tasks
{
        struct sqla_tasks_header    header;
        struct sqla_task            task[1];
};

/* Token return structure.  Used to return length and offset of               */
/* a token within an SQL statement.  May be overlaid on top of                */
/* the val member of the task array or on top of the id member                */
/* of the token id array.                                                     */
SQL_STRUCTURE sqla_return_token
{
        unsigned short    offset;
        unsigned short    length;
};

/* Precompiler Token ID Array.  Used with SQLACMPL.                           */

SQL_STRUCTURE sqla_tokens_header
{
        unsigned long               allocated;
        unsigned long               used;
};

SQL_STRUCTURE sqla_token
{
        unsigned long               id;
        unsigned long               use;
};

SQL_STRUCTURE sqla_tokens
{
        struct sqla_tokens_header   header;
        struct sqla_token           token[1];
};

/* Flagger information area. Used with SQLACMPL and SQLGCMPL.                 */
SQL_STRUCTURE sqla_flagmsgs
{
        short             count;
        short             padding;
        SQL_STRUCTURE sqlca sqlca[SQLA_FLAG_MAXMSGS];
};

SQL_STRUCTURE sqla_flaginfo
{
        short             version;
        short             padding;
        struct            sqla_flagmsgs msgs;
};
/* Precompiler Services Prototypes                                            */

/* NOTE: sqlaahvr has been obsoleted in favor of sqlaalhv.  sqlaahvr will be  */
/* unavailable in future releases.                                            */
SQL_API_RC SQL_API_FN                      /* Add a host variable             */
                                           /* declaration (obsolete)          */
  sqlaahvr (
        unsigned short *,                  /* host variable name length       */
        char *,                            /* host variable name              */
        unsigned short *,                  /* host variable SQL data type     */
        unsigned short *,                  /* host variable length            */
        unsigned long *,                   /* host variable token id          */
        unsigned short *,                  /* host variable location          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Add a host variable             */
                                           /* declaration                     */
  sqlaalhv (
        unsigned short *,                  /* host variable name length       */
        char *,                            /* host variable name              */
        unsigned short *,                  /* host variable SQL data type     */
        unsigned long *,                   /* host variable length            */
        unsigned long *,                   /* host variable token id          */
        unsigned short *,                  /* host variable location          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Compile an sql statement        */
  sqlacmpl (
        unsigned short *,                  /* SQL statement text length       */
        char *,                            /* SQL statement text              */
        unsigned short *,                  /* source line number              */
        struct sqla_tasks *,               /* task array                      */
        struct sqla_tokens *,              /* token id array                  */
        unsigned short *,                  /* section number                  */
        unsigned short *,                  /* type of SQL statement           */
        char *,                            /* 128 byte string buffer 1        */
        char *,                            /* 128 byte string buffer 2        */
        char *,                            /* 128 byte string buffer 3        */
        struct sqla_flaginfo *,            /* SQL Flagger information         */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Terminate an access plan        */
  sqlafini (
        unsigned short *,                  /* save/discard plan/bind file     */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Initialize an access plan       */
  sqlainit (
        unsigned short *,                  /* program name length             */
        char *,                            /* program name                    */
        unsigned short *,                  /* database name length            */
        char *,                            /* database name                   */
        unsigned short *,                  /* password length                 */
        char *,                            /* database password               */
        unsigned short *,                  /* bind file name length           */
        char *,                            /* bind file name                  */
        struct sqla_options *,             /* precompiler option array        */
        struct sqla_program_id *,          /* precompiler program ID          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

/* Generic Precompiler Services Prototypes                                    */

/* NOTE: sqlgahvr has been obsoleted in favor of sqlgalhv.  sqlgahvr will be  */
/* unavailable in future releases.                                            */
SQL_API_RC SQL_API_FN                      /* Add a host variable             */
                                           /* declaration (obsolete)          */
  sqlgahvr (
        unsigned short *,                  /* host variable name length       */
        char *,                            /* host variable name              */
        unsigned short *,                  /* host variable SQL data type     */
        unsigned short *,                  /* host variable length            */
        unsigned long *,                   /* host variable token id          */
        unsigned short *,                  /* host variable location          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Add a host variable             */
                                           /* declaration                     */
  sqlgalhv (
        unsigned short *,                  /* host variable name length       */
        char *,                            /* host variable name              */
        unsigned short *,                  /* host variable SQL data type     */
        unsigned long *,                   /* host variable length            */
        unsigned long *,                   /* host variable token id          */
        unsigned short *,                  /* host variable location          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Compile an sql statement        */
  sqlgcmpl (
        unsigned short *,                  /* SQL statement text length       */
        char *,                            /* SQL statement text              */
        unsigned short *,                  /* source line number              */
        struct sqla_tasks *,               /* task array                      */
        struct sqla_tokens *,              /* token id array                  */
        unsigned short *,                  /* section number                  */
        unsigned short *,                  /* type of SQL statement           */
        char *,                            /* 128 byte string buffer 1        */
        char *,                            /* 128 byte string buffer 2        */
        char *,                            /* 128 byte string buffer 3        */
        struct sqla_flaginfo *,            /* SQL Flagger information         */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Terminate an access plan        */
  sqlgfini (
        unsigned short *,                  /* save/discard plan/bind file     */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Initialize an access plan       */
  sqlginit (
        unsigned short *,                  /* program name length             */
        char *,                            /* program name                    */
        unsigned short *,                  /* database name length            */
        char *,                            /* database name                   */
        unsigned short *,                  /* password length                 */
        char *,                            /* database password               */
        unsigned short *,                  /* bind file name length           */
        char *,                            /* bind file name                  */
        struct sqla_options *,             /* precompiler option array        */
        struct sqla_program_id *,          /* precompiler program ID          */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */

/* Generic Runtime Services Prototypes                                        */

SQL_API_RC SQL_API_FN
  sqlgaloc (
        unsigned short,                    /* sqlda identification number     */
        unsigned short,                    /* number of sqlvar elements       */
                                           /* needed                          */
        unsigned short,                    /* statement identification        */
                                           /* number                          */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgcall (
        unsigned short,                    /* function call type              */
        unsigned short,                    /* access plan section or          */
                                           /* statement type                  */
        unsigned short,                    /* input SQLDA ID                  */
        unsigned short,                    /* output SQLDA ID                 */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgcmpd (
        unsigned short,                    /* function call type              */
        unsigned short,                    /* access plan section             */
        unsigned short,                    /* input SQLDA ID                  */
        unsigned short,                    /* output SQLDA ID                 */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgdloc (
        unsigned short,                    /* SQLDA ID                        */
        void *);                           /* reserved                        */

/* NOTE: sqlgsets has been obsoleted in favor of sqlgstls.  sqlgsets will be  */
/* unavailable in future releases.                                            */
SQL_API_RC SQL_API_FN
  sqlgsets (
        unsigned short,                    /* SQL statement text length       */
        const void *,                      /* SQL statement text              */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgstls (
        unsigned long,                     /* SQL statement text length       */
        const void *,                      /* SQL statement text              */
        void *);                           /* reserved                        */

/* NOTE: sqlgsetv has been obsoleted in favor of sqlgstlv.  sqlgsetv will be  */
/* unavailable in future releases.                                            */
SQL_API_RC SQL_API_FN
  sqlgsetv (
        unsigned short,                    /* SQLDA ID                        */
        unsigned short,                    /* sqlvar element                  */
        unsigned short,                    /* SQL data type                   */
        unsigned short,                    /* declared length                 */
        void *,                            /* address of host var             */
        short *,                           /* address of indicator var        */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgstlv (
        unsigned short,                    /* SQLDA ID                        */
        unsigned short,                    /* sqlvar element                  */
        unsigned short,                    /* SQL data type                   */
        unsigned long,                     /* declared length                 */
        void *,                            /* address of host var             */
        short *,                           /* address of indicator var        */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgstop (
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN
  sqlgstrt (
        char[40],                          /* runtime program ID              */
        struct sqla_runtime_info *,        /* runtime information             */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN
  sqlgusda (
        unsigned short,                    /* SQLDA ID                        */
        struct sqlda *,                    /* SQLDA                           */
        void *);                           /* reserved                        */

SQL_API_RC SQL_API_FN                      /* Parse an option string and      */
                                           /* produce an option array         */
  sqlgopts (
        void *,                            /* option string                   */
        struct sqlopt *,                   /* option array                    */
        void *,                            /* database name (sqlainit only)   */
        void *,                            /* userid (sqlainit only)          */
        void *,                            /* password (sqlainit only)        */
        void *,                            /* message file name               */
        void *,                            /* package name (sqlainit only)    */
        void *,                            /* bind file name (sqlainit only)  */
        long,                              /* target API                      */
        void *,                            /* memory handle                   */
        struct sqlca *);                   /* SQLCA                           */

SQL_API_RC SQL_API_FN                      /* Frees any memory allocated by   */
                                           /* sqlaopts                        */
  sqlgopts_free (
        void *,                            /* memory handle returned by       */
                                           /* sqlaopts                        */
        struct sqlca *);                   /* SQLCA                           */

#pragma options align=reset

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLAPREP */
L statkl O  $        =  R1R1ZU1           =      ./usr/lpp/db2_02_01/include/sqlcli.h h .                    $          /******************************************************************************
 *
 * Source File Name = SQLCLI.H
 *
 * (C) COPYRIGHT International Business Machines Corp. 1993, 1995
 * All Rights Reserved
 * Licensed Materials - Property of IBM
 *
 * US Government Users Restricted Rights - Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 * Function = Include File defining:
 *              DB2 CLI Interface - Constants
 *              DB2 CLI Interface - Data Structures
 *              DB2 CLI Interface - Function Prototypes
 *
 * Operating System = Common C Include File
 *
 *****************************************************************************/

#ifndef SQL_H_SQLCLI
#define SQL_H_SQLCLI            /* Permit duplicate Includes */


/* DB2CLI_VER            DB2 Call Level Interface Version Number (0x0210).
 *                       To revert to Version 1.0 definitions,
 *                       issue #define DB2CLI_VER 0x0110 before including
 *                       sqlcli.h and sqlcli1.h
 */

/* If DB2CLI_VER is not defined, assume version 2.10 */
#ifndef DB2CLI_VER
#define DB2CLI_VER 0x0210
#endif



#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>
#include "sqlsystm.h"                  /* System dependent defines  */

#if defined(DB2WIN) || defined(DB2NT)
#include <windows.h>
#else
#define FAR
#endif
#ifdef DB2OS2
#define INCL_WIN
#define INCL_DOS
#include <os2.h>
#endif

#ifdef DB2MAC

#include <Quickdraw.h>
typedef GrafPtr HWND;

#ifdef SQL_API
#undef SQL_API
#endif

#endif

#define SQL_API SQL_API_FN


/* generally useful constants */
#define  SQL_SQLSTATE_SIZE         5   /* size of SQLSTATE, not including
                                          null terminating byte           */
#define  SQL_MAX_MESSAGE_LENGTH   1024 /* message buffer size             */
#define  SQL_MAX_DSN_LENGTH       32   /* maximum data source name size   */
#define  SQL_MAX_ID_LENGTH        18   /* maximum identifier name size,
                                          e.g. cursor names               */

/* RETCODE values             */
#define  SQL_SUCCESS             0
#define  SQL_SUCCESS_WITH_INFO   1
#define  SQL_NO_DATA_FOUND       100
#define  SQL_NEED_DATA           99
#define  SQL_NO_DATA             SQL_NO_DATA_FOUND
#define  SQL_STILL_EXECUTING     2
#define  SQL_ERROR               -1
#define  SQL_INVALID_HANDLE      -2

/* SQLFreeStmt option values  */
#define  SQL_CLOSE               0
#define  SQL_DROP                1
#define  SQL_UNBIND              2
#define  SQL_RESET_PARAMS        3

/* SQLBindParameter / SQLSetParam defines        */
#define  SQL_C_DEFAULT           99

/* SQLTransact option values  */
#define  SQL_COMMIT              0
#define  SQL_ROLLBACK            1

/* Standard SQL data types */
#define  SQL_CHAR                1
#define  SQL_NUMERIC             2
#define  SQL_DECIMAL             3
#define  SQL_INTEGER             4
#define  SQL_SMALLINT            5
#define  SQL_FLOAT               6
#define  SQL_REAL                7
#define  SQL_DOUBLE              8
#define  SQL_DATE                9
#define  SQL_TIME               10
#define  SQL_TIMESTAMP          11
#define  SQL_VARCHAR            12

/* SQL extended data types */
#define  SQL_LONGVARCHAR        -1
#define  SQL_BINARY             -2
#define  SQL_VARBINARY          -3
#define  SQL_LONGVARBINARY      -4
#define  SQL_BIGINT             -5  /* Not supported */
#define  SQL_TINYINT            -6  /* Not supported */
#define  SQL_BIT                -7  /* Not supported */
#define  SQL_GRAPHIC            -95
#define  SQL_VARGRAPHIC         -96
#define  SQL_LONGVARGRAPHIC     -97
#define  SQL_BLOB               -98
#define  SQL_CLOB               -99
#define  SQL_DBCLOB             -350

#define  SQL_SIGNED_OFFSET      -20
#define  SQL_UNSIGNED_OFFSET    -22



/* C data type to SQL data type mapping */
#define  SQL_C_CHAR       SQL_CHAR      /* CHAR, VARCHAR, DECIMAL, NUMERIC */
#define  SQL_C_LONG       SQL_INTEGER   /* INTEGER                         */
#define  SQL_C_SHORT      SQL_SMALLINT  /* SMALLINT                        */
#define  SQL_C_FLOAT      SQL_REAL      /* REAL                            */
#define  SQL_C_DOUBLE     SQL_DOUBLE    /* FLOAT, DOUBLE                   */
#define  SQL_C_DATE       SQL_DATE      /* DATE                            */
#define  SQL_C_TIME       SQL_TIME      /* TIME                            */
#define  SQL_C_TIMESTAMP  SQL_TIMESTAMP /* TIMESTAMP                       */
#define  SQL_C_BINARY     SQL_BINARY    /* BINARY, VARGINARY               */
#define  SQL_C_BIT        SQL_BIT
#define  SQL_C_TINYINT    SQL_TINYINT
#define  SQL_C_DBCHAR     SQL_DBCLOB

/* For ODBC compatibility only */
#define  SQL_C_SLONG      SQL_C_LONG+SQL_SIGNED_OFFSET
#define  SQL_C_SSHORT     SQL_C_SHORT+SQL_SIGNED_OFFSET
#define  SQL_C_STINYINT   SQL_C_TINYINT+SQL_SIGNED_OFFSET
#define  SQL_C_ULONG      SQL_C_LONG+SQL_UNSIGNED_OFFSET
#define  SQL_C_USHORT     SQL_C_SHORT+SQL_UNSIGNED_OFFSET
#define  SQL_C_UTINYINT   SQL_C_TINYINT+SQL_UNSIGNED_OFFSET


/*
 *  locator type identifier
 */

#define SQL_BLOB_LOCATOR       31
#define SQL_CLOB_LOCATOR       41
#define SQL_DBCLOB_LOCATOR    -351

/*
 * C Data Type for the LOB locator types
 */
#define SQL_C_BLOB_LOCATOR     SQL_BLOB_LOCATOR
#define SQL_C_CLOB_LOCATOR     SQL_CLOB_LOCATOR
#define SQL_C_DBCLOB_LOCATOR   SQL_DBCLOB_LOCATOR

/*
 * NULL status defines; these are used in SQLColAttributes, SQLDescribeCol,
 * to describe the nullability of a column in a table.
 */

#define  SQL_NO_NULLS         0
#define  SQL_NULLABLE         1
#define  SQL_NULLABLE_UNKNOWN 2


/* Special length values  */
#define  SQL_NULL_DATA        -1
#define  SQL_DATA_AT_EXEC     -2
#define  SQL_NTS              -3      /* NTS = Null Terminated String    */

/* SQLColAttributes defines */
#define  SQL_COLUMN_COUNT             0
#define  SQL_COLUMN_NAME              1
#define  SQL_COLUMN_TYPE              2
#define  SQL_COLUMN_LENGTH            3
#define  SQL_COLUMN_PRECISION         4
#define  SQL_COLUMN_SCALE             5
#define  SQL_COLUMN_DISPLAY_SIZE      6
#define  SQL_COLUMN_NULLABLE          7
#define  SQL_COLUMN_UNSIGNED          8
#define  SQL_COLUMN_MONEY             9
#define  SQL_COLUMN_UPDATABLE        10
#define  SQL_COLUMN_AUTO_INCREMENT   11
#define  SQL_COLUMN_CASE_SENSITIVE   12
#define  SQL_COLUMN_SEARCHABLE       13
#define  SQL_COLUMN_TYPE_NAME        14
#define  SQL_COLUMN_TABLE_NAME       15
#define  SQL_COLUMN_OWNER_NAME       16
#define  SQL_COLUMN_QUALIFIER_NAME   17
#define  SQL_COLUMN_LABEL            18
#define  SQL_COLUMN_SCHEMA_NAME      SQL_COLUMN_OWNER_NAME
#define  SQL_COLUMN_CATALOG_NAME     SQL_COLUMN_QUALIFIER_NAME
#define  SQL_COLUMN_DISTINCT_TYPE    1250

/* SQLColAttributes defines for SQL_COLUMN_UPDATABLE condition */
#define  SQL_ATTR_READONLY            0
#define  SQL_ATTR_WRITE               1
#define  SQL_ATTR_READWRITE_UNKNOWN   2

/*
 * SQLColAttributes defines for SQL_COLUMN_SEARCHABLE condition.
 * These are also used by SQLGetInfo
 */
#define  SQL_UNSEARCHABLE             0
#define  SQL_LIKE_ONLY                1
#define  SQL_ALL_EXCEPT_LIKE          2
#define  SQL_SEARCHABLE               3

/* NULL handle defines    */
#define  SQL_NULL_HENV                0L
#define  SQL_NULL_HDBC                0L
#define  SQL_NULL_HSTMT               0L

/*
 * The following are provided to enhance portability and compatibility
 * with ODBC
 */

#ifndef DB2OS2
typedef           unsigned char         UCHAR;
typedef  unsigned long                  ULONG;
typedef  unsigned short                 USHORT;
#endif

typedef           signed   char         SCHAR;
typedef           long     int          SDWORD;
typedef           short    int          SWORD;
typedef  unsigned long     int          UDWORD;
typedef  unsigned short    int          UWORD;
typedef                    double       SDOUBLE;
typedef                    float        SFLOAT;

typedef  signed   long                  SLONG;
typedef  signed   short                 SSHORT;


#if defined(WINDOWS)
typedef  long     double                LDOUBLE;
#else
typedef           double                LDOUBLE;
#endif

typedef void FAR *         PTR;
typedef void FAR *         HENV;
typedef void FAR *         HDBC;
typedef void FAR *         HSTMT;

typedef signed short       RETCODE;



/* SQL portable types for C  */
typedef  UCHAR             SQLCHAR;
typedef  SCHAR             SQLSCHAR;
typedef  SDWORD            SQLINTEGER;
typedef  SWORD             SQLSMALLINT;
typedef  SDOUBLE           SQLDOUBLE;
typedef  SFLOAT            SQLREAL;

typedef  SQLSMALLINT       SQLRETURN;

#if (DB2CLI_VER >= 0x0200)
typedef  UDWORD            SQLUINTEGER;
typedef  UWORD             SQLUSMALLINT;
#else
typedef  SQLINTEGER        SQLUINTEGER;
typedef  SQLSMALLINT       SQLUSMALLINT;
#endif

typedef  PTR               SQLPOINTER;

/*
 * Double Byte Character Set support
 */

#ifdef SQL_WCHART_CONVERT
typedef  wchar_t           SQLDBCHAR;
#else
typedef  unsigned short    SQLDBCHAR;
#endif


#ifdef DB2WIN

typedef  HENV              SQLHENV;
typedef  HDBC              SQLHDBC;
typedef  HSTMT             SQLHSTMT;
typedef  HWND              SQLHWND;

#else

typedef  SQLINTEGER        SQLHENV;
typedef  SQLINTEGER        SQLHDBC;
typedef  SQLINTEGER        SQLHSTMT;

#if defined(DB2OS2) || defined (DB2WIN) || defined (DB2NT) || defined(DB2MAC)
typedef  HWND              SQLHWND;
#else
typedef  SQLPOINTER        SQLHWND;
#endif

#endif

typedef  struct DATE_STRUCT
  {
    SQLSMALLINT    year;
    SQLUSMALLINT   month;
    SQLUSMALLINT   day;
  } DATE_STRUCT;

typedef  struct TIME_STRUCT
  {
    SQLUSMALLINT   hour;
    SQLUSMALLINT   minute;
    SQLUSMALLINT   second;
  } TIME_STRUCT;

typedef  struct TIMESTAMP_STRUCT
  {
    SQLSMALLINT    year;
    SQLUSMALLINT   month;
    SQLUSMALLINT   day;
    SQLUSMALLINT   hour;
    SQLUSMALLINT   minute;
    SQLUSMALLINT   second;
    SQLUINTEGER    fraction;     /* fraction of a second */
  } TIMESTAMP_STRUCT;





/* Core Function Prototypes  */




SQLRETURN SQL_API_FN  SQLAllocConnect  (SQLHENV           henv,
                                        SQLHDBC     FAR   *phdbc);


SQLRETURN SQL_API_FN  SQLAllocEnv      (SQLHENV     FAR   *phenv);

SQLRETURN SQL_API_FN  SQLAllocStmt     (SQLHDBC           hdbc,
                                        SQLHSTMT    FAR   *phstmt);

SQLRETURN SQL_API_FN  SQLBindCol       (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLSMALLINT       fCType,
                                        SQLPOINTER        rgbValue,
                                        SQLINTEGER        cbValueMax,
                                        SQLINTEGER  FAR   *pcbValue);

SQLRETURN SQL_API_FN  SQLCancel        (SQLHSTMT          hstmt);

SQLRETURN SQL_API_FN  SQLColAttributes (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLUSMALLINT      fDescType,
                                        SQLPOINTER        rgbDesc,
                                        SQLSMALLINT       cbDescMax,
                                        SQLSMALLINT FAR   *pcbDesc,
                                        SQLINTEGER  FAR   *pfDesc);

SQLRETURN SQL_API_FN  SQLConnect       (SQLHDBC           hdbc,
                                        SQLCHAR     FAR   *szDSN,
                                        SQLSMALLINT       cbDSN,
                                        SQLCHAR     FAR   *szUID,
                                        SQLSMALLINT       cbUID,
                                        SQLCHAR     FAR   *szAuthStr,
                                        SQLSMALLINT       cbAuthStr);

SQLRETURN SQL_API_FN  SQLDescribeCol   (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLCHAR     FAR   *szColName,
                                        SQLSMALLINT       cbColNameMax,
                                        SQLSMALLINT FAR   *pcbColName,
                                        SQLSMALLINT FAR   *pfSqlType,
                                        SQLUINTEGER FAR   *pcbColDef,
                                        SQLSMALLINT FAR   *pibScale,
                                        SQLSMALLINT FAR   *pfNullable);

SQLRETURN SQL_API_FN  SQLDisconnect    (SQLHDBC           hdbc);

SQLRETURN SQL_API_FN  SQLError         (SQLHENV           henv,
                                        SQLHDBC           hdbc,
                                        SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szSqlState,
                                        SQLINTEGER  FAR   *pfNativeError,
                                        SQLCHAR     FAR   *szErrorMsg,
                                        SQLSMALLINT       cbErrorMsgMax,
                                        SQLSMALLINT FAR   *pcbErrorMsg);

SQLRETURN SQL_API_FN  SQLExecDirect    (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szSqlStr,
                                        SQLINTEGER        cbSqlStr);

SQLRETURN SQL_API_FN  SQLExecute       (SQLHSTMT          hstmt);

SQLRETURN SQL_API_FN  SQLFetch         (SQLHSTMT          hstmt);

SQLRETURN SQL_API_FN  SQLFreeConnect   (SQLHDBC           hdbc);

SQLRETURN SQL_API_FN  SQLFreeEnv       (SQLHENV           henv);

SQLRETURN SQL_API_FN  SQLFreeStmt      (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      fOption);

SQLRETURN SQL_API_FN  SQLGetCursorName (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szCursor,
                                        SQLSMALLINT       cbCursorMax,
                                        SQLSMALLINT FAR   *pcbCursor);

SQLRETURN SQL_API_FN  SQLGetData       (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLSMALLINT       fCType,
                                        SQLPOINTER        rgbValue,
                                        SQLINTEGER        cbValueMax,
                                        SQLINTEGER  FAR   *pcbValue);

SQLRETURN SQL_API_FN  SQLNumResultCols (SQLHSTMT          hstmt,
                                        SQLSMALLINT FAR   *pccol);

SQLRETURN SQL_API_FN  SQLPrepare       (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szSqlStr,
                                        SQLINTEGER        cbSqlStr);

SQLRETURN SQL_API_FN  SQLRowCount      (SQLHSTMT          hstmt,
                                        SQLINTEGER  FAR   *pcrow);

SQLRETURN SQL_API_FN  SQLSetCursorName (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szCursor,
                                        SQLSMALLINT       cbCursor);

SQLRETURN SQL_API_FN  SQLSetParam      (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      ipar,
                                        SQLSMALLINT       fCType,
                                        SQLSMALLINT       fSqlType,
                                        SQLUINTEGER       cbParamDef,
                                        SQLSMALLINT       ibScale,
                                        SQLPOINTER        rgbValue,
                                        SQLINTEGER  FAR   *pcbValue);

SQLRETURN SQL_API_FN  SQLTransact      (SQLHENV           henv,
                                        SQLHDBC           hdbc,
                                        SQLUSMALLINT      fType);



#ifdef __cplusplus
}
#endif


#endif /* SQL_H_SQLCLI */
LCHAR k P  $        Р  R1R1ZU1           Р      ./usr/lpp/db2_02_01/include/sqlcli1.h  .                    $          /******************************************************************************
 *
 * Source File Name = SQLCLI1.H
 *
 * (C) COPYRIGHT International Business Machines Corp. 1993, 1995
 * All Rights Reserved
 * Licensed Materials - Property of IBM
 *
 * US Government Users Restricted Rights - Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 * Function = Include File defining:
 *              DB2 CLI Interface - Constants
 *              DB2 CLI Interface - Function Prototypes
 *
 * Operating System = Common C Include File
 *
 *****************************************************************************/

#ifndef SQL_H_SQLCLI1
   #define SQL_H_SQLCLI1           /* Permit duplicate Includes */


#ifdef __cplusplus
extern "C" {
#endif

#include "sqlsystm.h"              /* System dependent defines  */


#if defined(DB2WIN) || defined(DB2NT)
#include <windows.h>
#endif
#ifdef DB2OS2
#define INCL_WIN
#define INCL_DOS
#include <os2.h>
#endif

#include    "sqlca.h"
#include    "sqlcli.h"

/* generally useful constants */
#define SQL_MAX_OPTION_STRING_LENGTH    256

/* Access modes */
#define SQL_MODE_READ_WRITE             0
#define SQL_MODE_READ_ONLY              1

/* Special return values for SQLFetch/SQLExtendedFetch/SQLGetData */
#define SQL_NO_TOTAL                   (-4)

/* SQLGetFunction defines  - supported functions */
#define  SQL_API_ALL_FUNCTIONS          0
#define  SQL_API_SQLALLOCCONNECT        1
#define  SQL_API_SQLALLOCENV            2
#define  SQL_API_SQLALLOCSTMT           3
#define  SQL_API_SQLBINDCOL             4
#define  SQL_API_SQLCANCEL              5
#define  SQL_API_SQLCOLATTRIBUTES       6
#define  SQL_API_SQLCONNECT             7
#define  SQL_API_SQLDESCRIBECOL         8
#define  SQL_API_SQLDISCONNECT          9
#define  SQL_API_SQLERROR              10
#define  SQL_API_SQLEXECDIRECT         11
#define  SQL_API_SQLEXECUTE            12
#define  SQL_API_SQLFETCH              13
#define  SQL_API_SQLFREECONNECT        14
#define  SQL_API_SQLFREEENV            15
#define  SQL_API_SQLFREESTMT           16
#define  SQL_API_SQLGETCURSORNAME      17
#define  SQL_API_SQLNUMRESULTCOLS      18
#define  SQL_API_SQLPREPARE            19
#define  SQL_API_SQLROWCOUNT           20
#define  SQL_API_SQLSETCURSORNAME      21
#define  SQL_API_SQLSETPARAM           22
#define  SQL_API_SQLTRANSACT           23

#define  SQL_API_SQLCOLUMNS            40
#define  SQL_API_SQLDRIVERCONNECT      41
#define  SQL_API_SQLGETCONNECTOPTION   42
#define  SQL_API_SQLGETDATA            43
#define  SQL_API_SQLGETFUNCTIONS       44
#define  SQL_API_SQLGETINFO            45
#define  SQL_API_SQLGETSTMTOPTION      46
#define  SQL_API_SQLGETTYPEINFO        47
#define  SQL_API_SQLPARAMDATA          48
#define  SQL_API_SQLPUTDATA            49
#define  SQL_API_SQLSETCONNECTOPTION   50
#define  SQL_API_SQLSETSTMTOPTION      51
#define  SQL_API_SQLSPECIALCOLUMNS     52
#define  SQL_API_SQLSTATISTICS         53
#define  SQL_API_SQLTABLES             54
#define  SQL_API_SQLCOLUMNPRIVILEGES   56
#define  SQL_API_SQLDATASOURCES        57
#define  SQL_API_SQLEXTENDEDFETCH      59
#define  SQL_API_SQLFOREIGNKEYS        60
#define  SQL_API_SQLMORERESULTS        61
#define  SQL_API_SQLNATIVESQL          62
#define  SQL_API_SQLNUMPARAMS          63
#define  SQL_API_SQLPARAMOPTIONS       64
#define  SQL_API_SQLPRIMARYKEYS        65
#define  SQL_API_SQLPROCEDURECOLUMNS   66
#define  SQL_API_SQLPROCEDURES         67
#define  SQL_API_SQLSETSCROLLOPTIONS   69
#define  SQL_API_SQLTABLEPRIVILEGES    70
#define  SQL_API_SQLBINDPARAMETER      72

#define  SQL_API_SQLBINDFILETOCOL      1250
#define  SQL_API_SQLBINDFILETOPARAM    1251
#define  SQL_API_SQLSETCOLATTRIBUTES   1252
#define  SQL_API_SQLGETSQLCA           1253

#define  SQL_API_SQLGETLENGTH          1022
#define  SQL_API_SQLGETPOSITION        1023
#define  SQL_API_SQLGETSUBSTRING       1024

#define  SQL_API_SQLGETENVATTR         1012
#define  SQL_API_SQLSETENVATTR         1019
#define  SQL_API_SQLSETCONNECTION      1254

/* SQLGetFunction defines  - unsupported functions */
#define  SQL_API_SQLBROWSECONNECT      55
#define  SQL_API_SQLDESCRIBEPARAM      58
#define  SQL_API_SQLSETPOS             68
#define  SQL_API_SQLDRIVERS            71
#define  SQL_EXT_API_LAST              SQL_API_SQLBINDPARAMETER


/* SQLGetInfo defines  - Info Type */
#define  SQL_ACTIVE_CONNECTIONS                0
#define  SQL_ACTIVE_STATEMENTS                 1
#define  SQL_DATA_SOURCE_NAME                  2
#define  SQL_DRIVER_HDBC                       3
#define  SQL_DRIVER_HENV                       4
#define  SQL_DRIVER_HSTMT                      5
#define  SQL_DRIVER_NAME                       6
#define  SQL_DRIVER_VER                        7
#define  SQL_FETCH_DIRECTION                   8
#define  SQL_ODBC_API_CONFORMANCE              9
#define  SQL_ODBC_VER                         10
#define  SQL_ROW_UPDATES                      11
#define  SQL_ODBC_SAG_CLI_CONFORMANCE         12
#define  SQL_SERVER_NAME                      13
#define  SQL_SEARCH_PATTERN_ESCAPE            14
#define  SQL_ODBC_SQL_CONFORMANCE             15
#define  SQL_DATABASE_NAME                    16
#define  SQL_DBMS_NAME                        17
#define  SQL_DBMS_VER                         18
#define  SQL_ACCESSIBLE_TABLES                19
#define  SQL_ACCESSIBLE_PROCEDURES            20
#define  SQL_PROCEDURES                       21
#define  SQL_CONCAT_NULL_BEHAVIOR             22
#define  SQL_CURSOR_COMMIT_BEHAVIOR           23
#define  SQL_CURSOR_ROLLBACK_BEHAVIOR         24
#define  SQL_DATA_SOURCE_READ_ONLY            25
#define  SQL_DEFAULT_TXN_ISOLATION            26
#define  SQL_EXPRESSIONS_IN_ORDERBY           27
#define  SQL_IDENTIFIER_CASE                  28
#define  SQL_IDENTIFIER_QUOTE_CHAR            29
#define  SQL_MAX_COLUMN_NAME_LEN              30
#define  SQL_MAX_CURSOR_NAME_LEN              31
#define  SQL_MAX_OWNER_NAME_LEN               32
#define  SQL_MAX_PROCEDURE_NAME_LEN           33
#define  SQL_MAX_QUALIFIER_NAME_LEN           34
#define  SQL_MAX_TABLE_NAME_LEN               35
#define  SQL_MULT_RESULT_SETS                 36
#define  SQL_MULTIPLE_ACTIVE_TXN              37
#define  SQL_OUTER_JOINS                      38
#define  SQL_OWNER_TERM                       39
#define  SQL_PROCEDURE_TERM                   40
#define  SQL_QUALIFIER_NAME_SEPARATOR         41
#define  SQL_QUALIFIER_TERM                   42
#define  SQL_SCROLL_CONCURRENCY               43
#define  SQL_SCROLL_OPTIONS                   44
#define  SQL_TABLE_TERM                       45
#define  SQL_TXN_CAPABLE                      46
#define  SQL_USER_NAME                        47
#define  SQL_CONVERT_FUNCTIONS                48
#define  SQL_NUMERIC_FUNCTIONS                49
#define  SQL_STRING_FUNCTIONS                 50
#define  SQL_SYSTEM_FUNCTIONS                 51
#define  SQL_TIMEDATE_FUNCTIONS               52
#define  SQL_CONVERT_BIGINT                   53
#define  SQL_CONVERT_BINARY                   54
#define  SQL_CONVERT_BIT                      55
#define  SQL_CONVERT_CHAR                     56
#define  SQL_CONVERT_DATE                     57
#define  SQL_CONVERT_DECIMAL                  58
#define  SQL_CONVERT_DOUBLE                   59
#define  SQL_CONVERT_FLOAT                    60
#define  SQL_CONVERT_INTEGER                  61
#define  SQL_CONVERT_LONGVARCHAR              62
#define  SQL_CONVERT_NUMERIC                  63
#define  SQL_CONVERT_REAL                     64
#define  SQL_CONVERT_SMALLINT                 65
#define  SQL_CONVERT_TIME                     66
#define  SQL_CONVERT_TIMESTAMP                67
#define  SQL_CONVERT_TINYINT                  68
#define  SQL_CONVERT_VARBINARY                69
#define  SQL_CONVERT_VARCHAR                  70
#define  SQL_CONVERT_LONGVARBINARY            71
#define  SQL_TXN_ISOLATION_OPTION             72
#define  SQL_ODBC_SQL_OPT_IEF                 73
#define  SQL_CORRELATION_NAME                 74
#define  SQL_NON_NULLABLE_COLUMNS             75
#define  SQL_DRIVER_HLIB                      76
#define  SQL_DRIVER_ODBC_VER                  77
#define  SQL_LOCK_TYPES                       78
#define  SQL_POS_OPERATIONS                   79
#define  SQL_POSITIONED_STATEMENTS            80
#define  SQL_GETDATA_EXTENSIONS               81
#define  SQL_BOOKMARK_PERSISTENCE             82
#define  SQL_STATIC_SENSITIVITY               83
#define  SQL_FILE_USAGE                       84
#define  SQL_NULL_COLLATION                   85
#define  SQL_ALTER_TABLE                      86
#define  SQL_COLUMN_ALIAS                     87
#define  SQL_GROUP_BY                         88
#define  SQL_KEYWORDS                         89
#define  SQL_ORDER_BY_COLUMNS_IN_SELECT       90
#define  SQL_OWNER_USAGE                      91
#define  SQL_QUALIFIER_USAGE                  92
#define  SQL_QUOTED_IDENTIFIER_CASE           93
#define  SQL_SPECIAL_CHARACTERS               94
#define  SQL_SUBQUERIES                       95
#define  SQL_UNION                            96
#define  SQL_MAX_COLUMNS_IN_GROUP_BY          97
#define  SQL_MAX_COLUMNS_IN_INDEX             98
#define  SQL_MAX_COLUMNS_IN_ORDER_BY          99
#define  SQL_MAX_COLUMNS_IN_SELECT           100
#define  SQL_MAX_COLUMNS_IN_TABLE            101
#define  SQL_MAX_INDEX_SIZE                  102
#define  SQL_MAX_ROW_SIZE_INCLUDES_LONG      103
#define  SQL_MAX_ROW_SIZE                    104
#define  SQL_MAX_STATEMENT_LEN               105
#define  SQL_MAX_TABLES_IN_SELECT            106
#define  SQL_MAX_USER_NAME_LEN               107
#define  SQL_MAX_CHAR_LITERAL_LEN            108
#define  SQL_TIMEDATE_ADD_INTERVALS          109
#define  SQL_TIMEDATE_DIFF_INTERVALS         110
#define  SQL_NEED_LONG_DATA_LEN              111
#define  SQL_MAX_BINARY_LITERAL_LEN          112
#define  SQL_LIKE_ESCAPE_CLAUSE              113
#define  SQL_QUALIFIER_LOCATION              114
#define  SQL_OJ_CAPABILITIES               65003  /* Temporary value */
#define  SQL_MAX_SCHEMA_NAME_LEN             SQL_MAX_OWNER_NAME_LEN
#define  SQL_MAX_CATALOG_NAME_LEN            SQL_MAX_QUALIFIER_NAME_LEN


#define SQL_INFO_LAST                         SQL_QUALIFIER_LOCATION
#define SQL_INFO_DRIVER_START                 1000

/* SQL_CONVERT_*  return value bitmasks - for use with SQLGetInfo */
#define  SQL_CVT_CHAR                 0x00000001L
#define  SQL_CVT_NUMERIC              0x00000002L
#define  SQL_CVT_DECIMAL              0x00000004L
#define  SQL_CVT_INTEGER              0x00000008L
#define  SQL_CVT_SMALLINT             0x00000010L
#define  SQL_CVT_FLOAT                0x00000020L
#define  SQL_CVT_REAL                 0x00000040L
#define  SQL_CVT_DOUBLE               0x00000080L
#define  SQL_CVT_VARCHAR              0x00000100L
#define  SQL_CVT_LONGVARCHAR          0x00000200L
#define  SQL_CVT_BINARY               0x00000400L
#define  SQL_CVT_VARBINARY            0x00000800L
#define  SQL_CVT_BIT                  0x00001000L
#define  SQL_CVT_TINYINT              0x00002000L
#define  SQL_CVT_BIGINT               0x00004000L
#define  SQL_CVT_DATE                 0x00008000L
#define  SQL_CVT_TIME                 0x00010000L
#define  SQL_CVT_TIMESTAMP            0x00020000L
#define  SQL_CVT_LONGVARBINARY        0x00040000L

/* SQL_CONVERT_FUNCTIONS functions - for use with SQLGetInfo */
#define  SQL_FN_CVT_CONVERT           0x00000001L

/* SQL_STRING_FUNCTIONS Bit Masks  - for use with SQLGetInfo */
#define  SQL_FN_STR_CONCAT            0x00000001L
#define  SQL_FN_STR_INSERT            0x00000002L
#define  SQL_FN_STR_LEFT              0x00000004L
#define  SQL_FN_STR_LTRIM             0x00000008L
#define  SQL_FN_STR_LENGTH            0x00000010L
#define  SQL_FN_STR_LOCATE            0x00000020L
#define  SQL_FN_STR_LCASE             0x00000040L
#define  SQL_FN_STR_REPEAT            0x00000080L
#define  SQL_FN_STR_REPLACE           0x00000100L
#define  SQL_FN_STR_RIGHT             0x00000200L
#define  SQL_FN_STR_RTRIM             0x00000400L
#define  SQL_FN_STR_SUBSTRING         0x00000800L
#define  SQL_FN_STR_UCASE             0x00001000L
#define  SQL_FN_STR_ASCII             0x00002000L
#define  SQL_FN_STR_CHAR              0x00004000L
#define  SQL_FN_STR_DIFFERENCE        0x00008000L
#define  SQL_FN_STR_LOCATE_2          0x00010000L
#define  SQL_FN_STR_SOUNDEX           0x00020000L
#define  SQL_FN_STR_SPACE             0x00040000L

/* SQL_NUMERIC_FUNCTIONS Bit Masks - for use with SQLGetInfo */
#define  SQL_FN_NUM_ABS               0x00000001L
#define  SQL_FN_NUM_ACOS              0x00000002L
#define  SQL_FN_NUM_ASIN              0x00000004L
#define  SQL_FN_NUM_ATAN              0x00000008L
#define  SQL_FN_NUM_ATAN2             0x00000010L
#define  SQL_FN_NUM_CEILING           0x00000020L
#define  SQL_FN_NUM_COS               0x00000040L
#define  SQL_FN_NUM_COT               0x00000080L
#define  SQL_FN_NUM_EXP               0x00000100L
#define  SQL_FN_NUM_FLOOR             0x00000200L
#define  SQL_FN_NUM_LOG               0x00000400L
#define  SQL_FN_NUM_MOD               0x00000800L
#define  SQL_FN_NUM_SIGN              0x00001000L
#define  SQL_FN_NUM_SIN               0x00002000L
#define  SQL_FN_NUM_SQRT              0x00004000L
#define  SQL_FN_NUM_TAN               0x00008000L
#define  SQL_FN_NUM_PI                0x00010000L
#define  SQL_FN_NUM_RAND              0x00020000L
#define  SQL_FN_NUM_DEGREES           0x00040000L
#define  SQL_FN_NUM_LOG10             0x00080000L
#define  SQL_FN_NUM_POWER             0x00100000L
#define  SQL_FN_NUM_RADIANS           0x00200000L
#define  SQL_FN_NUM_ROUND             0x00400000L
#define  SQL_FN_NUM_TRUNCATE          0x00800000L

/* SQL_TIMEDATE_FUNCTIONS Bit Masks - for use with SQLGetInfo */
#define  SQL_FN_TD_NOW                0x00000001L
#define  SQL_FN_TD_CURDATE            0x00000002L
#define  SQL_FN_TD_DAYOFMONTH         0x00000004L
#define  SQL_FN_TD_DAYOFWEEK          0x00000008L
#define  SQL_FN_TD_DAYOFYEAR          0x00000010L
#define  SQL_FN_TD_MONTH              0x00000020L
#define  SQL_FN_TD_QUARTER            0x00000040L
#define  SQL_FN_TD_WEEK               0x00000080L
#define  SQL_FN_TD_YEAR               0x00000100L
#define  SQL_FN_TD_CURTIME            0x00000200L
#define  SQL_FN_TD_HOUR               0x00000400L
#define  SQL_FN_TD_MINUTE             0x00000800L
#define  SQL_FN_TD_SECOND             0x00001000L
#define  SQL_FN_TD_TIMESTAMPADD       0x00002000L
#define  SQL_FN_TD_TIMESTAMPDIFF      0x00004000L
#define  SQL_FN_TD_DAYNAME            0x00008000L
#define  SQL_FN_TD_MONTHNAME          0x00010000L
#define  SQL_FN_TD_SECONDS_SINCE_MIDNIGHT 0x00020000L
#define  SQL_FN_TD_JULIAN_DAY         0x00040000L

/* SQL_SYSTEM_FUNCTIONS Bit Masks - for use with SQLGetInfo */
#define  SQL_FN_SYS_USERNAME          0x00000001L
#define  SQL_FN_SYS_DBNAME            0x00000002L
#define  SQL_FN_SYS_IFNULL            0x00000004L

/* SQL_TIMEDATE_ADD_INTERVALS and SQL_TIMEDATE_DIFF_INTERVALS Bit Masks
 * - for use with SQLGetInfo
 */
#define SQL_FN_TSI_FRAC_SECOND        0x00000001L
#define SQL_FN_TSI_SECOND             0x00000002L
#define SQL_FN_TSI_MINUTE             0x00000004L
#define SQL_FN_TSI_HOUR               0x00000008L
#define SQL_FN_TSI_DAY                0x00000010L
#define SQL_FN_TSI_WEEK               0x00000020L
#define SQL_FN_TSI_MONTH              0x00000040L
#define SQL_FN_TSI_QUARTER            0x00000080L
#define SQL_FN_TSI_YEAR               0x00000100L


/* SQL_ODBC_API_CONFORMANCE values */
#define SQL_OAC_NONE                  0x0000
#define SQL_OAC_LEVEL1                0x0001
#define SQL_OAC_LEVEL2                0x0002


/* SQL_ODBC_SAG_CLI_CONFORMANCE values */

#define SQL_OSCC_NOT_COMPLIANT        0x0000
#define SQL_OSCC_COMPLIANT            0x0001

/* SQL_ODBC_SQL_CONFORMANCE values */

#define SQL_OSC_MINIMUM               0x0000
#define SQL_OSC_CORE                  0x0001
#define SQL_OSC_EXTENDED              0x0002

/* SQL_CONCAT_NULL_BEHAVIOR values */

#define SQL_CB_NULL                   0x0000
#define SQL_CB_NON_NULL               0x0001

/* SQL_CURSOR_COMMIT_BEHAVIOR and SQL_CURSOR_ROLLBACK_BEHAVIOR values */

#define SQL_CB_DELETE                 0x0000
#define SQL_CB_CLOSE                  0x0001
#define SQL_CB_PRESERVE               0x0002

/* SQL_IDENTIFIER_CASE values */

#define SQL_IC_UPPER                  0x0001
#define SQL_IC_LOWER                  0x0002
#define SQL_IC_SENSITIVE              0x0003
#define SQL_IC_MIXED                  0x0004

/* SQL_TXN_CAPABLE values */

#define SQL_TC_NONE                   0x0000
#define SQL_TC_DML                    0x0001
#define SQL_TC_ALL                    0x0002
#define SQL_TC_DDL_COMMIT             0x0003
#define SQL_TC_DDL_IGNORE             0x0004

/* SQL_SCROLL_OPTIONS masks */

#define SQL_SO_FORWARD_ONLY           0x00000001L
#define SQL_SO_KEYSET_DRIVEN          0x00000002L
#define SQL_SO_DYNAMIC                0x00000004L
#define SQL_SO_MIXED                  0x00000008L
#define SQL_SO_STATIC                 0x00000010L

/* SQL_SCROLL_CONCURRENCY masks */

#define SQL_SCCO_READ_ONLY            0x00000001L
#define SQL_SCCO_LOCK                 0x00000002L
#define SQL_SCCO_OPT_ROWVER           0x00000004L
#define SQL_SCCO_OPT_VALUES           0x00000008L
#define SQL_SCCO_OPT_TIMESTAMP        SQL_SCCO_OPT_ROWVER   /* deprecated */

/* SQL_FETCH_DIRECTION masks */

#define  SQL_FD_FETCH_NEXT            0x00000001L
#define  SQL_FD_FETCH_FIRST           0x00000002L
#define  SQL_FD_FETCH_LAST            0x00000004L
#define  SQL_FD_FETCH_PREV            0x00000008L
#define  SQL_FD_FETCH_ABSOLUTE        0x00000010L
#define  SQL_FD_FETCH_RELATIVE        0x00000020L
#define  SQL_FD_FETCH_RESUME          0x00000040L
#define  SQL_FD_FETCH_BOOKMARK        0x00000080L

/* SQL_TXN_ISOLATION_OPTION masks */
#define  SQL_TXN_READ_UNCOMMITTED     0x00000001L
#define  SQL_TXN_READ_COMMITTED       0x00000002L
#define  SQL_TXN_REPEATABLE_READ      0x00000004L
#define  SQL_TXN_SERIALIZABLE         0x00000008L
#define  SQL_TXN_VERSIONING           0x00000010L
#define  SQL_TXN_NOCOMMIT             0x00000020L

/* SQL_CORRELATION_NAME values */

#define SQL_CN_NONE                   0x0000
#define SQL_CN_DIFFERENT              0x0001
#define SQL_CN_ANY                    0x0002

/* SQL_NON_NULLABLE_COLUMNS values */

#define SQL_NNC_NULL                  0x0000
#define SQL_NNC_NON_NULL              0x0001

/* SQL_NULL_COLLATION values */

#define SQL_NC_HIGH                   0x0000
#define SQL_NC_LOW                    0x0001
#define SQL_NC_START                  0x0002
#define SQL_NC_END                    0x0040

/* SQL_FILE_USAGE values */

#define SQL_FILE_NOT_SUPPORTED        0x0000
#define SQL_FILE_TABLE                0x0001
#define SQL_FILE_QUALIFIER            0x0002

/* SQL_GETDATA_EXTENSIONS values */

#define SQL_GD_ANY_COLUMN             0x00000001L
#define SQL_GD_ANY_ORDER              0x00000002L
#define SQL_GD_BLOCK                  0x00000004L
#define SQL_GD_BOUND                  0x00000008L

/* SQL_ALTER_TABLE values */

#define SQL_AT_ADD_COLUMN             0x00000001L
#define SQL_AT_DROP_COLUMN            0x00000002L

/* SQL_POSITIONED_STATEMENTS masks */

#define SQL_PS_POSITIONED_DELETE      0x00000001L
#define SQL_PS_POSITIONED_UPDATE      0x00000002L
#define SQL_PS_SELECT_FOR_UPDATE      0x00000004L

/* SQL_GROUP_BY values */

#define SQL_GB_NOT_SUPPORTED            0x0000
#define SQL_GB_GROUP_BY_EQUALS_SELECT   0x0001
#define SQL_GB_GROUP_BY_CONTAINS_SELECT 0x0002
#define SQL_GB_NO_RELATION              0x0003

/* SQL_OWNER_USAGE masks */

#define SQL_OU_DML_STATEMENTS         0x00000001L
#define SQL_OU_PROCEDURE_INVOCATION   0x00000002L
#define SQL_OU_TABLE_DEFINITION       0x00000004L
#define SQL_OU_INDEX_DEFINITION       0x00000008L
#define SQL_OU_PRIVILEGE_DEFINITION   0x00000010L

/* SQL_QUALIFIER_USAGE masks */

#define SQL_QU_DML_STATEMENTS         0x00000001L
#define SQL_QU_PROCEDURE_INVOCATION   0x00000002L
#define SQL_QU_TABLE_DEFINITION       0x00000004L
#define SQL_QU_INDEX_DEFINITION       0x00000008L
#define SQL_QU_PRIVILEGE_DEFINITION   0x00000010L

/* SQL_SUBQUERIES masks */

#define SQL_SQ_COMPARISON             0x00000001L
#define SQL_SQ_EXISTS                 0x00000002L
#define SQL_SQ_IN                     0x00000004L
#define SQL_SQ_QUANTIFIED             0x00000008L
#define SQL_SQ_CORRELATED_SUBQUERIES  0x00000010L

/* SQL_UNION masks */

#define SQL_U_UNION                   0x00000001L
#define SQL_U_UNION_ALL               0x00000002L

/* SQL_BOOKMARK_PERSISTENCE values */

#define SQL_BP_CLOSE                  0x00000001L
#define SQL_BP_DELETE                 0x00000002L
#define SQL_BP_DROP                   0x00000004L
#define SQL_BP_TRANSACTION            0x00000008L
#define SQL_BP_UPDATE                 0x00000010L
#define SQL_BP_OTHER_HSTMT            0x00000020L
#define SQL_BP_SCROLL                 0x00000040L

/* SQL_STATIC_SENSITIVITY values */

#define SQL_SS_ADDITIONS              0x00000001L
#define SQL_SS_DELETIONS              0x00000002L
#define SQL_SS_UPDATES                0x00000004L

/* SQL_LOCK_TYPES masks */

#define SQL_LCK_NO_CHANGE             0x00000001L
#define SQL_LCK_EXCLUSIVE             0x00000002L
#define SQL_LCK_UNLOCK                0x00000004L

/* SQL_POS_OPERATIONS masks */

#define SQL_POS_POSITION              0x00000001L
#define SQL_POS_REFRESH               0x00000002L
#define SQL_POS_UPDATE                0x00000004L
#define SQL_POS_DELETE                0x00000008L
#define SQL_POS_ADD                   0x00000010L

/* SQL_QUALIFIER_LOCATION values */

#define SQL_QL_START                  0x0001L
#define SQL_QL_END                    0x0002L

/* SQL_OJ_CAPABILITIES values */

#define SQL_OJ_LEFT                   0x00000001L
#define SQL_OJ_RIGHT                  0x00000002L
#define SQL_OJ_FULL                   0x00000004L
#define SQL_OJ_NESTED                 0x00000008L
#define SQL_OJ_NOT_ORDERED            0x00000010L
#define SQL_OJ_INNER                  0x00000020L
#define SQL_OJ_ALL_COMPARISON_OPS     0x00000040L


/* SQLGetTypeInfo define */
#define  SQL_ALL_TYPES                0

/* Options for SQLGetStmtOption/SQLSetStmtOption */
#define  SQL_QUERY_TIMEOUT      0
#define  SQL_MAX_ROWS           1
#define  SQL_NOSCAN             2
#define  SQL_MAX_LENGTH         3
#define  SQL_ASYNC_ENABLE       4
#define  SQL_BIND_TYPE          5
#define  SQL_CURSOR_TYPE        6
#define  SQL_CONCURRENCY        7
#define  SQL_KEYSET_SIZE        8
#define  SQL_ROWSET_SIZE        9
#define  SQL_SIMULATE_CURSOR    10
#define  SQL_RETRIEVE_DATA      11
#define  SQL_USE_BOOKMARKS      12
#define  SQL_GET_BOOKMARK       13
#define  SQL_ROW_NUMBER         14

/* Options for SQLGetStmtOption/SQLSetStmtOption extensions */
#define  SQL_CURSOR_HOLD        1250
#define  SQL_NODESCRIBE_OUTPUT  1251

#define  SQL_NODESCRIBE_INPUT   1264
#define  SQL_NODESCRIBE         SQL_NODESCRIBE_OUTPUT
#define  SQL_CLOSE_BEHAVIOR     1257

/* SQL_CLOSE_BEHAVIOR values.                  */

#define SQL_CC_NO_RELEASE             0
#define SQL_CC_RELEASE                1
#define SQL_CC_DEFAULT                SQL_CC_NO_RELEASE

/* CLI attribute/option values */
#define SQL_FALSE               0
#define SQL_TRUE                1

/* Options for SQL_CURSOR_HOLD */
#define SQL_CURSOR_HOLD_ON        1
#define SQL_CURSOR_HOLD_OFF       0
#define SQL_CURSOR_HOLD_DEFAULT   SQL_CURSOR_HOLD_ON


/* Options for SQL_NODESCRIBE_INPUT/SQL_NODESCRIBE_OUTPUT */
#define SQL_NODESCRIBE_ON          1
#define SQL_NODESCRIBE_OFF         0
#define SQL_NODESCRIBE_DEFAULT     SQL_NODESCRIBE_OFF

/* SQL_QUERY_TIMEOUT options */
#define SQL_QUERY_TIMEOUT_DEFAULT  0

/* SQL_MAX_ROWS options */
#define SQL_MAX_ROWS_DEFAULT       0

/* SQL_NOSCAN options */
#define SQL_NOSCAN_OFF             0
#define SQL_NOSCAN_ON              1
#define SQL_NOSCAN_DEFAULT         SQL_NOSCAN_OFF

/* SQL_MAX_LENGTH options */
#define SQL_MAX_LENGTH_DEFAULT     0

/* SQL_ASYNC_ENABLE options */
#define SQL_ASYNC_ENABLE_OFF       0
#define SQL_ASYNC_ENABLE_ON        1
#define SQL_ASYNC_ENABLE_DEFAULT   SQL_ASYNC_ENABLE_OFF

/* SQL_BIND_TYPE options */
#define SQL_BIND_BY_COLUMN         0
#define SQL_BIND_TYPE_DEFAULT      SQL_BIND_BY_COLUMN

/* SQL_CONCURRENCY options */
#define SQL_CONCUR_READ_ONLY       1
#define SQL_CONCUR_LOCK            2
#define SQL_CONCUR_ROWVER          3
#define SQL_CONCUR_VALUES          4
#define SQL_CONCUR_DEFAULT         SQL_CONCUR_READ_ONLY

/* SQL_CURSOR_TYPE options */
#define SQL_CURSOR_FORWARD_ONLY    0
#define SQL_CURSOR_KEYSET_DRIVEN   1
#define SQL_CURSOR_DYNAMIC         2
#define SQL_CURSOR_STATIC          3
#define SQL_CURSOR_TYPE_DEFAULT    SQL_CURSOR_FORWARD_ONLY

/* SQL_ROWSET_SIZE options */
#define SQL_ROWSET_SIZE_DEFAULT    1

/* SQL_KEYSET_SIZE options */
#define SQL_KEYSET_SIZE_DEFAULT    0

/* SQL_SIMULATE_CURSOR options */
#define SQL_SC_NON_UNIQUE          0
#define SQL_SC_TRY_UNIQUE          1
#define SQL_SC_UNIQUE              2

/* SQL_RETRIEVE_DATA options */
#define SQL_RD_OFF                 0
#define SQL_RD_ON                  1
#define SQL_RD_DEFAULT             SQL_RD_ON

/* SQL_USE_BOOKMARKS options */
#define SQL_UB_OFF                 0
#define SQL_UB_ON                  1
#define SQL_UB_DEFAULT             SQL_UB_OFF

/* Options for SQLSetConnectOption/SQLGetConnectOption */
#define SQL_ACCESS_MODE              101
#define SQL_AUTOCOMMIT               102
#define SQL_LOGIN_TIMEOUT            103
#define SQL_OPT_TRACE                104
#define SQL_OPT_TRACEFILE            105
#define SQL_TRANSLATE_DLL            106
#define SQL_TRANSLATE_OPTION         107
#define SQL_TXN_ISOLATION            108
#define SQL_CURRENT_QUALIFIER        109
#define SQL_ODBC_CURSORS             110
#define SQL_QUIET_MODE               111
#define SQL_PACKET_SIZE              112
#define SQL_CONNECT_OPT_DRVR_START   1000

/* Options for SQLGetConnectOption/SQLSetConnectOption extensions */
#define SQL_WCHARTYPE                1252
#define SQL_LONGDATA_COMPAT          1253
#define SQL_CURRENT_SCHEMA           1254
#define SQL_DB2EXPLAIN               1258
#define SQL_DB2ESTIMATE              1259
#define SQL_PARAMOPT_ATOMIC          1260
#define SQL_STMTTXN_ISOLATION        1261
#define SQL_MAXCONN                  1262

/* Options for SQLSetConnectOption, SQLSetEnvAttr */
#define SQL_CONNECTTYPE              1255
#define SQL_SYNC_POINT               1256
#define SQL_MINMEMORY_USAGE          1263

/* Options for SQL_LONGDATA_COMPAT */
#define SQL_LD_COMPAT_YES            1
#define SQL_LD_COMPAT_NO             0
#define SQL_LD_COMPAT_DEFAULT        SQL_LD_COMPAT_NO

/*
 *  Options for SQL_PARAMOPT_ATOMIC
 */

#define SQL_ATOMIC_YES               1
#define SQL_ATOMIC_NO                0
#define SQL_ATOMIC_DEFAULT           SQL_ATOMIC_YES

/* Options for SQL_CONNECT_TYPE */
#define SQL_CONCURRENT_TRANS         1
#define SQL_COORDINATED_TRANS        2
#define SQL_CONNECTTYPE_DEFAULT      SQL_CONCURRENT_TRANS

/* Options for SQL_SYNCPOINT */
#define SQL_ONEPHASE                 1
#define SQL_TWOPHASE                 2
#define SQL_SYNCPOINT_DEFAULT        SQL_ONEPHASE

/* Options for SQL_DB2ESTIMATE */
#define SQL_DB2ESTIMATE_ON           1
#define SQL_DB2ESTIMATE_OFF          0
#define SQL_DB2ESTIMATE_DEFAULT      SQL_DB2ESTIMATE_OFF

/* Options for SQL_DB2EXPLAIN */
#define SQL_DB2EXPLAIN_OFF              0x00000000L
#define SQL_DB2EXPLAIN_SNAPSHOT_ON      0x00000001L
#define SQL_DB2EXPLAIN_MODE_ON          0x00000002L
#define SQL_DB2EXPLAIN_SNAPSHOT_MODE_ON SQL_DB2EXPLAIN_SNAPSHOT_ON+SQL_DB2EXPLAIN_MODE_ON
#define SQL_DB2EXPLAIN_ON               SQL_DB2EXPLAIN_SNAPSHOT_ON
#define SQL_DB2EXPLAIN_DEFAULT          SQL_DB2EXPLAIN_OFF

/* Options for SQL_WCHARTYPE
 * Note that you can only specify SQL_WCHARTYPE_CONVERT if you have an
 * external compile flag SQL_WCHART_CONVERT defined
 */
#ifdef SQL_WCHART_CONVERT
#define SQL_WCHARTYPE_CONVERT        1
#endif
#define SQL_WCHARTYPE_NOCONVERT      0
#define SQL_WCHARTYPE_DEFAULT        SQL_WCHARTYPE_NOCONVERT

/* SQL_ACCESS_MODE options */
#define SQL_MODE_READ_WRITE          0
#define SQL_MODE_READ_ONLY           1
#define SQL_MODE_DEFAULT             SQL_MODE_READ_WRITE

/* SQL_AUTOCOMMIT options */
#define SQL_AUTOCOMMIT_OFF           0
#define SQL_AUTOCOMMIT_ON            1
#define SQL_AUTOCOMMIT_DEFAULT       SQL_AUTOCOMMIT_ON

/* SQL_LOGIN_TIMEOUT options */
#define SQL_LOGIN_TIMEOUT_DEFAULT    0

/* Column types and scopes in SQLSpecialColumns */
#define SQL_BEST_ROWID               1
#define SQL_ROWVER                   2

#define SQL_SCOPE_CURROW             0
#define SQL_SCOPE_TRANSACTION        1
#define SQL_SCOPE_SESSION            2

/* Defines for SQLStatistics */
#define SQL_INDEX_UNIQUE             0
#define SQL_INDEX_ALL                1

#define SQL_QUICK                    0
#define SQL_ENSURE                   1

/* Defines for SQLStatistics (returned in the result set) */
#define SQL_TABLE_STAT               0
#define SQL_INDEX_CLUSTERED          1
#define SQL_INDEX_HASHED             2
#define SQL_INDEX_OTHER              3

/* Defines for SQLSpecialColumns (returned in the result set) */
#define SQL_PC_UNKNOWN               0
#define SQL_PC_NOT_PSEUDO            1
#define SQL_PC_PSEUDO                2

/* SQLDataSources "fDirection" values, also used on SQLExtendedFetch() */
/* See sqlext.h for additional SQLExtendedFetch fetch direction defines */
#define  SQL_FETCH_NEXT              1
#define  SQL_FETCH_FIRST             2


/*
 * Environment attributes; note SQL_CONNECTTYPE, SQL_SYNC_POINT are also
 * environment attributes that are settable at the connection level
 */
#define SQL_ATTR_OUTPUT_NTS          10001


/*  LOB file reference options */
#ifndef SQL_H_SQL                     /* if sql.h is not included, then...  */
#define SQL_FILE_READ              2  /* Input file to read from            */
#define SQL_FILE_CREATE            8  /* Output file - new file to be       */
                                      /* created                            */
#define SQL_FILE_OVERWRITE        16  /* Output file - overwrite existing   */
                                      /* file or create a new file if it    */
                                      /* doesn't exist                      */
#define SQL_FILE_APPEND           32  /* Output file - append to an         */
                                      /* existing file or create a new file */
                                      /* if it doesn't exist                */
#endif

/*
 *  Source of string for SQLGetLength(), SQLGetPosition(),
 *  and SQLGetSubstring().
 */
#define SQL_FROM_LOCATOR           2
#define SQL_FROM_LITERAL           3



/*
 *  Function definitions of APIs in both X/Open CLI and ODBC
 */

SQLRETURN SQL_API_FN  SQLColumns       (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szCatalogName,
                                        SQLSMALLINT       cbCatalogName,
                                        SQLCHAR     FAR   *szSchemaName,
                                        SQLSMALLINT       cbSchemaName,
                                        SQLCHAR     FAR   *szTableName,
                                        SQLSMALLINT       cbTableName,
                                        SQLCHAR     FAR   *szColumnName,
                                        SQLSMALLINT       cbColumnName);

SQLRETURN SQL_API_FN  SQLDataSources   (SQLHENV           henv,
                                        SQLUSMALLINT      fDirection,
                                        SQLCHAR     FAR   *szDSN,
                                        SQLSMALLINT       cbDSNMax,
                                        SQLSMALLINT FAR   *pcbDSN,
                                        SQLCHAR     FAR   *szDescription,
                                        SQLSMALLINT       cbDescriptionMax,
                                        SQLSMALLINT FAR   *pcbDescription);

SQLRETURN SQL_API_FN  SQLGetConnectOption (
                                        SQLHDBC           hdbc,
                                        SQLUSMALLINT      fOption,
                                        SQLPOINTER        pvParam);

SQLRETURN SQL_API_FN  SQLGetFunctions  (SQLHDBC           hdbc,
                                        SQLUSMALLINT      fFunction,
                                        SQLUSMALLINT FAR  *pfExists);

SQLRETURN SQL_API_FN  SQLGetInfo       (SQLHDBC           hdbc,
                                        SQLUSMALLINT      fInfoType,
                                        SQLPOINTER        rgbInfoValue,
                                        SQLSMALLINT       cbInfoValueMax,
                                        SQLSMALLINT FAR   *pcbInfoValue);

SQLRETURN SQL_API_FN  SQLGetStmtOption (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      fOption,
                                        SQLPOINTER        pvParam);

SQLRETURN SQL_API_FN  SQLGetTypeInfo   (SQLHSTMT          hstmt,
                                        SQLSMALLINT       fSqlType);

SQLRETURN SQL_API_FN  SQLParamData     (SQLHSTMT          hstmt,
                                        SQLPOINTER  FAR   *prgbValue);

SQLRETURN SQL_API_FN  SQLPutData       (SQLHSTMT          hstmt,
                                        SQLPOINTER        rgbValue,
                                        SQLINTEGER        cbValue);

SQLRETURN SQL_API_FN  SQLSetConnectOption(
                                        SQLHDBC           hdbc,
                                        SQLUSMALLINT      fOption,
                                        SQLUINTEGER       vParam);

SQLRETURN SQL_API_FN  SQLSetStmtOption (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      fOption,
                                        SQLUINTEGER       vParam);

SQLRETURN SQL_API_FN  SQLSpecialColumns(SQLHSTMT          hstmt,
                                        SQLUSMALLINT      fColType,
                                        SQLCHAR     FAR   *szCatalogName,
                                        SQLSMALLINT       cbCatalogName,
                                        SQLCHAR     FAR   *szSchemaName,
                                        SQLSMALLINT       cbSchemaName,
                                        SQLCHAR     FAR   *szTableName,
                                        SQLSMALLINT       cbTableName,
                                        SQLUSMALLINT      fScope,
                                        SQLUSMALLINT      fNullable);

SQLRETURN SQL_API_FN  SQLStatistics    (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szCatalogName,
                                        SQLSMALLINT       cbCatalogName,
                                        SQLCHAR     FAR   *szSchemaName,
                                        SQLSMALLINT       cbSchemaName,
                                        SQLCHAR     FAR   *szTableName,
                                        SQLSMALLINT       cbTableName,
                                        SQLUSMALLINT      fUnique,
                                        SQLUSMALLINT      fAccuracy);

SQLRETURN SQL_API_FN  SQLTables        (SQLHSTMT          hstmt,
                                        SQLCHAR     FAR   *szCatalogName,
                                        SQLSMALLINT       cbCatalogName,
                                        SQLCHAR     FAR   *szSchemaName,
                                        SQLSMALLINT       cbSchemaName,
                                        SQLCHAR     FAR   *szTableName,
                                        SQLSMALLINT       cbTableName,
                                        SQLCHAR     FAR   *szTableType,
                                        SQLSMALLINT       cbTableType);


/*
 * DB2 specific CLI APIs
 */

SQLRETURN SQL_API_FN SQLBindFileToCol  (SQLHSTMT          hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLCHAR     FAR   *FileName,
                                        SQLSMALLINT FAR   *FileNameLength,
                                        SQLUINTEGER FAR   *FileOptions,
                                        SQLSMALLINT       MaxFileNameLength,
                                        SQLINTEGER  FAR   *StringLength,
                                        SQLINTEGER  FAR   *IndicatorValue);

SQLRETURN SQL_API_FN SQLBindFileToParam(SQLHSTMT          hstmt,
                                        SQLUSMALLINT      ipar,
                                        SQLSMALLINT       fSqlType,
                                        SQLCHAR     FAR   *FileName,
                                        SQLSMALLINT FAR   *FileNameLength,
                                        SQLUINTEGER FAR   *FileOptions,
                                        SQLSMALLINT       MaxFileNameLength,
                                        SQLINTEGER  FAR   *IndicatorValue);

SQLRETURN SQL_API_FN SQLGetLength      (SQLHSTMT          hstmt,
                                        SQLSMALLINT       LocatorCType,
                                        SQLINTEGER        Locator,
                                        SQLINTEGER  FAR   *StringLength,
                                        SQLINTEGER  FAR   *IndicatorValue);

SQLRETURN SQL_API_FN SQLGetPosition    (SQLHSTMT          hstmt,
                                        SQLSMALLINT       LocatorCType,
                                        SQLINTEGER        SourceLocator,
                                        SQLINTEGER        SearchLocator,
                                        SQLCHAR     FAR   *SearchLiteral,
                                        SQLINTEGER        SearchLiteralLength,
                                        SQLUINTEGER       FromPosition,
                                        SQLUINTEGER FAR   *LocatedAt,
                                        SQLINTEGER  FAR   *IndicatorValue);


SQLRETURN SQL_API_FN SQLGetSQLCA       (SQLHENV           henv,
                                        SQLHDBC           hdbc,
                                        SQLHSTMT          hstmt,
                                        struct sqlca FAR  *pSqlca );

SQLRETURN SQL_API_FN SQLGetSubString   (SQLHSTMT          hstmt,
                                        SQLSMALLINT       LocatorCType,
                                        SQLINTEGER        SourceLocator,
                                        SQLUINTEGER       FromPosition,
                                        SQLUINTEGER       ForLength,
                                        SQLSMALLINT       TargetCType,
                                        SQLPOINTER        rgbValue,
                                        SQLINTEGER        cbValueMax,
                                        SQLINTEGER  FAR   *StringLength,
                                        SQLINTEGER  FAR   *IndicatorValue);

SQLRETURN SQL_API_FN SQLSetColAttributes (SQLHSTMT        hstmt,
                                        SQLUSMALLINT      icol,
                                        SQLCHAR     FAR   *pszColName,
                                        SQLSMALLINT       cbColName,
                                        SQLSMALLINT       fSQLType,
                                        SQLUINTEGER       cbColDef,
                                        SQLSMALLINT       ibScale,
                                        SQLSMALLINT       fNullable);

/*
 *  Set active connection API, for use in conjunction with embedded
 *  SQL programming only.
 */
SQLRETURN SQL_API_FN SQLSetConnection  (SQLHDBC           hdbc);

/*
 * APIs defined only by X/Open CLI
 */

SQLRETURN SQL_API_FN SQLGetEnvAttr     (SQLHENV           henv,
                                        SQLINTEGER        Attribute,
                                        SQLPOINTER        Value,
                                        SQLINTEGER        BufferLength,
                                        SQLINTEGER  FAR   *StringLength);

SQLRETURN SQL_API_FN SQLSetEnvAttr     (SQLHENV           henv,
                                        SQLINTEGER        Attribute,
                                        SQLPOINTER        Value,
                                        SQLINTEGER        StringLength);




#ifdef __cplusplus
}
#endif

/*
 * Include ODBC Version 2.50 header files for ODBC Level 1 and Level 2
 * functions that are not specified in the X/Open Call Level Interface.
 * This is included with permission from Microsoft.
 * Do not modify (i.e. must not add, remove, rearrange) any part of the
 * contents of sqlext.h
 * Note: SQLBrowseConnect(), SQLDescribeParam(), SQLDrivers, and SQLSetPos()
 *       in sqlext.h are not supported by the current version of DB2 CLI.
 */
#ifndef __SQL
#define __SQL
#define ODBCVER 0x0250
#endif
#include "sqlext.h"

#endif /* SQL_H_SQLCLI1 */
kꎳ R  $        a  R1R1ZU1           a      ./usr/lpp/db2_02_01/include/sqlcodes.h .                    $          /******************************************************************************
** 
** Source File Name: SQLCODES
** 
** (C) COPYRIGHT International Business Machines Corp. 1987, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function: Include File defining:
**             Labels for SQLCODES
** 
** Operating System: AIX
** 
*******************************************************************************/
#ifndef SQL_H_SQLCODES
#define SQL_H_SQLCODES

#ifdef __cplusplus
extern "C" {
#endif


#include "sqlsystm.h"                  /* System dependent defines  */

/* SQL Return Codes in SQLCODE                                                */

#ifndef   SQL_RC_OK
#define SQL_RC_OK              0       /* successful execution                */
#endif

/* ------------ warnings ------------                                         */
#define SQL_RC_W012            12      /* correlation without qualification   */
#define SQL_RC_W020            20      /* unsupported bind/prep options       */
#define SQL_RC_W100            100     /* eof                                 */
#define SQL_RC_W139            139     /* duplicate column conistraint        */
#define SQL_RC_W143            143     /* invalid syntax ignored              */
#define SQL_RC_W217            217     /* explain mode incompatible           */
#define SQL_RC_W236            236     /* not enough sqlvars, none filled in  */
#define SQL_RC_W237            237     /* distinct type: not enough sqlvars,  */
                                       /* some filled in                      */
#define SQL_RC_W238            238     /* LOB type: not enough sqlvars, none  */
                                       /* filled in                           */
#define SQL_RC_W239            239     /* distinct type: not enough sqlvars,  */
                                       /* none filled in                      */
#define SQL_RC_W280            280     /* new view replaced old               */
#define SQL_RC_W347            347     /* possible infinite loop              */
#define SQL_RC_W403            403     /* alias target is not defined         */
#define SQL_RC_W434            434     /* clause value has been replaced      */
#define SQL_RC_W437            437     /* Sub-optimal query                   */
#define SQL_RC_W445            445     /* Function has truncated value        */
#define SQL_RC_W447            447     /* Create UDF contains redundant keyw  */
#define SQL_RC_W462            462     /* UDF returns a warning sqlstate      */
#define SQL_RC_W474            474     /* DDL:could truncate value at         */
                                       /* runtime                             */
#define SQL_RC_W477            477     /* DDL:could truncate value at         */
                                       /* runtime                             */
#define SQL_RC_W541            541     /* duplicate referential constraint    */
#define SQL_RC_W595            595     /* Isolation level escalated           */
#define SQL_RC_W598            598     /* existing index used                 */
#define SQL_RC_W599            599     /* compare func not created for lstr   */
#define SQL_RC_W605            605     /* index already exists                */
#define SQL_RC_W965            965     /* unknown SQL warning another         */
                                       /* product                             */
#define SQL_RC_W997            997     /* XA informational message            */
#define SQL_RC_W1251           1251    /* XA no data to return from recover   */
#define SQL_RC_W1580           1580    /* Trailing blanks are truncated       */
#define SQLM_RC_NOT_SET        1615    /* Event monitor state not changed     */

/* ------------ errors ------------                                           */
#define SQL_RC_E007            -7      /* illegal character                   */
#define SQL_RC_E010            -10     /* string constant not terminated      */
#define SQL_RC_E013            -13     /* cursor or statement name = ""       */
#define SQL_RC_E029            -29     /* INTO clause required                */
#define SQL_RC_E051            -51     /* reserved                            */
#define SQL_RC_E084            -84     /* bad SQL statement                   */

#define SQL_RC_E101            -101    /* statement too long                  */
#define SQL_RC_E102            -102    /* string constant too long            */
#define SQL_RC_E103            -103    /* invalid numeric literal             */
#define SQL_RC_E104            -104    /* invalid character/token             */
#define SQL_RC_E105            -105    /* invalid string constant             */
#define SQL_RC_E107            -107    /* name too long                       */
#define SQL_RC_E108            -108    /* name has too many qualifiers        */
#define SQL_RC_E109            -109    /* clause not permitted                */
#define SQL_RC_E110            -110    /* invalid hex constant                */
#define SQL_RC_E111            -111    /* no column name                      */
#define SQL_RC_E112            -112    /* operand is SQL function             */
#define SQL_RC_E117            -117    /* wrong nbr of insert values          */
#define SQL_RC_E118            -118    /* object table in from clause         */
#define SQL_RC_E119            -119    /* column not in group by              */
#define SQL_RC_E120            -120    /* clause includes SQL fn              */
#define SQL_RC_E121            -121    /* dup column name                     */
#define SQL_RC_E122            -122    /* no group by                         */
#define SQL_RC_NOTCONST        -123    /* parameter must be constant          */
#define SQL_RC_E125            -125    /* no result column                    */
#define SQL_RC_E127            -127    /* dup distinct                        */
#define SQL_RC_E129            -129    /* too many table names                */
#define SQL_RC_INVESC          -130    /* invalid escape character            */
#define SQL_RC_E131            -131    /* incompatible data for like          */
#define SQL_RC_E132            -132    /* like predicate invalid              */
#define SQL_RC_E134            -134    /* improper use of long string         */
#define SQL_RC_E137            -137    /* length of concat too long           */
#define SQL_RC_E138            -138    /* substr arg out of range             */
#define SQL_RC_E142            -142    /* syntax not supported                */
#define SQL_RC_E146            -146    /* unsupported ANSI syntax             */
#define SQL_RC_E150            -150    /* view not updatable                  */
#define SQL_RC_E151            -151    /* column not updatable                */
#define SQL_RC_E153            -153    /* no column list                      */
#define SQL_RC_E155            -155    /* trigger trans tbl not modifiable    */
#define SQL_RC_E156            -156    /* command not allowed on view         */
#define SQL_RC_E157            -157    /* view name in foreign key            */
#define SQL_RC_E158            -158    /* nbr of columns does not match       */
#define SQL_RC_E159            -159    /* drop view on table                  */
#define SQL_RC_E160            -160    /* with check not allowed on view      */
#define SQL_RC_E161            -161    /* with check violation                */
#define SQL_RC_E170            -170    /* nbr of arguments invalid            */
#define SQL_RC_E171            -171    /* argument invalid                    */
#define SQL_RC_E172            -172    /* function name invalid               */
#define SQL_RC_E176            -176    /* translate scalar argument invalid   */
#define SQL_RC_E180            -180    /* datetime syntax invalid             */
#define SQL_RC_E181            -181    /* datetime value invalid              */
#define SQL_RC_E182            -182    /* datetime arithmetic invalid         */
#define SQL_RC_E183            -183    /* datetime arithmetic out of range    */
#define SQL_RC_DTMEREG         -187    /* datetime register is invalid        */
#define SQL_RC_DBCSTRUNC       -191    /* truncated DBCS character found      */
#define SQL_RC_E193            -193    /* NOT NULL needs DEFAULT              */
#define SQL_RC_E197            -197    /* no qualified columns in ORDER BY    */
#define SQL_RC_E198            -198    /* no statement text                   */
#define SQL_RC_E199            -199    /* illegal use of reserved word        */

#define SQL_RC_E203            -203    /* ambiguous column reference          */
#define SQL_RC_E204            -204    /* undefined name                      */
#define SQL_RC_E205            -205    /* not a column                        */
#define SQL_RC_E206            -206    /* not a column of referenced tables   */
#define SQL_RC_E207            -207    /* cannot orderby column name w/union  */
#define SQL_RC_E208            -208    /* column not part of result table     */
#define SQL_RC_E212            -212    /* duplicate table designator          */
#define SQL_RC_E219            -219    /* required explain table not exist    */
#define SQL_RC_E214            -214    /* bad expression in group/by or       */
                                       /* order by                            */
#define SQL_RC_E220            -220    /* explain table has improper def      */
#define SQL_RC_E257            -257    /* raw device containers not allowed   */
#define SQL_RC_E258            -258    /* cannot add container to pool        */
#define SQL_RC_E259            -259    /* container map too big               */
#define SQL_RC_E281            -281    /* cannot add containers to            */
                                       /* tablespace                          */
#define SQL_RC_E282            -282    /* cannot drop tblspace, tbl conflict  */
#define SQL_RC_E283            -283    /* cannot drop only temp tablespace    */
#define SQL_RC_E284            -284    /* invalid tablespace type for clause  */
#define SQL_RC_E285            -285    /* all table parts must be in tblspce  */
#define SQL_RC_E286            -286    /* need default tblspce for new        */
                                       /* tables                              */
#define SQL_RC_E287            -287    /* SYSCATSPACE not for user objects    */
#define SQL_RC_E288            -288    /* long tablespace cannot use system   */
#define SQL_RC_E289            -289    /* cannot allocate new pages in        */
                                       /* tablespace                          */
#define SQL_RC_E290            -290    /* access to tablespace not allowed    */
#define SQL_RC_E291            -291    /* invalid state transition            */
#define SQL_RC_E292            -292    /* cannot create internal db file      */
#define SQL_RC_E293            -293    /* error accessing container           */
#define SQL_RC_E294            -294    /* container already in use            */
#define SQL_RC_E295            -295    /* container names too long            */
#define SQL_RC_E296            -296    /* tablespace limit exceeded           */
#define SQL_RC_E297            -297    /* container pathname too long         */
#define SQL_RC_E298            -298    /* bad container pathname              */
#define SQL_RC_E299            -299    /* container already added             */

#define SQL_RC_E301            -301    /* host variable has invalid type      */
#define SQL_RC_E302            -302    /* host variable value too large       */
#define SQL_RC_E303            -303    /* data types not comparable           */
#define SQL_RC_E304            -304    /* value not in range of host var      */
#define SQL_RC_E305            -305    /* host var cannot be null             */
#define SQL_RC_E308            -308    /* host var limit reached              */
#define SQL_RC_E309            -309    /* host var should not be null         */
#define SQL_RC_E311            -311    /* length of host var is negative      */
#define SQL_RC_E312            -312    /* unusable host variable              */
#define SQL_RC_E313            -313    /* wrong nbr of host variables         */
#define SQL_RC_E332            -332    /* no conversn source-cp to target-cp  */
#define SQL_RC_E334            -334    /* converion overflow                  */
#define SQL_RC_E340            -340    /* duplicate common table expression   */
#define SQL_RC_E341            -341    /* cyclic ref between comm tbl exp     */
#define SQL_RC_E342            -342    /* comm tbl exp use UNION ALL          */
#define SQL_RC_E343            -343    /* col names required                  */
#define SQL_RC_E344            -344    /* columns must match exactly          */
#define SQL_RC_E345            -345    /* cannot use GROUP BY or HAVING here  */
#define SQL_RC_E346            -346    /* invalid reference to comm tbl exp   */
#define SQL_RC_E350            -350    /* LOB col cannot be idx, key, constr  */
#define SQL_RC_E351            -351    /* LOB col cannot be selected by DRDA  */
#define SQL_RC_E352            -352    /* LOB col cannot be inserted by DRDA  */
#define SQL_RC_E355            -355    /* LOB col cannot be logged            */

#define SQL_RC_E401            -401    /* operands not comparable             */
#define SQL_RC_E402            -402    /* invalid type for arithmetic op      */
#define SQL_RC_E403            -403    /* alias object undefined              */
#define SQL_RC_E404            -404    /* update/insert string too long       */
#define SQL_RC_E405            -405    /* numeric literal out of range        */
#define SQL_RC_E406            -406    /* derived value out of range          */
#define SQL_RC_E407            -407    /* column cannot be null               */
#define SQL_RC_E408            -408    /* invalid data type for column        */
#define SQL_RC_E409            -409    /* invalid operand for count           */
#define SQL_RC_E410            -410    /* float literal too long              */
#define SQL_RC_E412            -412    /* multiple columns in subquery        */
#define SQL_RC_E413            -413    /* overflow during data conversion     */
#define SQL_RC_E415            -415    /* incompatible data types for union   */
#define SQL_RC_E416            -416    /* long string in union                */
#define SQL_RC_E417            -417    /* invalid use of parameter markers    */
#define SQL_RC_E418            -418    /* parameter marker in select clause   */
#define SQL_RC_E419            -419    /* division produced negative scale    */
#define SQL_RC_E420            -420    /* invalid character in input string   */
#define SQL_RC_E421            -421    /* diff number of columns for union    */
#define SQL_RC_E423            -423    /* Invalid handle                      */
#define SQL_RC_E426            -426    /* dynamic COMMIT not valid            */
#define SQL_RC_E427            -427    /* dynamic ROLLBACK not valid          */
#define SQL_RC_E428            -428    /* DISCONNECT in unit of work          */
                                       /* notallow                            */
#define SQL_RC_E429            -429    /* Handle table full                   */
#define SQL_RC_E430            -430    /* UDF abnormal end                    */
#define SQL_RC_E431            -431    /* UDF interrupted                     */
#define SQL_RC_E432            -432    /* Parameter marker cannot have udf    */
                                       /* nm                                  */
#define SQL_RC_E433            -433    /* Value is too long                   */
#define SQL_RC_E435            -435    /* Inv SQLSTATE in RAISE_ERROR         */
#define SQL_RC_E436            -436    /* C language char string missing NUL  */
#define SQL_RC_E438            -438    /* App raised error                    */
#define SQL_RC_E439            -439    /* Error in UDF                        */
#define SQL_RC_E440            -440    /* No function with compatible arg     */
#define SQL_RC_E441            -441    /* Invalid use of DISTINCT with        */
                                       /* scalar                              */
#define SQL_RC_E442            -442    /* Error refering function in DML      */
#define SQL_RC_E443            -443    /* UDF returns error sqlstate          */
#define SQL_RC_E444            -444    /* Unable to access UDF function       */
#define SQL_RC_E448            -448    /* Exceed max number of parameters     */
#define SQL_RC_E449            -449    /* Invalid EXTERNAL NAME format        */
#define SQL_RC_E450            -450    /* UDF generates too long result       */
                                       /* value                               */
#define SQL_RC_E451            -451    /* DDL: invalid type for external UDF  */
#define SQL_RC_E452            -452    /* Hostvar file inaccessible           */
#define SQL_RC_E453            -453    /* Error in RETURNS and CAST FROM      */
#define SQL_RC_E454            -454    /* Duplicate UDF name and signature    */
#define SQL_RC_E455            -455    /* Diff schema for UDF name &          */
                                       /* specific                            */
#define SQL_RC_E456            -456    /* Duplicate specific name             */
#define SQL_RC_E457            -457    /* Name reserved for system use        */
#define SQL_RC_E458            -458    /* DDL refers UDF signature not found  */
#define SQL_RC_E459            -459    /* AS CAST use error                   */
#define SQL_RC_E461            -461    /* invalid CAST                        */
#define SQL_RC_E463            -463    /* UDF returns an invalid sqlstate     */
#define SQL_RC_E465            -465    /* Unable to start fenced UDF          */
#define SQL_RC_E473            -473    /* reserved object name                */
#define SQL_RC_E475            -475    /* Result type of source is different  */
#define SQL_RC_E476            -476    /* Reference to function is not        */
                                       /* unique                              */
#define SQL_RC_E478            -478    /* other obj depends on this obj       */
#define SQL_RC_E483            -483    /* Parm num not match with source      */
#define SQL_RC_E486            -486    /* Boolean type is system used only    */
#define SQL_RC_E487            -487    /* Attempt to excute an SQL statement  */
#define SQL_RC_E489            -489    /* Inv BOOLEAN in select list result   */
#define SQL_RC_E491            -491    /* DDL: missing reqired clause         */
#define SQL_RC_E492            -492    /* DDL: miss match with source type    */
#define SQL_RC_E493            -493    /* UDF returned bad date/time value    */

#define SQL_RC_E501            -501    /* cursor not open (fetch/close)       */
#define SQL_RC_E502            -502    /* cursor already open                 */
#define SQL_RC_E503            -503    /* column not in update clause         */
#define SQL_RC_E504            -504    /* cursor name not defined             */
#define SQL_RC_E507            -507    /* cursor not open (update/delete)     */
#define SQL_RC_E508            -508    /* cursor not on a row                 */
#define SQL_RC_E509            -509    /* table not same as for cursor        */
#define SQL_RC_E510            -510    /* table cannot be modified            */
#define SQL_RC_E511            -511    /* for update not allowed              */
#define SQL_RC_E514            -514    /* cursor not prepared                 */
#define SQL_RC_E516            -516    /* describe not a prepared statement   */
#define SQL_RC_E517            -517    /* prepared statment not a select      */
#define SQL_RC_E518            -518    /* execute not a prepared statement    */
#define SQL_RC_E519            -519    /* statement has an open cursor        */
#define SQL_RC_E530            -530    /* invalid foreign key value           */
#define SQL_RC_E531            -531    /* cannot update primary key           */
#define SQL_RC_E532            -532    /* delete is restricted                */
#define SQL_RC_E533            -533    /* multi-row insert not allowed        */
#define SQL_RC_E534            -534    /* multi-row update of pk              */
#define SQL_RC_E535            -535    /* multi-row delete not allowed        */
#define SQL_RC_E536            -536    /* descendent in subquery              */
#define SQL_RC_E537            -537    /* dup column in key def               */
#define SQL_RC_E538            -538    /* foreign key does not match pk       */
#define SQL_RC_E539            -539    /* table does not have primary key     */
#define SQL_RC_E541            -541    /* duplicate referential constraint    */
#define SQL_RC_E542            -542    /* pk column cannot allow nulls        */
#define SQL_RC_E543            -543    /* restricted row delete               */
#define SQL_RC_E544            -544    /* check contraint violated            */
#define SQL_RC_E545            -545    /* check contraint not satisfied       */
#define SQL_RC_E546            -546    /* check contraint invalid             */
#define SQL_RC_E548            -548    /* check contraint invalid             */
#define SQL_RC_E551            -551    /* authorization error w/obj insert    */
#define SQL_RC_E552            -552    /* auth error w/o obj ins              */
#define SQL_RC_E553            -553    /* SYSIBM qualifier                    */
#define SQL_RC_E554            -554    /* cannot grant privilege to self      */
#define SQL_RC_E555            -555    /* cannot revoke privilege from self   */
#define SQL_RC_E556            -556    /* revoke stmt denied--priv not held   */
#define SQL_RC_E557            -557    /* invalid combination of privileges   */
#define SQL_RC_E558            -558    /* revoke stmt denied--has CONTROL     */
#define SQL_RC_E562            -562    /* privilege not allowed for public    */
#define SQL_RC_E567            -567    /* invalid authorization id            */
#define SQL_RC_E569            -569    /* user/group ambiguity                */
#define SQL_RC_E572            -572    /* Inoperative package                 */
#define SQL_RC_E573            -573    /* contraint col not primary key       */
#define SQL_RC_E574            -574    /* DEFAULT invalid for column          */
#define SQL_RC_E575            -575    /* view is inoperative                 */
#define SQL_RC_E576            -576    /* Repetitive alias chain              */
#define SQL_RC_E580            -580    /* Result of CASE expr cannot be NULL  */
#define SQL_RC_E581            -581    /* Data types of CASE expr incompat    */
#define SQL_RC_E582            -582    /* Inv predicate in CASE expr          */
#define SQL_RC_E583            -583    /* Variant or ext action function      */
#define SQL_RC_E584            -584    /* Inv use of NULL or DEFAULT          */
#define SQL_RC_E585            -585    /* Duplicate schema name               */
#define SQL_RC_E586            -586    /* Too many schema names               */
#define SQL_RC_E600            -600    /* udf - dup func signature            */
#define SQL_RC_E601            -601    /* duplicate table/view name           */
#define SQL_RC_E602            -602    /* too many columns in index           */
#define SQL_RC_E603            -603    /* cannot create unique index          */
#define SQL_RC_E604            -604    /* invalid length, precision, scale    */
#define SQL_RC_E607            -607    /* op not allowed on system tables     */
#define SQL_RC_E612            -612    /* duplicate column name               */
#define SQL_RC_E613            -613    /* primary key too long                */
#define SQL_RC_E614            -614    /* index key too long                  */
#define SQL_RC_E624            -624    /* table already has primary key       */
#define SQL_RC_E628            -628    /* DDL: multiple/conflict keywords     */
#define SQL_RC_E629            -629    /* foreign key is not nullable         */
#define SQL_RC_E631            -631    /* foreign key is too long             */
#define SQL_RC_E632            -632    /* delete rule restriction             */
#define SQL_RC_E633            -633    /* delete rule is restricted           */
#define SQL_RC_E634            -634    /* delete rule cannot be CASCADE       */
#define SQL_RC_E637            -637    /* dup pk or drop pk clause            */
#define SQL_RC_E638            -638    /* no column definitions               */
#define SQL_RC_E644            -644    /* invalid keyword value               */
#define SQL_RC_E659            -659    /* architectural size limit of object  */
#define SQL_RC_E667            -667    /* ref constraint does not hold        */
#define SQL_RC_E668            -668    /* table in CHECK PENDING state        */
#define SQL_RC_E669            -669    /* cannot drop primary key             */
#define SQL_RC_E670            -670    /* row length too large                */
#define SQL_RC_E673            -673    /* primary key not unique              */
#define SQL_RC_E680            -680    /* too many columns for table          */
#define SQL_RC_E683            -683    /* incompatible column constraint      */
#define SQL_RC_E696            -696    /* invalid trigger definition          */
#define SQL_RC_E697            -697    /* invalid correlation name use        */

#define SQL_RC_E707            -707    /* object uses reserved name           */
#define SQL_RC_INV_REPL        -713    /* invalid replace value for sp reg    */
#define SQL_RC_E723            -723    /* trigger error                       */
#define SQL_RC_E724            -724    /* max level of cascading              */
#define SQL_RC_E751            -751    /* Invalid triggered statement         */
#define SQL_RC_E752            -752    /* Inoperative package                 */

#define SQL_RC_E801            -801    /* divide by zero                      */
#define SQL_RC_E802            -802    /* arith overflow or divide by zero    */
#define SQL_RC_E803            -803    /* distinct violation                  */
#define SQL_RC_E804            -804    /* bad input parameters                */
#define SQL_RC_E805            -805    /* program not bound                   */
#define SQL_RC_E808            -808    /* inconsistent connect semantics      */
#define SQL_RC_E811            -811    /* more than one row/value             */
#define SQL_RC_E818            -818    /* time stamp conflict                 */
#define SQL_RC_E822            -822    /* invalid address in sqlda            */
#define SQL_RC_E840            -840    /* too many items in list              */
#define SQL_RC_E842            -842    /* connection already exists           */
#define SQL_RC_E843            -843    /* connection does not exist           */
#define SQL_RC_E847            -847    /* can't change connection settings    */
#define SQL_RC_E859            -859    /* TM not for 2 phase commit apps      */
#define SQL_RC_E865            -865    /* inv TM_DATABASE value               */
#define SQL_RC_E866            -866    /* connect redirect failed             */
#define SQL_RC_E868            -868    /* connection already exists           */

#define SQL_RC_E901            -901    /* non-fatal system error              */
#define SQL_RC_E902            -902    /* fatal error                         */
#define SQL_RC_E903            -903    /* commit failed, rollback             */
#define SQL_RC_E904            -904    /* lock timeout                        */
#define SQL_RC_E910            -910    /* drop pending                        */
#define SQL_RC_E911            -911    /* deadlock                            */
#define SQL_RC_E912            -912    /* too many lock requests              */
#define SQL_RC_E913            -913    /* dist env rollback                   */
#define SQL_RC_E918            -918    /* ROLLBACK required                   */
#define SQL_RC_E920            -920    /* reject DB connection to SA REQ      */
#define SQL_RC_E925            -925    /* COMMIT not allowed                  */
#define SQL_RC_E926            -926    /* ROLLBACK not allowed                */
#define SQL_RC_E930            -930    /* insufficient storage                */
#define SQL_RC_INODE           -931    /* all inodes used, system limit       */
#define SQL_RC_E950            -950    /* cursors active on dropped object    */
#define SQL_RC_E951            -951    /* table in use - alter disallowed     */
#define SQL_RC_E952            -952    /* user cancel                         */
#define SQL_RC_E953            -953    /* agent heap too small                */
#define SQL_RC_E954            -954    /* application heap too small          */
#define SQL_RC_E955            -955    /* sort heap error                     */
#define SQL_RC_E956            -956    /* database heap too small             */
#define SQL_RC_E957            -957    /* requestor comm heap too small       */
#define SQL_RC_E958            -958    /* max number of files open            */
#define SQL_RC_E959            -959    /* server comm heap too small          */
#define SQL_RC_E960            -960    /* max nbr of files in database        */
#define SQL_RC_E961            -961    /* rqstr remote svcs heap too small    */
#define SQL_RC_E962            -962    /* svr remote svcs heap too small      */
#define SQL_RC_E964            -964    /* log file full                       */
#define SQL_RC_E966            -966    /* error opening sqlcode mapping file  */
#define SQL_RC_E967            -967    /* format error in sqlcode map file    */
#define SQL_RC_E968            -968    /* disk full                           */
#define SQL_RC_E969            -969    /* unknown sql error another product   */
#define SQL_RC_E970            -970    /* read-only file                      */

#define SQL_RC_E972_DB2AIX     -10019  /* incorrect diskette                  */
#define SQL_RC_E972_DB2OS2     -972    /* incorrect diskette                  */
#define SQL_RC_E972            SQL_RC_E972_DB2AIX /* incorrect diskette       */

#define SQL_RC_E973            -973    /* out of memory error                 */

#define SQL_RC_E974_DB2AIX     -10019  /* drive locked                        */
#define SQL_RC_E974_DB2OS2     -974    /* drive locked                        */
#define SQL_RC_E974            SQL_RC_E974_DB2AIX /* drive locked             */

#define SQL_RC_QBACK           -975    /* quiesce backup                      */

#define SQL_RC_E976_DB2AIX     -10019  /* diskette door open                  */
#define SQL_RC_E976_DB2OS2     -976    /* diskette door open                  */
#define SQL_RC_E976            SQL_RC_E976_DB2AIX /* diskette door open       */

#define SQL_RC_E977            -977    /* unknown commit state                */
#define SQL_RC_E978_DB2AIX     -10019  /* diskette write-protected            */
#define SQL_RC_E978_DB2OS2     -978    /* diskette write-protected            */
#define SQL_RC_E978            SQL_RC_E978_DB2AIX /* diskette write           */
                                       /* protected                           */

#define SQL_RC_E979            -979    /* commit failed with SYNCPOINT NONE   */
#define SQL_RC_E980            -980    /* disk error                          */
#define SQL_RC_E982            -982    /* disk error on temp file             */
#define SQL_RC_E984            -984    /* unsuccessful commit or rollback     */
#define SQL_RC_E985            -985    /* file error - catalog file bad       */
#define SQL_RC_E986            -986    /* file error - file renamed           */
#define SQL_RC_E988            -988    /* app ctl heap out of memory          */
#define SQL_RC_E990            -990    /* index structure limit error         */
#define SQL_RC_E992            -992    /* release number incompatible         */
#define SQL_RC_E994            -994    /* reserved                            */
#define SQL_RC_E996            -996    /* error freeing pages in DMS          */
                                       /* tablespace                          */
#define SQL_RC_E998            -998    /* General XA error                    */

#define SQL_RC_E1007           -1007   /* error finding pages in DMS          */
                                       /* tablespace                          */
#define SQL_RC_E1008           -1008   /* invalid tablespace id               */

#define SQL_RC_E1216           -1216   /* invalid use of graphic data         */
#define SQL_RC_E1219           -1219   /* out of private memory               */
#define SQL_RC_E1227           -1227   /* Updatale cat values inv             */
#define SQL_RC_E1229           -1229   /* System error rollback               */
#define SQL_RC_W1244           1244    /* Disconn at next commit              */
#define SQL_RC_E1245           -1245   /* Max client connects                 */
#define SQL_RC_E1247           -1247   /* XA TM uses syncpoint 2              */
#define SQL_RC_E1248           -1248   /* db not defined with TM              */
#define SQL_RC_E1290           -1290   /* DB2CLIENTCOMM env var inv           */
#define SQL_RC_E1291           -1291   /* direcory services error             */
#define SQL_RC_E1293           -1293   /* global dir error                    */
#define SQL_RC_E1294           -1294   /* global dir path invalid             */
#define SQL_RC_E1295           -1295   /* global dir router invalid           */

#define SQL_RC_E1339           -1339   /* Not Atomic Compound SQL error(s)    */

#define SQL_RC_E1419           -1419   /* package not executable              */
#define SQL_RC_E1420           -1420   /* too many concat operators           */
#define SQL_RC_E1421           -1421   /* MBCS conversion error               */
#define SQL_RC_E1422           -1422   /* Container wrong size                */
#define SQL_RC_E1423           -1423   /* no blobs for dwn lvl cl             */
#define SQL_RC_E1424           -1424   /* too many transition tbles           */

#define SQL_RC_E1590           -1590   /* LONG not allowed on devices         */
#define SQL_RC_E3600           -3600   /* Table not in check pend state       */
#define SQL_RC_W3601           3601    /* Auto Check pending state            */
#define SQL_RC_W3602           3602    /* Constraint violation moved          */
#define SQL_RC_E3603           -3603   /* Constraint Violations               */
#define SQL_RC_E3604           -3604   /* Invalid Exception Table             */
#define SQL_RC_E3605           -3605   /* Exception Table same as Check       */
                                       /* Table                               */
#define SQL_RC_E3606           -3606   /* # check & exception tables not      */
                                       /* match                               */
#define SQL_RC_E3608           -3608   /* Parent in Check Pending state       */

#define SQL_RC_E8100           -8100   /* Page number too high                */
#define SQL_RC_E8101           -8101   /* Segment in error                    */

#define SQL_RC_E30000          -30000  /* Distribution protocol error, no     */
                                       /* disconnect                          */
#define SQL_RC_E30020          -30020  /* Distribution protocol error,        */
                                       /* disconnect                          */
#define SQL_RC_E30021          -30021  /* Distribution compatibility error    */
#define SQL_RC_E30040          -30040  /* Distribution memory allocation err  */
#define SQL_RC_E30041          -30041  /* Distribution memory allocation      */
                                       /* err, disconnect                     */
#define SQL_RC_E30050          -30050  /* Invalid command while bind in prog  */
#define SQL_RC_E30051          -30051  /* Bind not active                     */
#define SQL_RC_E30053          -30053  /* Bind Owner authorization failure    */
#define SQL_RC_E30060          -30060  /* RDB authorization failure           */
#define SQL_RC_E30061          -30061  /* RDB not found                       */
#define SQL_RC_E30070          -30070  /* Distribution command error          */
#define SQL_RC_E30071          -30071  /* Distribution object error           */
#define SQL_RC_E30072          -30072  /* Distribution parameter error        */
#define SQL_RC_E30073          -30073  /* Distribution parameter value error  */
#define SQL_RC_E30074          -30074  /* Distribution reply error            */
#define SQL_RC_E30080          -30080  /* Communication error                 */
#define SQL_RC_E30081          -30081  /* Communication error                 */
#define SQL_RC_E30082          -30082  /* Security error                      */
#define SQL_RC_E30090          -30090  /* Remote operation invalid            */
#define SQL_RC_W30101          30101   /* Rebind options ignored              */
#define SQL_RC_W30102          30102   /* Connection disabled                 */

/* Database Monitor SQLCODES                                                  */

#define SQLM_RC_BAD_PATH       -1612   /* bad path specified for event        */
                                       /* monitor                             */
#define SQLM_RC_BAD_OPTION     -1613   /* bad OPTION specified for event      */
                                       /* monitor                             */
#define SQLM_RC_IO_ERROR       -1614   /* I/O error on activating event       */
                                       /* monitor                             */
#define SQLM_RC_NOT_ACTIVATED  -1616   /* Event monitor not activated         */
#define SQLM_RC_EVMON_FULL     -1617   /* Event monitor data files are full   */
#define SQLM_RC_PATH_IN_USE    -1618   /* Event monitor path is in use        */
#define SQLM_RC_CANNOT_DROP    -1619   /* Cannot drop active event monitor    */
#define SQLM_RC_MUST_COMMIT    -1621   /* Must commit to use event monitor    */
#define SQLM_RC_BAD_STATE      -1622   /* Invalid state                       */

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLCODES */
590    k.M b  $        $t R1R1ZU1           $t     ./usr/lpp/db2_02_01/include/sqlenv.h h .                    $          /******************************************************************************
** 
** Source File Name: SQLENV
** 
** (C) COPYRIGHT International Business Machines Corp. 1987, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function = Include File defining:
**              Environment Commands - Constants
**              Environment Commands - Structures
**              Environment Commands - Function Prototypes
**              Environment Commands - Labels for SQLCODES
** 
** Operating System:AIX
** 
*******************************************************************************/
#ifndef SQL_H_SQLENV
#define SQL_H_SQLENV

#ifdef __cplusplus
extern "C" {
#endif

/* Note: _SQLOLDCHAR defaults to 'char'.  See sqlsystm.h for details.         */

#include "sqlsystm.h"                  /* System dependent defines  */

/* Required Include Files */

#include "sql.h"                       /* Includes sqlsystm & sqlca */
#include "sqlda.h"
#include <stddef.h>                    /* needed for offsetof */

#pragma options align=power

/* Interface Parameters/Structures/Return Codes                               */

/* Parameters for START USING DATABASE                                        */
#define SQL_USE_SHR            'S'     /* USE = Share                         */
#define SQL_USE_EXC            'X'     /* USE = Exclusive                     */

/* Sizes for entries in sqledinfo, sqleninfo, sqledbstat, sqleusrstat, sql    */
/* dir_entry, sqle_reg_nwbindery                                              */
#define SQL_ALIAS_SZ           8       /* Alias name                          */
#define SQL_USERID_SZ          8       /* User Id                             */
#define SQL_DBNAME_SZ          8       /* Database name                       */

#define SQL_DRIVE_SZ_DB2OS2    2       /* Drive (Qualified) - OS/2            */
#define SQL_DRIVE_SZ_DB2DOS    2       /* Drive (Qualified) - Windows         */
#define SQL_DRIVE_SZ_DB2WINT   12      /* Drive (Qualified) - NT              */
#define SQL_DRIVE_SZ_DB2AIX    215     /* Path (Qualified) - AIX/UNIX         */
#define SQL_DRIVE_SZ           SQL_DRIVE_SZ_DB2AIX

#define SQL_INAME_SZ           8       /* Internal db name                    */
#define SQL_NNAME_SZ           8       /* Node name                           */
#define SQL_INSTNAME_SZ        8       /* Instance Name                       */
#define SQL_DBTYP_SZ           20      /* Type of database                    */
#define SQL_CMT_SZ             30      /* Comment                             */
#define SQL_LOCLU_SZ           8       /* Local_lu                            */
#define SQL_RMTLU_SZ           8       /* Partner_lu                          */
#define SQL_MODE_SZ            8       /* Mode                                */
#define SQL_NRESERVE_SZ        0       /* Reserved                            */
#define SQL_DBSTAT_ALIAS_SZ    16      /* Alias name                          */
#define SQL_DBSTAT_DBNAME_SZ   16      /* Database name                       */
#define SQL_LONG_NAME_SZ       18      /* Host database name                  */
#define SQL_CS_SZ              256     /* collating sequence                  */
#define SQL_PARAMETER_SZ       512     /* Parameter string                    */
#define SQL_NETID_SZ           8       /* Network ID                          */
#define SQL_PATH_SZ            1024    /* Maximum Path size                   */
#define SQL_HOSTNAME_SZ        255     /* Host Name                           */
#define SQL_SERVICE_NAME_SZ    14      /* Service Name                        */
#define SQL_TPMON_NAME_SZ      19      /* TP Monitor Name                     */
#define SQL_SYM_DEST_NAME_SZ   8       /* Symbolic Destination Name           */
#define SQL_TMDATABASE_NAME_SZ 8       /* TM Database Name                    */
#define SQL_AR_SZ              32      /* AR Library Name                     */

#define SQL_DFTDRDAACT_SZ      25      /* Default DRDA accounting string.     */
#define SQL_DCEPRINCPL_SZ      256     /* DCE Principal name                  */
#define SQL_DIR_NAME_SZ        255     /* Dir/Route Path/Obj Name             */
#define SQL_CLIENT_COMM_SZ     31      /* Client Comm. Protocol               */
#define SQL_SYSADM_SZ          16      /* Sysadm Group name                   */
#define SQL_FILESERVER_SZ      48      /* Netware fileserver name             */
#define SQL_OBJECTNAME_SZ      48      /* Netware bindery name                */
#define SQL_IPXSOCKET_SZ       4       /* Netware IPX socket                  */
#define SQL_NW_UID_SZ          48      /* Netware userid                      */
#define SQL_NW_PSWD_SZ         128     /* Netware password                    */
#define SQL_COLLATE_INFO_SZ    260     /* Collate info size (256 + 4)         */
#define SQL_ACCOUNT_STR_SZ     199     /* Max accounting string               */

/* After an SQL CONNECT, the 5th token in the SQLCA identifies the DBMS an    */
/* application has connected to.  The following are values returned from IBM  */
/* DBMS.                                                                      */
#define SQL_DBMS_ES10_OS2      "QOS/2 DBM"
#define SQL_DBMS_DB2_OS2       "QDB2/2"
#define SQL_DBMS_DB2_NT        "QDB2/NT"
#define SQL_DBMS_DB2_95        "QDB2/Windows 95"
#define SQL_DBMS_DB2_AIX       "QDB2/6000"
#define SQL_DBMS_DB2_AIX_PE    "QDB2/6000 PE"
#define SQL_DBMS_DB2_HPUX      "QDB2/HPUX"
#define SQL_DBMS_DB2_SUN       "QDB2/SUN"
#define SQL_DBMS_DB2_SNI       "QDB2/SNI"
#define SQL_DBMS_DB2_MVS       "QDB2"
#define SQL_DBMS_OS400         "QAS"
#define SQL_DBMS_SQLDS_VM      "QSQLDS/VM"
#define SQL_DBMS_SQLDS_VSE     "QSQLDS/VSE"
#define SQL_DBMS_LU62_SPM      "QLU62SPM"

/* Parameters for Entry Type in sqledinfo                                     */
#define SQL_DCE                '3'     /* Database is DCE                     */
#define SQL_HOME               '2'     /* Database is Home                    */
#define SQL_REMOTE             '1'     /* Database is Remote                  */
#define SQL_INDIRECT           '0'     /* Database is Indirect                */

/* Parameters for adapter number in sqlectnd                                  */
#define SQL_ADAPTER_0          0       /* Adapter number 0                    */
#define SQL_ADAPTER_1          1       /* Adapter number 1                    */
#define SQL_ADAPTER_MIN        0       /* Minimum adapter number              */
#define SQL_ADAPTER_MAX        15      /* Maximum adapter number              */

/* Definitions of constants used for Structure IDs                            */
#define SQL_DCS_STR_ID         0x100   /* DCS directory entry id              */
#define SQL_NODE_STR_ID        0x100   /* Catalog node struct id              */

/* Parameters for protocol types in sqlectnd                                  */
#define SQL_PROTOCOL_APPC      0x0     /* APPC                                */
#define SQL_PROTOCOL_NETB      0x1     /* NETBIOS                             */
#define SQL_PROTOCOL_APPN      0x2     /* APPN                                */
#define SQL_PROTOCOL_TCPIP     0x3     /* TCPIP                               */
#define SQL_PROTOCOL_CPIC      0x4     /* APPC using CPIC                     */
#define SQL_PROTOCOL_IPXSPX    0x5     /* IPX/SPX                             */
#define SQL_PROTOCOL_LOCAL     0x6     /* Local IPC                           */
#define SQL_PROTOCOL_NPIPE     0x7     /* Named Pipe                          */

/* Security Type for APPC using CPIC                                          */
#define SQL_CPIC_SECURITY_NONE         0    /* None                           */
#define SQL_CPIC_SECURITY_SAME         1    /* Same                           */
#define SQL_CPIC_SECURITY_PROGRAM      2    /* Program                        */

/* Authentication Types                                                       */
#define SQL_AUTHENTICATION_SERVER      0    /* Authenticate on Server         */
#define SQL_AUTHENTICATION_CLIENT      1    /* Authenticate on Client         */
#define SQL_AUTHENTICATION_DCS         2    /* Authenticate via DDCS          */
#define SQL_AUTHENTICATION_NOT_SPEC    255  /* Authentication Not Specified   */

/* Parameters for Create Database API Collating Sequences                     */
#define SQL_CS_SYSTEM          0       /* Coll. Seq. from System              */
#define SQL_CS_USER            -1      /* Coll. Seq. from User                */
#define SQL_CS_NONE            -2      /* Coll. Seq. (None)                   */

/* Parameters for indicating the stored procedure invocation was via the      */
/* CALL statement                                                             */
#define SQL_CALLPROC           "$SQL$CAL"

/* Default values for Segmented Tables parameters                             */
#define SQL_DEF_NUMSEGS        1       /* Default number of segments-nonOS2   */
#define SQL_DEF_SEGPAGES       76800   /* OBSOLETE: Default max pages per     */
                                       /* seg                                 */
#define SQL_DEF_EXTSIZE        32      /* default extent size                 */

/* DUOW Connection Setting types used by sqleqryc() and                       */
/* sqlesetc().Associated values are in sql.h, used in common with the         */
/* precompiler.                                                               */
#define SQL_CONNECT_TYPE       1       /* Connect type                        */
#define SQL_RULES              2       /* Rules for changing connections      */
#define SQL_DISCONNECT         3       /* Disconnect type at syncpoint        */
#define SQL_SYNCPOINT          4       /* Syncpoint type                      */
#define SQL_MAX_NETBIOS_CONNECTIONS 5  /* Maximum concurrent connections      */

/* A structure to identify an SQL statement.  The eyecatcher $SQL$CALL        */
/* identifies this as an EXEC SQL CALL statement.                             */
SQL_STRUCTURE SQLSTMTID
{
        char                   sqlcstid[8]; /* eye catcher                    */
        char                   sqluser[8]; /* creator id                      */
        char                   pkgname[8]; /* package name                    */
        char                   contoken[8]; /* consistency token              */
        short                  sectnum; /* reserved                           */
        char                   wchar_info; /* reserved                        */
        char                   fCacheRows; /* reserved                        */
        char                   buffer[38]; /* reserved                        */
};


/******************************************************************************
** Database Description Block structure
*******************************************************************************/
/* TableSpace types                                                           */
#define SQL_TBS_TYP_SMS        'S'
#define SQL_TBS_TYP_DMS        'D'

/* TableSpace container types                                                 */
#define SQL_TBSC_TYP_PATH      'P'     /* path (directory)  SMS only          */
#define SQL_TBSC_TYP_DEV       'D'     /* device (raw disk) DMS only          */
#define SQL_TBSC_TYP_FILE      'F'     /* file (cooked file) DMS only         */

#define SQLE_DBDESC_2          "SQLDBD02" /* version 2 database descriptor    */
#define SQLE_DBTSDESC_1        "SQLTS001" /* version 2 tableSpace descriptor  */

/* Initial TableSpace names                                                   */
#define SQLCATTS_NAME          "SYSCATSPACE" /* system catalogs               */
#define SQLUSRTS_NAME          "USERSPACE1" /* user tables                    */
#define SQLTMPTS_NAME          "TEMPSPACE1" /* temp tables                    */

/* tableSpace container descriptor                                            */
SQL_STRUCTURE SQLETSCDESC
{
        char           sqlctype;                     /* container type        */
        char           pad1[3];                      /* reserved              */
        long           sqlcsize;                     /* container size (4K    */
                                                     /* pages)                */
        short          sqlclen;                      /* length of container   */
                                                     /* name                  */
        char           sqlcontr[SQLB_MAX_CONTAIN_NAME_SZ]; /* container name  */
                                                     /* (includes 1 byte for  */
                                                     /* C NULL terminator)    */
        char           pad2[2];                      /* 2 bytes padding       */
                                                     /* before next           */
                                                     /* container             */
};


/* tableSpace descriptor                                                      */
SQL_STRUCTURE SQLETSDESC
{
        char           sqltsdid[8];                  /* eyecatcher            */
                                                     /* descriptor version    */
        long           sqlextnt;                     /* extent size (in 4K    */
                                                     /* pages)                */
        long           sqlprftc;                     /* prefetch size (4K     */
                                                     /* pages)                */
        double         sqlpovhd;                     /* i/o overhead          */
        double         sqltrfrt;                     /* i/o transfer rate     */
        char           sqltstyp;                     /* tableSpace type       */
        char           pad1;                         /* reserved              */
        short          sqlccnt;                      /* container count       */
        struct SQLETSCDESC containr[1];              /* array of container    */
                                                     /* specs                 */
};

#define SQLETSDESC_SIZE(containerCount) \
(sizeof(struct SQLETSDESC)+ \
((containerCount)-1)*sizeof(struct SQLETSCDESC) )

SQL_STRUCTURE sqledbdesc
{
        _SQLOLDCHAR    sqldbdid[8];                  /* eye catcher           */
        long           sqldbccp;                     /* comment code page     */
        long           sqldbcss;                     /* Source of collating   */
                                                     /* seq                   */
        unsigned char  sqldbudc[SQL_CS_SZ];          /* user-defined          */
                                                     /* collating seq         */
        _SQLOLDCHAR    sqldbcmt[SQL_CMT_SZ+1];       /* comment               */
        _SQLOLDCHAR    pad[1];                       /* reserved              */
        unsigned long  sqldbsgp;                     /* obsolete: use         */
                                                     /* sqltsext              */
        short          sqldbnsg;                     /* number of segments    */
        char           pad2[2];                      /* reserved              */
        long           sqltsext;                     /* default extent size   */
        struct SQLETSDESC *sqlcatts;
        struct SQLETSDESC *sqlusrts;
        struct SQLETSDESC *sqltmpts;
};


/* Database Directory Scan data structure                                     */
SQL_STRUCTURE sqledinfo
{
        _SQLOLDCHAR    alias[SQL_ALIAS_SZ];          /* Alias name            */
        _SQLOLDCHAR    dbname[SQL_DBNAME_SZ];        /* Database name         */
        _SQLOLDCHAR    drive[SQL_DRIVE_SZ];          /* Drive/Path            */
        _SQLOLDCHAR    intname[SQL_INAME_SZ];        /* Database              */
                                                     /* subdirectory          */
        _SQLOLDCHAR    nodename[SQL_NNAME_SZ];       /* Node name             */
        _SQLOLDCHAR    dbtype[SQL_DBTYP_SZ];         /* Release information   */
        _SQLOLDCHAR    comment[SQL_CMT_SZ];          /* Comment               */
        short          com_codepage;                 /* Code page of comment  */
        _SQLOLDCHAR    type;                         /* Entry type - defines  */
                                                     /* above                 */
        unsigned short authentication;               /* Authentication type   */
        char           glbdbname[SQL_DIR_NAME_SZ];   /* Global database name  */
};

/* Node Directory Scan data structure                                         */
SQL_STRUCTURE sqleninfo
{
        _SQLOLDCHAR    nodename[SQL_NNAME_SZ];       /* Node name             */
        _SQLOLDCHAR    local_lu[SQL_LOCLU_SZ];       /* Local_lu_name         */
        _SQLOLDCHAR    partner_lu[SQL_RMTLU_SZ];     /* Partner_lu_name       */
        _SQLOLDCHAR    mode[SQL_MODE_SZ];            /* Mode                  */
        _SQLOLDCHAR    comment[SQL_CMT_SZ];          /* Comment               */
        unsigned short com_codepage;                 /* Comment code page     */
        unsigned short adapter;                      /* NetBIOS Adapter #     */
        _SQLOLDCHAR    networkid[SQL_NETID_SZ];      /* APPN Network ID       */
        _SQLOLDCHAR    protocol;                     /* Protocol type         */
        _SQLOLDCHAR    sym_dest_name[SQL_SYM_DEST_NAME_SZ]; /* CPIC Sym.      */
                                                     /* Dest. Name            */
        unsigned short security_type;                /* CPIC Security Type    */
        _SQLOLDCHAR    hostname[SQL_HOSTNAME_SZ];    /* TCP/IP Host name      */
        _SQLOLDCHAR    service_name[SQL_SERVICE_NAME_SZ]; /* TCP/IP Service   */
                                                     /* name                  */
        char           fileserver[SQL_FILESERVER_SZ]; /* IPX/SPX fileserver   */
                                                     /* name                  */
        char           objectname[SQL_OBJECTNAME_SZ]; /* IPX/SPX objectname   */
        char           instance_name[SQL_INSTNAME_SZ]; /* LOCAL Instance      */
                                                     /* name                  */
};

/* General Catalog Node structures and defines                                */

SQL_STRUCTURE sqle_node_struct
{
        unsigned short struct_id;                    /* Structure Identifier  */
        unsigned short codepage;                     /* Codepage for comment  */
        _SQLOLDCHAR    comment[SQL_CMT_SZ + 1];      /* Comment               */
        _SQLOLDCHAR    nodename[SQL_NNAME_SZ + 1];   /* Node name             */
        unsigned char  protocol;                     /* Protocol Type         */
};

SQL_STRUCTURE sqle_node_appc                         /* For APPC protocol     */
{
        _SQLOLDCHAR    local_lu[SQL_LOCLU_SZ + 1];   /* Local_lu name         */
        _SQLOLDCHAR    partner_lu[SQL_RMTLU_SZ + 1]; /* Alias Partner_lu      */
                                                     /* name                  */
        _SQLOLDCHAR    mode[SQL_MODE_SZ + 1];        /* Mode                  */
};

SQL_STRUCTURE sqle_node_netb                         /* For NetBIOS Protocol  */
{
        unsigned short adapter;                      /* Adapter Number        */
        _SQLOLDCHAR    remote_nname[SQL_RMTLU_SZ + 1]; /* Remote Workstation  */
                                                     /* name                  */
};

SQL_STRUCTURE sqle_node_appn                         /* For APPN protocol     */
{
        _SQLOLDCHAR    networkid[SQL_NETID_SZ + 1];  /* Network ID            */
        _SQLOLDCHAR    remote_lu[SQL_RMTLU_SZ + 1];  /* Remoter lu name       */
        _SQLOLDCHAR    local_lu[SQL_LOCLU_SZ + 1];   /* Local_lu name         */
        _SQLOLDCHAR    mode[SQL_MODE_SZ + 1];        /* Mode                  */
};

SQL_STRUCTURE sqle_node_tcpip                        /* For TCPIP protocol    */
{
        _SQLOLDCHAR    hostname[SQL_HOSTNAME_SZ+1];  /* Host name             */
        _SQLOLDCHAR    service_name[SQL_SERVICE_NAME_SZ+1]; /* Service Name   */
};

SQL_STRUCTURE sqle_node_local                        /* For LOCAL protocol    */
{
        char           instance_name[SQL_INSTNAME_SZ+1]; /* Instance Name     */
};

SQL_STRUCTURE sqle_node_cpic                         /* For APPC using CPIC   */
                                                     /* protocol              */
{
        _SQLOLDCHAR    sym_dest_name[SQL_SYM_DEST_NAME_SZ+1]; /* Sym Dest     */
                                                     /* Name                  */
        unsigned short security_type;                /* Security Type         */
};

SQL_STRUCTURE sqle_node_ipxspx                       /* For IPX/SPX protocol  */
{
        char           fileserver[SQL_FILESERVER_SZ+1]; /* Fileserver name    */
        char           objectname[SQL_OBJECTNAME_SZ+1]; /* Object name        */
};

/* Values for sqlefrce                                                        */
#define SQL_ASYNCH             0       /* Force Mode (Asynchronous)           */
#define SQL_ALL_USERS          -1      /* Force Count (All Users)             */

#define SQL_PRODNAME_SZ        30      /* Product name                        */
SQL_STRUCTURE sql_dir_entry            /* DDCS Directory Entry Data           */
                                       /* Structure                           */
{
        unsigned short         struct_id; /* Structure Identifier             */
        unsigned short         release; /* Release level of entry             */
        unsigned short         codepage; /* Codepage of comment               */
        _SQLOLDCHAR            comment[SQL_CMT_SZ + 1]; /* Directory entry    */
                                       /* comment                             */
        _SQLOLDCHAR            ldb[SQL_DBNAME_SZ + 1]; /* Local DB name       */
        _SQLOLDCHAR            tdb[SQL_LONG_NAME_SZ + 1]; /* Target (host)    */
                                       /* DB name                             */
        _SQLOLDCHAR            ar[SQL_AR_SZ + 1]; /* AR library name          */
        _SQLOLDCHAR            parm[SQL_PARAMETER_SZ + 1]; /* Parameter       */
                                       /* string                              */
};

/******************************************************************************
** Database Codepage and Country code info structures
*******************************************************************************/

SQL_STRUCTURE sqledbcinfo
{
        _SQLOLDCHAR            sqldbcp[SQL_CODESET_LEN + 1]; /* database      */
                                       /* codeset                             */
        _SQLOLDCHAR            sqldbcc[SQL_LOCALE_LEN + 1]; /* database       */
                                       /* territory                           */
};

/******************************************************************************
** V2 Database Codepage and Country code info structure
*******************************************************************************/

SQL_STRUCTURE sqledbcountryinfo
{
        char                   sqldbcodeset[SQL_CODESET_LEN + 1]; 
        char                   sqldblocale[SQL_LOCALE_LEN + 1]; /* database   */
                                       /* territory                           */
};

SQL_STRUCTURE sqle_conn_setting        /* Connection setting structure for    */
                                       /* use with distributed unit of work   */
{
        unsigned short         type;   /* Connection setting type             */
        unsigned short         value;  /* Connection setting value            */
};

/******************************************************************************
** Register/Deregister constants and data structures
*******************************************************************************/

/* Defines for LOCATION TO REGISTER parameter                                 */
#define SQL_NWBINDERY          0

/* Register/deregister info. for NW bindery data structure                    */
SQL_STRUCTURE sqle_reg_nwbindery
{
        char                   uid[SQL_NW_UID_SZ+1];
        unsigned short         reserved_len_1;
        char                   pswd[SQL_NW_PSWD_SZ+1];
        unsigned short         reserved_len_2;
};

#if defined(SQLZ_STACK)
#define SQLENOP 0
#else

/******************************************************************************
** Database Environment Commands -- Function Prototypes
*******************************************************************************/


#if defined(SQL_REL_10)
#define sqledrpd(dbn,pw,ca) sqledrpd_api(dbn,pw,ca)
#else
#define sqledrpd(dbn,ca) sqledrpd_api(dbn, (_SQLOLDCHAR *) "",ca)
#endif
#define sqlectdd(dbn,als,ty,nm,dr,com,au,ca) sqlectdd_api(dbn,\
  als,ty,nm,dr,com,au,ca)
#define sqlectnd(node,prot,ca) sqlectnd_api(node,prot,ca)
#define sqledbcr(dbn,drv,dbdesc,au,dbcinfo,ca) \
  sqledbcr_api(dbn,drv,dbdesc,au,dbcinfo,ca)
#define sqledcgd(dbn,drv,com,ca) sqledcgd_api(dbn,drv,com,ca)
#define sqledcls(ha,ca) sqledcls_api(ha,ca)
#define sqledgne(ha,bu,ca) sqledgne_api(ha,bu,ca)
#define sqledosd(dr,ha,co,ca) sqledosd_api(dr,ha,co,ca)
#define sqlefrce(cn,ap,mo,ca) sqlefrce_api(cn,ap,mo,ca)
#define sqlegdad(entry,ca) sqlegdad_api(entry,ca)
#define sqlegdcl(ca) sqlegdcl_api(ca)
#define sqlegdel(entry,ca) sqlegdel_api(entry,ca)
#define sqlegdge(entry,ca) sqlegdge_api(entry,ca)
#define sqlegdgt(ct,entry,ca) sqlegdgt_api(ct,entry,ca)
#define sqlegdsc(ct,ca) sqlegdsc_api(ct,ca)
#define sqlegins(iname,ca) sqlegins_api(iname,ca)

#define sqleregs(loc,reg,ca) sqleregs_api(loc,reg,ca)
#define sqledreg(loc,reg,ca) sqledreg_api(loc,reg,ca)
#define sqleintr() sqleintr_api()
#define sqleisig(ca) sqleisig_api(ca)
#define sqlefmem(ca,mptr) sqlefmem_api(ca,mptr)
#define sqlemgdb(db,id,pw,ca) sqlemgdb_api(db,id,pw,ca)
#define sqle_activate_db(db,id,pw,rr,ca) sqle_activate_db_api(db,id,pw,rr,ca)
#define sqle_deactivate_db(db,id,pw,rr,ca) sqle_deactivate_db_api(db,id,pw,rr,ca)
#define sqlencls(ha,ca) sqlencls_api(ha,ca)
#define sqlengne(ha,bu,ca) sqlengne_api(ha,bu,ca)
#define sqlenops(ha,bu,ca) sqlenops_api(ha,bu,ca)
#define sqleproc(na,ln,ida,oda,ca) sqleproc_api(na,ln,ida,oda,ca)
#define sqlerstd(dbn,id,pw,ca) sqlerstd_api(dbn,id,pw,ca)
#define sqlestar() sqlestar_api()
#define sqlestop(ca) sqlestop_api(ca)
#define sqleuncd(dbn,ca) sqleuncd_api(dbn,ca)
#define sqleuncn(nn,ca) sqleuncn_api(nn,ca)
#define sqlesetc(set,num,ca) sqlesetc_api(set,num,ca)
#define sqleqryc(set,num,ca) sqleqryc_api(set,num,ca)
#define sqleatin(iname,id,pw,ca) sqleatin_api(iname,id,pw,ca)
#define sqledtin(ca) sqledtin_api(ca)
#define sqlecrea(dbn,alias,drv,dbdesc,dbcinfo,rsvd2,rsvd1,ca) \
        sqlecrea_api(dbn,alias,drv,dbdesc,dbcinfo,rsvd2,rsvd1,ca)
#define sqlesact(str,ca) sqlesact_api(str,ca)
#endif

SQL_API_RC SQL_API_FN                        /* Catalog Database              */
  sqlectdd_api (
        _SQLOLDCHAR * pDbName,               /* database                      */
        _SQLOLDCHAR * pDbAlias,              /* alias                         */
        unsigned char Type,                  /* type                          */
        _SQLOLDCHAR * pNodeName,             /* node name                     */
        _SQLOLDCHAR * pPath,                 /* drive/path                    */
        _SQLOLDCHAR * pComment,              /* comment                       */
        unsigned short Authentication,       /* authentication                */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Catalog Node                  */
  sqlectnd_api (
        struct sqle_node_struct * pNodeInfo, /* node structure ptr            */
        void * pProtocolInfo,                /* protocol structure ptr        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Change Database Comment       */
  sqledcgd_api (
        _SQLOLDCHAR * pDbAlias,              /* database alias                */
        _SQLOLDCHAR * pPath,                 /* drive/path                    */
        _SQLOLDCHAR * pComment,              /* comment                       */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Close Directory Scan          */
  sqledcls_api (
        unsigned short Handle,               /* handle                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get Next Directory Entry      */
  sqledgne_api (
        unsigned short Handle,               /* handle                        */
        struct sqledinfo ** ppDbDirEntry,    /* buffer                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Open Directory Scan           */
  sqledosd_api (
        _SQLOLDCHAR * pPath,                 /* drive/path                    */
        unsigned short * pHandle,            /* handle                        */
        unsigned short * pNumEntries,        /* count                         */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Drop Database                 */
  sqledrpd_api (
        _SQLOLDCHAR * pDbAlias,              /* database alias                */
        _SQLOLDCHAR * pReserved2,            /* reserved                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Force Users                   */
  sqlefrce_api (
        long NumAgentIds,                    /* number of users to force      */
        unsigned long * pAgentIds,           /* array of agent ids            */
        unsigned short ForceMode,            /* mode of operation             */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Catalog DCS Database          */
  sqlegdad_api (
        struct sql_dir_entry * pDCSDirEntry, /* pointer to entry structure    */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Close DCS Directory Scan      */
  sqlegdcl_api (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Uncatalog DCS Database        */
  sqlegdel_api (
        struct sql_dir_entry * pDCSDirEntry, /* pointer to entry structure    */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get DCS Directory Entry For   */
                                             /* Database                      */
  sqlegdge_api (
        struct sql_dir_entry * pDCSDirEntry, /* pointer to entry structure    */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get DCS Directory Entries     */
  sqlegdgt_api (
        short * pNumEntries,                 /* pointer to count variable     */
        struct sql_dir_entry * pDCSDirEntries, /* pointer to entry structure  */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Open DCS Directory Scan       */
  sqlegdsc_api (
        short * pNumEntries,                 /* pointer to count variable     */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get Instance                  */
  sqlegins_api (
        _SQLOLDCHAR * pInstance,             /* pointer to instance name      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_INTR                      /* Interrupt                     */
        sqleintr_api ( void );

SQL_API_RC SQL_API_FN                        /* Install Signal Handler        */
  sqleisig_api (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Free Memory                   */
  sqlefmem_api (
        struct sqlca * pSqlca,               /* SQLCA                         */
        void * pBuffer);                     /* buffer pointer                */

SQL_API_RC SQL_API_FN                        /* Migrate Database              */
  sqlemgdb_api (
        _SQLOLDCHAR * pDbAlias,              /* database alias                */
        _SQLOLDCHAR * pUserName,             /* user name                     */
        _SQLOLDCHAR * pPassword,             /* password                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Activate Database             */
  sqle_activate_db_api (
        char * pDbAlias,                     /* database alias                */
        char * pUserName,                    /* user name                     */
        char * pPassword,                    /* password                      */
        void * pReserved,                    /* Reserved for future use       */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Deactivate Database           */
  sqle_deactivate_db_api (
        char * pDbAlias,                     /* database alias                */
        char * pUserName,                    /* user name                     */
        char * pPassword,                    /* password                      */
        void * pReserved,                    /* Reserved for future use       */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Close Node Directory Scan     */
  sqlencls_api (
        unsigned short Handle,               /* handle                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get Next Node Directory       */
                                             /* Entry                         */
  sqlengne_api (
        unsigned short Handle,               /* handle                        */
        struct sqleninfo ** ppNodeDirEntry,  /* buffer                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Open Node Directory Scan      */
  sqlenops_api (
        unsigned short * pHandle,            /* handle                        */
        unsigned short * pNumEntries,        /* count                         */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Database Application Remote   */
                                             /* Interface                     */
  sqleproc_api (
        char * pProgramName,                 /* Path of program to run        */
        struct sqlchar * pInput,             /* variable length area ptr      */
        struct sqlda * pInputSqlda,          /* input SQLDA                   */
        struct sqlda * pOutputSqlda,         /* output SQLDA                  */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Restart Database              */
  sqlerstd_api (
        _SQLOLDCHAR * pDbAlias,              /* database alias                */
        _SQLOLDCHAR * pUserName,             /* user name                     */
        _SQLOLDCHAR * pPassword,             /* password                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Start Database Manager        */
  sqlestar_api (
        void);

SQL_API_RC SQL_API_FN                        /* Stop Database Manager         */
  sqlestop_api (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Uncatalog Database            */
  sqleuncd_api (
        _SQLOLDCHAR * pDbAlias,              /* database alias                */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Uncatalog Node                */
  sqleuncn_api (
        _SQLOLDCHAR * pNodeName,             /* node name                     */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Set Client                    */
  sqlesetc_api (
        struct sqle_conn_setting * pConnectionSettings, /* conn setting       */
                                             /* array                         */
        unsigned short NumSettings,          /* number of settings            */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Query Client                  */
  sqleqryc_api (
        struct sqle_conn_setting * pConnectionSettings, /* conn setting       */
                                             /* array                         */
        unsigned short NumSettings,          /* number of settings            */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Create Database               */
  sqlecrea_api (
        char * pDbName,                      /* database                      */
        char * pLocalDbAlias,                /* local alias                   */
        char * pPath,                        /* drive/path                    */
        struct sqledbdesc * pDbDescriptor,   /* database descriptor block     */
        struct sqledbcountryinfo * pCountryInfo, /* db locale and codeset     */
        char Reserved2,                      /* reserved                      */
        void * pReserved1,                   /* reserved                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Attach                        */
  sqleatin_api (
        char * pNodeName,                    /* node name                     */
        char * pUserName,                    /* user name                     */
        char * pPassword,                    /* password                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Detach                        */
  sqledtin_api (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Set Accounting String         */
  sqlesact_api (
        char * pAccountingString,            /* accounting string             */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Register DB2 Server           */
  sqleregs_api (
        unsigned short Registry,             /* location at which to reg      */
        void * pRegisterInfo,                /* register info.                */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Deregister DB2 Server         */
  sqledreg_api (
        unsigned short Registry,             /* location at which to dereg    */
        void * pRegisterInfo,                /* deregister info.              */
        struct sqlca * pSqlca);              /* SQLCA                         */

/* GENERIC INTERFACES                                                         */

SQL_API_RC SQL_API_FN                        /* Change Database Comment       */
  sqlgdcgd (
        unsigned short CommentLen,           /* comment length                */
        unsigned short PathLen,              /* drive/path length             */
        unsigned short DbAliasLen,           /* database length               */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pComment,              /* comment                       */
        _SQLOLDCHAR * pPath,                 /* drive/path                    */
        _SQLOLDCHAR * pDbAlias);             /* database                      */

SQL_API_RC SQL_API_FN                        /* Close Directory Scan          */
  sqlgdcls (
        unsigned short Handle,               /* handle                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get Next Database Directory   */
                                             /* Entry                         */
  sqlgdgne (
        unsigned short Handle,               /* handle                        */
        struct sqledinfo ** ppDbDirEntry,    /* buffer                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Drop Database                 */
  sqlgdrpd (
        unsigned short Reserved1,            /* reserved                      */
        unsigned short DbAliasLen,           /* database alias length         */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pReserved2,            /* reserved                      */
        _SQLOLDCHAR * pDbAlias);             /* database alias                */

SQL_API_RC SQL_API_FN                        /* Open Directory Scan           */
  sqlgdosd (
        unsigned short PathLen,              /* drive/path length             */
        struct sqlca * pSqlca,               /* SQLCA                         */
        unsigned short * pNumEntries,        /* count                         */
        unsigned short * pHandle,            /* handle                        */
        _SQLOLDCHAR * pPath);                /* drive/path                    */

SQL_API_RC SQL_API_FN                        /* Force Users                   */
  sqlgfrce (
        struct sqlca * pSqlca,               /* SQLCA                         */
        unsigned short ForceMode,            /* mode of operation             */
        unsigned long * pAgentIds,           /* array of agent ids            */
        long NumAgentIds);                   /* num of users to force         */

SQL_API_RC SQL_API_FN                        /* Catalog DCS Database          */
  sqlggdad (
        struct sqlca * pSqlca,               /* SQLCA                         */
        struct sql_dir_entry * pDCSDirEntry); /* directory entry              */

SQL_API_RC SQL_API_FN                        /* Close DCS Directory Scan      */
  sqlggdcl (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Uncatalog DCS Database        */
  sqlggdel (
        struct sqlca * pSqlca,               /* SQLCA                         */
        struct sql_dir_entry * pDCSDirEntry); /* directory entry              */

SQL_API_RC SQL_API_FN                        /* Get DCS Directory Entry For   */
                                             /* Database                      */
  sqlggdge (
        struct sqlca * pSqlca,               /* SQLCA                         */
        struct sql_dir_entry * pDCSDirEntry); /* directory entry              */

SQL_API_RC SQL_API_FN                        /* Get DCS Directory Entries     */
  sqlggdgt (
        struct sqlca * pSqlca,               /* SQLCA                         */
        short * pNumEntries,                 /* count variable                */
        struct sql_dir_entry * pDCSDirEntries); /* entry structure            */

SQL_API_RC SQL_API_FN                        /* Open DCS Directory Scan       */
  sqlggdsc (
        struct sqlca * pSqlca,               /* SQLCA                         */
        short * pNumEntries);                /* count variable                */

SQL_API_RC SQL_API_FN                        /* Get Instance                  */
  sqlggins (
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pInstance);            /* pointer to instance name      */

SQL_API_RC SQL_API_FN                        /* Catalog Database              */
  sqlgctdd (
        unsigned short CommentLen,           /* comment length                */
        unsigned short PathLen,              /* drive/path length             */
        unsigned short NodeNameLen,          /* node name length              */
        unsigned short DbAliasLen,           /* alias length                  */
        unsigned short DbNameLen,            /* database length               */
        struct sqlca * pSqlca,               /* SQLCA                         */
        unsigned short Authentication,       /* authentication                */
        _SQLOLDCHAR * pComment,              /* comment                       */
        _SQLOLDCHAR * pPath,                 /* drive/path                    */
        _SQLOLDCHAR * pNodeName,             /* node name                     */
        unsigned char Type,                  /* type                          */
        _SQLOLDCHAR * pDbAlias,              /* alias                         */
        _SQLOLDCHAR * pDbName);              /* database                      */

SQL_API_RC SQL_API_FN                        /* Catalog Node                  */
  sqlgctnd (
        struct sqlca * pSqlca,               /* SQLCA                         */
        struct sqle_node_struct * pNodeInfo, /* node structure                */
        void * pProtocolInfo);               /* Protocol Structure            */

SQL_API_RC SQL_API_FN                        /* CREATE DATABASE               */
  sqlgdbcr (
        unsigned short,                      /* length drive/path             */
        unsigned short,                      /* length database               */
        struct sqlca *,                      /* SQLCA                         */
        struct sqledbcinfo *,                /* database country info         */
        unsigned short,                      /* authentication                */
        struct sqledbdesc *,                 /* db descriptor block           */
        _SQLOLDCHAR *,                       /* drive/path                    */
        _SQLOLDCHAR *);                      /* database                      */

SQL_API_RC SQL_API_FN                        /* Interrupt                     */
  sqlgintr (
        void);

SQL_API_RC SQL_API_FN                        /* Install Signal Handler        */
  sqlgisig (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Migrate Database              */
  sqlgmgdb (
        unsigned short PasswordLen,          /* password length               */
        unsigned short UserNameLen,          /* user name length              */
        unsigned short DbAliasLen,           /* database alias length         */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pPassword,             /* password                      */
        _SQLOLDCHAR * pUserName,             /* user name                     */
        _SQLOLDCHAR * pDbAlias);             /* database alias                */

SQL_API_RC SQL_API_FN                        /* Activate Database             */
  sqlg_activate_db (
        unsigned short DbAliasLen,           /* database alias length         */
        unsigned short UserNameLen,          /* user name length              */
        unsigned short PasswordLen,          /* password length               */
        char * pDbAlias,                     /* database alias                */
        char * pUserName,                    /* user name                     */
        char * pPassword,                    /* password                      */
        void * pReserved,                    /* reserved                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Deactivate Database           */
  sqlg_deactivate_db (
        unsigned short DbAliasLen,           /* database alias length         */
        unsigned short UserNameLen,          /* user name length              */
        unsigned short PasswordLen,          /* password length               */
        char * pDbAlias,                     /* database alias                */
        char * pUserName,                    /* user name                     */
        char * pPassword,                    /* password                      */
        void * pReserved,                    /* reserved                      */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Close Node Directory Scan     */
  sqlgncls (
        unsigned short Handle,               /* handle                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Get Next Node Directory       */
                                             /* Entry                         */
  sqlgngne (
        unsigned short Handle,               /* handle                        */
        struct sqleninfo ** ppNodeDirEntry,  /* buffer                        */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Open Node Directory Scan      */
  sqlgnops (
        unsigned short * pHandle,            /* handle                        */
        unsigned short * pNumEntries,        /* count                         */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Database Application Remote   */
                                             /* Interface                     */
  sqlgproc (
        unsigned short ProgramNameLen,       /* program name length           */
        struct sqlca * pSqlca,               /* SQLCA                         */
        char * pProgramName,                 /* Path of program to run        */
        struct sqlda * pInputSqlda,          /* input SQLDA                   */
        struct sqlda * pOutputSqlda,         /* output SQLDA                  */
        struct sqlchar * pInput);            /* variable length area ptr      */

SQL_API_RC SQL_API_FN                        /* Restart Database              */
  sqlgrstd (
        unsigned short PasswordLen,          /* password length               */
        unsigned short UserNameLen,          /* user name length              */
        unsigned short DbAliasLen,           /* database alias length         */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pPassword,             /* password                      */
        _SQLOLDCHAR * pUserName,             /* user name                     */
        _SQLOLDCHAR * pDbAlias);             /* database alias                */

SQL_API_RC SQL_API_FN                        /* Set Client                    */
  sqlgsetc (
        struct sqle_conn_setting * pConnectionSettings, /* conn setting       */
                                             /* array                         */
        unsigned short NumSettings,          /* number of settings            */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Query Client                  */
  sqlgqryc (
        struct sqle_conn_setting * pConnectionSettings, /* conn setting       */
                                             /* array                         */
        unsigned short NumSettings,          /* number of settings            */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Create Database               */
  sqlgcrea (
        unsigned short PathLen,              /* drive/path length             */
        unsigned short LocalDbAliasLen,      /* local alias length            */
        unsigned short DbNameLen,            /* database length               */
        struct sqlca * pSqlca,               /* SQLCA                         */
        void * pReserved1,                   /* reserved                      */
        unsigned short Reserved2,            /* reserved                      */
        struct sqledbcountryinfo * pCountryInfo, /* db locale and codeset     */
        struct sqledbdesc * pDbDescriptor,   /* db description block          */
        char * pPath,                        /* drive/path                    */
        char * pLocalDbAlias,                /* local alias                   */
        char * pDbName);                     /* database                      */

SQL_API_RC SQL_API_FN                        /* Attach                        */
  sqlgatin (
        unsigned short PasswordLen,          /* password length               */
        unsigned short UserNameLen,          /* user name length              */
        unsigned short NodeNameLen,          /* node name length              */
        struct sqlca * pSqlca,               /* SQLCA                         */
        char * pPassword,                    /* password                      */
        char * pUserName,                    /* user name                     */
        char * pNodeName);                   /* node name                     */

SQL_API_RC SQL_API_FN                        /* Detach                        */
  sqlgdtin (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Start Database Manager        */
  sqlgstar (
        void);

SQL_API_RC SQL_API_FN                        /* Stop Database Manager         */
  sqlgstdm (
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Uncatalog Database            */
  sqlguncd (
        unsigned short DbAliasLen,           /* database alias length         */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pDbAlias);             /* database alias                */

SQL_API_RC SQL_API_FN                        /* Uncatalog Node                */
  sqlguncn (
        unsigned short NodeNameLen,          /* node name length              */
        struct sqlca * pSqlca,               /* SQLCA                         */
        _SQLOLDCHAR * pNodeName);            /* node name                     */

SQL_API_RC SQL_API_FN                        /* Set Accounting String         */
  sqlgsact (
        unsigned short AccountingStringLen,  /* accounting string length      */
        char * pAccountingString,            /* accounting string             */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Register DB2 Server           */
  sqlgregs (
        unsigned short Registry,             /* location at which to reg      */
        void * pRegisterInfo,                /* register info.                */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Deregister DB2 Server         */
  sqlgdreg (
        unsigned short Registry,             /* location at which to dereg    */
        void * pRegisterInfo,                /* deregister info.              */
        struct sqlca * pSqlca);              /* SQLCA                         */

SQL_API_RC SQL_API_FN                        /* Free Memory                   */
  sqlgfmem (
        struct sqlca * pSqlca,               /* SQLCA                         */
        void * pBuffer);                     /* buffer pointer                */

/* SQL Return Codes in SQLCODE for Environment Commands                       */

#ifndef SQL_RC_OK
#define SQL_RC_OK 0 /* everything is ok */
#endif /* SQL_RC_OK */

#ifndef SQL_RC_INVALID_SQLCA
#define SQL_RC_INVALID_SQLCA -1 /* invalid sqlca */
#endif /* SQL_RC_INVALID_SQLCA */

#define SQLE_RC_STILL_EXECUTING 16           /* Request is still executing    */
#define SQLE_RC_INLUW  -752                  /* Connect to other DB not       */
                                             /* allowed                       */
#define SQLE_RC_W863   863                   /* Only SBCS data allowed        */

#define SQLE_RC_E953   -953                  /* Agent heap too small          */
#define SQLE_RC_E957   -957                  /* Requestor comm heap too       */
                                             /* small                         */
#define SQLE_RC_E959   -959                  /* Server comm heap too small    */
#define SQLE_RC_E961   -961                  /* Rqstr remote svcs heap too    */
                                             /* small                         */
#define SQLE_RC_E962   -962                  /* Svr remote svcs heap too      */
                                             /* small                         */

#define SQLE_RC_INVNEWLOGP 993               /* New log path is invalid       */
#define SQLE_RC_INVLOGP 995                  /* Current log path is invalid   */

#define SQLE_RC_INVALIAS -1000               /* Invalid alias                 */
#define SQLE_RC_INVDBNAME -1001              /* Invalid database name         */
#define SQLE_RC_INVDRIVE -1002               /* Invalid drive                 */

#define SQLE_RC_INVPSW_DB2OS2 -1003          /* Invalid password - OS/2       */
#define SQLE_RC_INVPSW_DB2NT -1003           /* Invalid password - NT         */
#define SQLE_RC_INVPSW_DB2DOS -1003          /* Invalid password - DOS        */
#define SQLE_RC_INVPSW_DB2WIN -1003          /* Invalid password - Windows    */
#define SQLE_RC_INVPSW_DB2MAC -1003          /* Invalid password - Mac        */
#define SQLE_RC_INVPSW_DB2AIX -10002         /* Invalid password - AIX        */

#define SQLE_RC_INVPSW SQLE_RC_INVPSW_DB2AIX

#define SQLE_RC_INSSTOR -1004                /* Insuf storage on file system  */
#define SQLE_RC_DUPALIAS -1005               /* Duplicate alias               */
#define SQLE_RC_WRONGCODEPG -1006            /* Appl code page does not       */
                                             /* match db                      */
#define SQLE_RC_INV_NEWPSW -1008             /* Invalid new password          */
#define SQLE_RC_INVREMOTE -1009              /* Invalid remote command        */

#define SQLE_RC_INVTYPE -1010                /* Invalid type                  */
#define SQLE_RC_NODRIVE -1011                /* No drive for indirect entry   */
#define SQLE_RC_NONODE -1012                 /* No nodename for remote entry  */
#define SQLE_RC_NODB   -1013                 /* Alias or database name not    */
                                             /* found                         */
#define SQLE_RC_NOMORE 1014                  /* No more entries               */
#define SQLE_RC_DB_RESTART -1015             /* Database needs restart        */
#define SQLE_RC_INVLLU -1016                 /* Invalid local_lu alias        */
#define SQLE_RC_INVMODE -1017                /* Invalid mode                  */
#define SQLE_RC_DUPNODE -1018                /* Duplicate node name           */
#define SQLE_RC_INVNODE -1019                /* Invalid node name             */

#define SQLE_RC_MAXNODE -1020                /* Node could not be cataloged   */
#define SQLE_RC_NOTNODE -1021                /* Nodename not found            */

#define SQLE_RC_INSSYS_DB2OS2 -1022          /* Insuf system resources - OS   */
                                             /* 2                             */
#define SQLE_RC_INSSYS_DB2NT -1022           /* Insuf system resources - NT   */
#define SQLE_RC_INSSYS_DB2DOS -1022          /* Insuf system resources - DOS  */
#define SQLE_RC_INSSYS_DB2WIN -1022          /* Insuf system resources -      */
                                             /* Windows                       */
#define SQLE_RC_INSSYS_DB2MAC -1022          /* Insuf system resources -      */
                                             /* Macintosh                     */
#define SQLE_RC_INSSYS_DB2AIX -10003         /* Insuf system resources - AIX  */

#define SQLE_RC_INSSYS SQLE_RC_INSSYS_DB2AIX

#define SQLE_RC_NOCONV -1023                 /* Communication conversation    */
                                             /* failed                        */
#define SQLE_RC_NOSUDB -1024                 /* No database connection        */
                                             /* exists                        */
#define SQLE_RC_DBACT  -1025                 /* Databases are active          */
#define SQLE_RC_INVSTRT -1026                /* Database manager already      */
                                             /* started                       */
#define SQLE_RC_NONODEDIR -1027              /* Node directory not found      */
#define SQLE_RC_INVRLU -1029                 /* Partner lu not specified      */

#define SQLE_RC_MAXDB  -1030                 /* Database directory is full    */
#define SQLE_RC_NODBDIR -1031                /* Database directory not found  */
#define SQLE_RC_NOSTARTG -1032               /* Database manager not started  */
#define SQLE_RC_DIRBUSY -1033                /* Database directory being      */
                                             /* updated                       */
#define SQLE_RC_DBBAD  -1034                 /* Database is damaged           */
#define SQLE_RC_DB_INUSE -1035               /* Database already in use       */
#define SQLE_RC_FILEDB -1036                 /* Database file error           */
#define SQLE_RC_NODE_DIR_EMPTY 1037          /* No entry in Node directory    */
#define SQLE_RC_FILENODE -1038               /* Node directory file error     */

#define SQLE_RC_FILEDIR_DB2OS2 -1039         /* Directory file error - OS/2   */
#define SQLE_RC_FILEDIR_DB2NT -1039          /* Directory file error - NT     */
#define SQLE_RC_FILEDIR_DB2DOS -1039         /* Directory file error - DOS    */
#define SQLE_RC_FILEDIR_DB2WIN -1039         /* Directory file error -        */
                                             /* Windows                       */
#define SQLE_RC_FILEDIR_DB2MAC -1039         /* Directory file error - Mac    */
#define SQLE_RC_FILEDIR_DB2AIX -10004        /* Directory file error - AIX    */

#define SQLE_RC_FILEDIR SQLE_RC_FILEDIR_DB2AIX

#define SQLE_RC_MAXAPPLS -1040               /* Max number of applications    */
                                             /* reached                       */
#define SQLE_RC_MAXDBS -1041                 /* Max number of databases       */
                                             /* started                       */
#define SQLE_RC_SYSERR -1042                 /* System error                  */
#define SQLE_RC_CATBOOT -1043                /* Catalog bootstrap failure     */
#define SQLE_RC_INTRRPT -1044                /* Request interrupted by        */
                                             /* ctrl+break                    */
#define SQLE_RC_INVINDIR -1045               /* Invalid level of indirection  */
#define SQLE_RC_INVAUTHID -1046              /* Invalid userid                */
#define SQLE_RC_APCONN -1047                 /* Appl already connect to       */
                                             /* another db                    */

#define SQLE_RC_USEINVALID_DB2OS2 -1048      /* Invalid use specified - OS/2  */
#define SQLE_RC_USEINVALID_DB2NT -1048       /* Invalid use specified - NT    */
#define SQLE_RC_USEINVALID_DB2DOS -1048      /* Invalid use specified - DOS   */
#define SQLE_RC_USEINVALID_DB2WIN -1048      /* Invalid use specified -       */
                                             /* Windows                       */
#define SQLE_RC_USEINVALID_DB2MAC -1048      /* Invalid use specified -       */
                                             /* MacOS                         */
#define SQLE_RC_USEINVALID_DB2AIX -10005     /* Invalid use specified - AIX   */

#define SQLE_RC_USEINVALID SQLE_RC_USEINVALID_DB2AIX

#define SQLE_RC_APPSERR -900                 /* Appl state in error           */

#define SQLE_RC_UNCHOME -1050                /* Cannot uncatalog 'Home'       */
                                             /* database                      */
#define SQLE_RC_NODIRDRV -1051               /* Db direct. drive does not     */
                                             /* exist                         */
#define SQLE_RC_NODBDRV -1052                /* Database drive does not       */
                                             /* exist                         */
#define SQLE_RC_INTBUSY -1053                /* Interrupt already in          */
                                             /* progress                      */
#define SQLE_RC_COMMINP -1054                /* Commit in progress - no       */
                                             /* int's                         */
#define SQLE_RC_ROLLINP -1055                /* Rollback in progress - no     */
                                             /* int's                         */
#define SQLE_RC_NOINTER -1360                /* Cannot be interrupted - no    */
                                             /* int's                         */
#define SQLE_RC_TIMEOUT 1361                 /* Windows Client Execution      */
                                             /* Timeout                       */
#define SQLE_RC_MAXSCAN -1056                /* Maximum allowable scans       */
                                             /* exceeded                      */
#define SQLE_RC_NODENTRY 1057                /* No entries in directory       */
#define SQLE_RC_INVHAND -1058                /* Invalid input handle          */
#define SQLE_RC_NOSCAN -1059                 /* Open scan not issued          */

#define SQLE_RC_NOCONNECT -1060              /* User lacks connect privilege  */
#define SQLE_RC_RESTART_WITH_INDOUBTS 1061   /* RESTART was successful, but   */
                                             /* indoubt transactions exist    */
#define SQLE_RC_BADPATH -1062                /* Database path not found       */
#define SQLE_RC_START_OK -1063               /* Database manager started OK   */
#define SQLE_RC_STOP_OK -1064                /* Database manager stopped OK   */
#define SQLE_RC_DB_BADBINDS 1065             /* N utilities not bound         */

#define SQLE_RC_NOMSG_DB2OS2 -1068           /* Message file not found - OS   */
                                             /* 2                             */
#define SQLE_RC_NOMSG_DB2NT -1068            /* Message file not found - NT   */
#define SQLE_RC_NOMSG_DB2DOS -1068           /* Message file not found - DOS  */
#define SQLE_RC_NOMSG_DB2WIN -1068           /* Message file not found -      */
                                             /* Windows                       */
#define SQLE_RC_NOMSG_DB2MAC -1068           /* Message file not found -      */
                                             /* MacOS                         */
#define SQLE_RC_NOMSG_DB2AIX -10007          /* Message file not found - AIX  */

#define SQLE_RC_NOMSG  SQLE_RC_NOMSG_DB2AIX

#define SQLE_RC_INVDROP -1069                /* DB invalid type for Drop      */

#define SQLE_RC_INVDBNAME_PTR -1070          /* Invalid Database Name         */
                                             /* pointer                       */
#define SQLE_RC_INVALIAS_PTR -1071           /* Invalid Alias pointer         */
#define SQLE_RC_RESOURCE_ERROR -1072         /* Resources in inconsistent     */
                                             /* state                         */
#define SQLE_RC_BAD_ND_REL -1073             /* Invalid Node Directory        */
                                             /* release                       */
#define SQLE_RC_INVPSW_PTR -1074             /* Invalid Password pointer      */
#define SQLE_RC_INVCOMM_PTR -1075            /* Invalid Comment pointer       */
#define SQLE_RC_INVCNT_PTR -1076             /* Invalid Count pointer         */
#define SQLE_RC_INVHAND_PTR -1077            /* Invalid Handle pointer        */
#define SQLE_RC_INVBUFF_PTR -1078            /* Invalid Buffer pointer        */
#define SQLE_RC_INVNODE_PTR -1079            /* Invalid Node pointer          */
#define SQLE_RC_INVUSERID_PTR -1150          /* Invalid Userid pointer        */

#define SQLE_RC_INVLLU_PTR -1080             /* Invalid Local Lu pointer      */
#define SQLE_RC_INVRLU_PTR -1081             /* Invalid Remote Lu pointer     */
#define SQLE_RC_INVMODE_PTR -1082            /* Invalid Mode pointer          */
#define SQLE_RC_BAD_DBDB -1083               /* Bad Database Description      */
                                             /* Block                         */
#define SQLE_RC_KSEGSFAIL -1084              /* Cannot Allocate Kernel        */
                                             /* Segments                      */
#define SQLE_RC_APPHEAPFAIL -1085            /* Cannot Allocate Application   */
                                             /* heap                          */
#define SQLE_RC_OS2ERROR -1086               /* Unexpected OS/2 error         */
#define SQLE_RC_BIND_LIST 1087               /* Bind list could not be        */
                                             /* opened                        */
#define SQLE_RC_BIND_ERROR 1088              /* Error occurred during bind    */
#define SQLE_RC_BIND_INTRRPT 1089            /* Binding was interrupted       */

#define SQLE_RC_BAD_APP_REL -1090            /* Release number of appl is     */
                                             /* invalid                       */
#define SQLE_RC_BAD_DB_REL -1091             /* Release number of database    */
                                             /* bad                           */

#define SQLE_RC_INSAUTH -1092                /* Authorization error           */
#define SQLE_RC_NOLOGON -1093                /* User not logged on            */
#define SQLE_RC_NDBUSY -1094                 /* Node directory being updated  */
#define SQLE_RC_MAX_NDSCAN -1095             /* Max node scans open           */
#define SQLE_RC_REQTYPE -1096                /* Invalid type for requester    */
                                             /* node                          */
#define SQLE_RC_NODERR -1097                 /* Node not found for remote db  */
#define SQLE_RC_APCONN_SAME -1098            /* Appl is already connected to  */
                                             /* db                            */

#define SQLE_RC_WRPROT_ERR_DB2OS2 -1099      /* Write protect error on        */
                                             /* diskette                      */
#define SQLE_RC_WRPROT_ERR_DB2NT -1099       /* Write protect error on        */
                                             /* diskette                      */
#define SQLE_RC_WRPROT_ERR_DB2DOS -1099      /* Write protect error on        */
                                             /* diskette                      */
#define SQLE_RC_WRPROT_ERR_DB2WIN -1099      /* Write protect error on        */
                                             /* diskette                      */
#define SQLE_RC_WRPROT_ERR_DB2MAC -1099      /* Write protect error on        */
                                             /* diskette                      */
#define SQLE_RC_WRPROT_ERR_DB2AIX -10021     /* Write protect error on        */
                                             /* filesystem                    */

#define SQLE_RC_WRPROT_ERR SQLE_RC_WRPROT_ERR_DB2AIX

#define SQLE_RC_NODE_WARN 1100               /* Node not cataloged for        */
                                             /* database                      */
#define SQLE_RC_REMCONN_ERR -1101            /* Remote communications error   */
#define SQLE_RC_MIG_NODB -1102               /* No database name provided in  */
                                             /* call                          */
#define SQLE_RC_MIG_OK 1103                  /* Migration was successful      */
#define SQLE_RC_INVPROG_PTR -1104            /* Invalid program name pointer  */

#define SQLE_RC_INV_SPDB_DB2OS2 -1105        /* Invalid disconnect from       */
                                             /* database                      */
#define SQLE_RC_INV_SPDB_DB2NT -1105         /* Invalid disconnect from       */
                                             /* database                      */
#define SQLE_RC_INV_SPDB_DB2DOS -1105        /* Invalid disconnect from       */
                                             /* database                      */
#define SQLE_RC_INV_SPDB_DB2WIN -1105        /* Invalid disconnect from       */
                                             /* database                      */
#define SQLE_RC_INV_SPDB_DB2MAC -1105        /* Invalid disconnect from       */
                                             /* database                      */
#define SQLE_RC_INV_SPDB_DB2AIX -10017       /* Invalid disconnect from       */
                                             /* database                      */

#define SQLE_RC_INV_SPDB SQLE_RC_INV_SPDB_DB2AIX

#define SQLE_RC_INVALID_PROC_DB2OS2 -1106    /* Function could not be         */
                                             /* executed                      */
#define SQLE_RC_INVALID_PROC_DB2NT -1106     /* Function could not be         */
                                             /* executed                      */
#define SQLE_RC_INVALID_PROC_DB2DOS -1106    /* Function could not be         */
                                             /* executed                      */
#define SQLE_RC_INVALID_PROC_DB2WIN -1106    /* Function could not be         */
                                             /* executed                      */
#define SQLE_RC_INVALID_PROC_DB2MAC -1106    /* Function could not be         */
                                             /* executed                      */
#define SQLE_RC_INVALID_PROC_DB2AIX -10010   /* Function could not be         */
                                             /* executed                      */

#define SQLE_RC_INVALID_PROC SQLE_RC_INVALID_PROC_DB2AIX

#define SQLE_RC_INTRP_PROC_DB2OS2 -1107      /* Program interrupted - OS/2    */
#define SQLE_RC_INTRP_PROC_DB2NT -1107       /* Program interrupted - NT      */
#define SQLE_RC_INTRP_PROC_DB2DOS -1107      /* Program interrupted - DOS     */
#define SQLE_RC_INTRP_PROC_DB2WIN -1107      /* Program interrupted -         */
                                             /* Windows                       */
#define SQLE_RC_INTRP_PROC_DB2MAC -1107      /* Program interrupted - MacOS   */
#define SQLE_RC_INTRP_PROC_DB2AIX -10011     /* Program interrupted - AIX     */

#define SQLE_RC_INTRP_PROC SQLE_RC_INVALID_PROC_DB2AIX

#define SQLE_RC_SYSERR_PROC_DB2OS2 -1108     /* System error on library load  */
#define SQLE_RC_SYSERR_PROC_DB2NT -1108      /* System error on library load  */
#define SQLE_RC_SYSERR_PROC_DB2DOS -1108     /* System error on library load  */
#define SQLE_RC_SYSERR_PROC_DB2WIN -1108     /* System error on library load  */
#define SQLE_RC_SYSERR_PROC_DB2MAC -1108     /* System error on library load  */
#define SQLE_RC_SYSERR_PROC_DB2AIX -10012    /* System error on library load  */

#define SQLE_RC_SYSERR_PROC SQLE_RC_SYSERR_PROC_DB2AIX

#define SQLE_RC_NOFILE_PROC_DB2OS2 -1109     /* Library could not be loaded   */
#define SQLE_RC_NOFILE_PROC_DB2NT -1109      /* Library could not be loaded   */
#define SQLE_RC_NOFILE_PROC_DB2DOS -1109     /* Library could not be loaded   */
#define SQLE_RC_NOFILE_PROC_DB2WIN -1109     /* Library could not be loaded   */
#define SQLE_RC_NOFILE_PROC_DB2MAC -1109     /* Library could not be loaded   */
#define SQLE_RC_NOFILE_PROC_DB2AIX -10013    /* Library could not be loaded   */

#define SQLE_RC_NOFILE_PROC SQLE_RC_NOFILE_PROC_DB2AIX

#define SQLE_RC_ERROR_PROC -1110             /* Program error                 */

#define SQLE_RC_BADPGN_PROC_DB2OS2 -1111     /* Invalid DARI prog name        */
                                             /* format                        */
#define SQLE_RC_BADPGN_PROC_DB2NT -1111      /* Invalid DARI prog name        */
                                             /* format                        */
#define SQLE_RC_BADPGN_PROC_DB2DOS -1111     /* Invalid DARI prog name        */
                                             /* format                        */
#define SQLE_RC_BADPGN_PROC_DB2WIN -1111     /* Invalid DARI prog name        */
                                             /* format                        */
#define SQLE_RC_BADPGN_PROC_DB2MAC -1111     /* Invalid DARI prog name        */
                                             /* format                        */
#define SQLE_RC_BADPGN_PROC_DB2AIX -10014    /* Invalid DARI prog name        */
                                             /* format                        */

#define SQLE_RC_BADPGN_PROC SQLE_RC_BADPGN_PROC_DB2AIX

#define SQLE_RC_INSMEM_PROC_DB2OS2 -1112     /* Insuf memory to load lib      */
#define SQLE_RC_INSMEM_PROC_DB2NT -1112      /* Insuf memory to load lib      */
#define SQLE_RC_INSMEM_PROC_DB2DOS -1112     /* Insuf memory to load lib      */
#define SQLE_RC_INSMEM_PROC_DB2WIN -1112     /* Insuf memory to load lib      */
#define SQLE_RC_INSMEM_PROC_DB2MAC -1112     /* Insuf memory to load lib      */
#define SQLE_RC_INSMEM_PROC_DB2AIX -10015    /* Insuf memory to load lib      */

#define SQLE_RC_INSMEM_PROC SQLE_RC_INSMEM_PROC_DB2AIX

#define SQLE_RC_SQLDA_DATATYPE -1113         /* Data type in output SQLDA     */
                                             /* changed                       */
#define SQLE_RC_SQLDA_LENGTH -1114           /* Data length in output SQLDA   */
                                             /* changed                       */
#define SQLE_RC_SQLDA_VARS -1115             /* Num of sqlvars changed in     */
                                             /* SQLDA                         */
#define SQLE_RC_BKP_PEND -1116               /* Backup pending                */
#define SQLE_RC_ROLLFWD_PEND -1117           /* Roll forward pending          */
#define SQLE_RC_BKP_INPROG -1118             /* Need to rerun the Backup      */
                                             /* process                       */
#define SQLE_RC_RST_INPROG -1119             /* Need to rerun the Restore     */
                                             /* process                       */
#define SQLE_RC_BR_INPROG -1120              /* Need to rerun either Backup   */
                                             /* or Restore process            */

#define SQLE_RC_INVNODESTR_PTR -1121         /* Invalid Node structure        */
                                             /* pointer                       */
#define SQLE_RC_INVPROTOCOL_PTR -1122        /* Invalid Protocol structure    */
                                             /* pointer                       */
#define SQLE_RC_INVPROTOCOL -1123            /* Invalid protocol type         */
#define SQLE_RC_INVRNNAME -1124              /* Invalid remote workstation    */
                                             /* name                          */
#define SQLE_RC_INVADAPTER -1125             /* Invalid adapter number        */
#define SQLE_RC_INVNETID -1126               /* Invalid network id            */
#define SQLE_RC_INVPLU -1127                 /* Invalid real partner LU name  */

#define SQLE_RC_DARI_INSSYS -1129            /* Insuf system resources for    */
                                             /* DARI                          */
#define SQLE_RC_DARI_MAXDARI -1130           /* Max DARI process limit        */
                                             /* reached                       */
#define SQLE_RC_DARI_ABEND -1131             /* DARI process abnormally       */
                                             /* terminated                    */
#define SQLE_RC_DARI_INV_RQST -1132          /* Invalid DB2 request in DARI   */
#define SQLE_RC_DARI_VAR_POINTER_CHG -1133   /* SQLVAR's sqldata or sqlind    */
                                             /* ptrs were altered             */
#define SQLE_RC_DARI_RQST_AUTH_ERR -1134     /* DB2 request is not allowed    */
                                             /* when DB auth is client        */
#define SQLE_RC_BAD_NUMSEGS -1135            /* Invalid numsegs on create db  */
#define SQLE_RC_BAD_EXTSIZE -1136            /* Invalid extSize on create db  */
#define SQLE_RC_MOUNTED_SEGS -1137           /* Mounted Segment Directories   */
                                             /* on a drop database request    */

#define SQLE_RC_INVOS_OBJ -1200              /* Invalid object specified      */
#define SQLE_RC_INVOS_STAT -1201             /* Invalid status specified      */
#define SQLE_RC_INVOS_NOSTAT -1202           /* Status has not been           */
                                             /* collected                     */
#define SQLE_RC_INVOS_NOUSER -1203           /* No users connected to         */
                                             /* database                      */
#define SQLE_RC_UNSUPP_CODEPG -1204          /* Active codepage is not        */
                                             /* supported                     */

#define SQLE_RC_INV_CNTRYINFO_DB2OS2 -1205   /* Invalid country information   */
#define SQLE_RC_INV_CNTRYINFO_DB2NT -1205    /* Invalid country information   */
#define SQLE_RC_INV_CNTRYINFO_DB2DOS -1205   /* Invalid country information   */
#define SQLE_RC_INV_CNTRYINFO_DB2WIN -1205   /* Invalid country information   */
#define SQLE_RC_INV_CNTRYINFO_DB2MAC -1205   /* Invalid country information   */
#define SQLE_RC_INV_CNTRYINFO_DB2AIX -10009  /* Invalid country information   */

#define SQLE_RC_INV_CNTRYINFO SQLE_RC_INV_CNTRYINFO_DB2AIX

#define SQLE_RC_NO_SHRD_SEG -1220            /* DB2 Shared Memory Set alloc   */
                                             /* failed                        */
#define SQLE_RC_NO_ASL_HEAP -1221            /* ASL heap cannot be allocated  */
#define SQLE_RC_ASL_TOO_SMALL -1222          /* ASL heap is too small         */
#define SQLE_RC_NO_AGENT_AVAIL -1223         /* No more agents available      */
#define SQLE_RC_AGENT_GONE -1224             /* DB2 agent not active          */
#define SQLE_RC_PROC_LIMIT -1225             /* Op. Sys. couldn't spawn a     */
                                             /* process                       */

#define SQLE_RC_AGENT_NOT_FORCED 1230        /* At least one agent not        */
                                             /* forced                        */
#define SQLE_RC_INVCOUNT -1231               /* Invalid Force Users count     */
#define SQLE_RC_INVFRCE_MODE -1232           /* Invalid Force Users mode      */

#define SQLE_RC_INV_TBS_DESC -1241           /* Invalid TableSpace            */
                                             /* descriptor                    */

#define SQLE_RC_NO_SETCONNOPT -1246          /* Cannot set connection         */
                                             /* options - existing            */
                                             /* connections                   */

#define SQLE_RC_NOUEXIT -1267                /* db2uexit file not found       */

#define SQLC_RC_NPIPE_BROKEN               -1281
#define SQLC_RC_NPIPE_BUSY                 -1282
#define SQLC_RC_NPIPE_PIPE_INUSE           -1283
#define SQLC_RC_NPIPE_PIPE_NOT_FOUND       -1284
#define SQLC_RC_NPIPE_INVALID_NAME         -1285
#define SQLC_RC_NPIPE_NO_RESOURCE          -1286
#define SQLC_RC_NPIPE_INST_NOT_FOUND       -1287

#define SQLE_RC_DS_FAILED -1291              /* Directory Services failed     */
#define SQLE_RC_DS_BAD_GLB_NAME -1292        /* Bad global name               */
#define SQLE_RC_DS_BAD_GLB_DIR_ENTRY -1293   /* Bad global directory entry    */
#define SQLE_RC_DS_BAD_DIR_PATH_NAME -1294   /* Bad DIR_PATH_NAME             */
#define SQLE_RC_DS_BAD_ROUTE_NAME -1295      /* Bad ROUTE_OBJ_NAME            */
#define SQLE_RC_DS_UNSUPPORTED_CMD -1297     /* Command not supported         */

#define SQLE_RC_FILEDCS -1310                /* DCS Directory file access     */
                                             /* error                         */
#define SQLE_RC_DCSDIR_NF -1311              /* DCS Directory not found       */
#define SQLE_RC_NO_ENTRY 1312                /* DCS Directory is empty        */
#define SQLE_RC_MAX_ENTRY -1313              /* DCS Directory is full         */
#define SQLE_RC_INVENTRY_PTR -1314           /* Entry parameter pointer       */
                                             /* invalid                       */
#define SQLE_RC_INVLDB -1315                 /* Local DB name has invalid     */
                                             /* chars                         */
#define SQLE_RC_LDB_NF -1316                 /* DCS Directory entry not       */
                                             /* found                         */
#define SQLE_RC_DUPLDB -1317                 /* DCS Directory duplicate       */
                                             /* entry                         */
#define SQLE_RC_INVLENGTH -1318              /* Invalid element length        */
#define SQLE_RC_ENTRYNOT_COL -1319           /* Entries have not been         */
                                             /* collected                     */

#define SQLE_RC_GDBUSY -1320                 /* Cannot access DCS Dir at      */
                                             /* this time                     */
#define SQLE_RC_INVSTRUCT_ID -1321           /* Invalid structure ID          */
#define SQLE_RC_DRDANSP -1325                /* Remote function not           */
                                             /* supported                     */
#define SQLE_RC_ACCD   -1326                 /* File or directory access      */
                                             /* denied                        */
#define SQLE_RC_IMPLCONN_INVDB -1327         /* Implicit connect - invalid    */
                                             /* dbname                        */
#define SQLE_RC_IMPLCONN_NODB -1328          /* Implicit connect - alias not  */
                                             /* found                         */
#define SQLE_RC_PATH_TOO_LONG -1329          /* Input path too long           */

#define SQLE_RC_INVSDNAME -1330              /* Invalid symbolic destination  */
                                             /* name                          */
#define SQLE_RC_INVSTYPE -1331               /* Invalid CPIC security type    */
#define SQLE_RC_INV_HOSTNAME -1332           /* Invalid Host Name             */
#define SQLE_RC_INV_SERNAME -1333            /* Invalid Service Name          */

#define SQLE_RC_DOUBLE_REMOTE -1334          /* Double-hops not allowed       */
#define SQLE_RC_INVAR  -1335                 /* AR name has invalid chars     */

#define SQLE_RC_UNKNOWN_FILESERVER -1340     /* File server is unknown        */
#define SQLE_RC_INV_FSERVER -1342            /* Invalid File Server           */
#define SQLE_RC_INV_OBJNAME -1343            /* Invalid Object Name           */

#define SQLE_RC_BR_ACTIVE -1350              /* Backup or Restore is active   */

#define SQLE_RC_INV_INSTANCE -1390           /* Invalid Instance Name         */
#define SQLE_RC_INSTANCE_USING -1391         /* Another Instance is using     */
                                             /* the DB                        */
#define SQLE_RC_INV_DB2PATH -1393            /* Invalid DB2 Path Name         */

#define SQLE_RC_BAD_AUTH -1400               /* Unsupported authentication    */
                                             /* type                          */
#define SQLE_RC_DIFF_AUTH -1401              /* Authentication types do not   */
                                             /* match                         */
#define SQLE_RC_AUTH_ERR -1402               /* Authentication failed due to  */
                                             /* unexpected error              */
#define SQLE_RC_AUTH_FAILURE -1403           /* Invalid user name and/or      */
                                             /* password                      */
#define SQLE_RC_PASSWORD_EXPIRED -1404       /* Password has expired          */
#define SQLE_RC_PASSWORD_WITHOUT_USERID    -1425   /* Password without        */
                                                   /* userid                  */
#define SQLE_RC_DB2INSTDFT_ERROR -1426       /* Error getting DB2INSTDFT      */
#define SQLE_RC_NOT_INSTANCE_ATTACHED -1427  /* No current attachment         */
#define SQLE_RC_WRONG_ATTACH -1428           /* Attached to wrong instance    */
#define SQLE_RC_RELPATH_NOT_ALLOWED -1431    /* Relative path not allowed     */
#define SQLE_RC_WRONG_CONNECT -1433          /* Connected to wrong database   */

#define SQLE_RC_INVREGINFO_PTR -1450         /* Invalid registration info.    */
                                             /* ptr.                          */
#define SQLE_RC_REG_INVNODE -1451            /* Reg. issued from invalid      */
                                             /* node                          */
#define SQLE_RC_INVREGLOC -1452              /* Invalid registration          */
                                             /* location                      */
#define SQLE_RC_INVCFG_FSNAME -1453          /* Invalid file server in DBM    */
                                             /* cfg.                          */
#define SQLE_RC_INVCFG_OBJNAME -1454         /* Invalid object name in DBM    */
                                             /* cfg.                          */
#define SQLE_RC_INVCFG_IPXSOCKET -1455       /* Invalid IPX socket in DBM     */
                                             /* cfg.                          */
#define SQLE_RC_DUPLICATE_OBJNAME -1456      /* Object name already exists    */
#define SQLE_RC_NWDS_CONNEXISTS -1457        /* NWDS connection exists,       */
                                             /* cannot log into NW            */
                                             /* fileserver                    */
#define SQLE_RC_REG_NOT_NEEDED -1458         /* DB2 server reg./dereg. not    */
                                             /* needed                        */

#define SQLE_RC_UNSUPP_FUNCTION -1650        /* Function is no longer         */
                                             /* supported                     */

#define SQLE_RC_INV_SCHEMA -1700             /* Invalid Schema name found     */
#define SQLE_RC_DB_NOT_MIGR -1701            /* DB cannot be migrated         */
#define SQLE_RC_CRT_EVENT_FAIL -1703         /* Fail to create db2event dir   */
#define SQLE_RC_DB_MIG_FAIL -1704            /* DB migration failed           */
#define SQLE_RC_UPDATE_DIR_FAIL 1705         /* Fail to update directory      */
                                             /* entry                         */

#define SQLE_RC_DB_ACTIVATED 1490            /* DB is already activated       */
#define SQLE_RC_DB_NOT_STOPPED -1491         /* DB is still active            */
#define SQLE_RC_DB_NOT_ACTIVATED -1492       /* DB is not active              */
#define SQLE_RC_APP_IS_CONNECTED -1493       /* Application is connected to   */
                                             /* a database                    */
#define SQLE_RC_COMM_FAILED 5043             /* Communications support        */
                                             /* failed                        */

#define SQLE_RC_DB2_SERVER_LICENSE -8000     /* No DB2/6000 license           */
#define SQLE_RC_DB2_LICENSE -8001            /* Out of DB2 client licenses    */
#define SQLE_RC_DDCS_LICENSE -8002           /* Out of DDCS clients           */
#define SQLE_RC_TRYBUY_STARTED -8006         /* Evaluation period initiated   */
#define SQLE_RC_TRYBUY -8007                 /* n days left in evaluation     */
                                             /* period                        */

/******************************************************************************
** 
** The following functions and symbols are obsolete and may not be supported
** in future releases. The obsolete functions are provided for backward compatibility
** and exported from DB2API.LIB. All applications should be migrated to use new APIs.
** Note: Some of the function parameters may be NO-OP.
**       Some structures are larger (eg. SQLEDINFO) in V2.
** 
*******************************************************************************/
#define SQLE_RC_BAD_SEGPAGES -1136           /* Invalid numsegs on create db  */

#define SQLE_RC_CS_LICENSE -8003             /* No CS/6000 license            */
#define SQLE_RC_SNA_LICENSE -8004            /* No SNA/6000 license           */

#define SQL_AUTHENTICATION_UNDEF 255         /* Authentication Undefined      */

SQL_API_RC SQL_API_FN                        /* CREATE DATABASE               */
  sqledbcr_api (
        _SQLOLDCHAR *,                       /* database                      */
        _SQLOLDCHAR *,                       /* drive/path                    */
        struct sqledbdesc *,                 /* db description block          */
        unsigned short,                      /* authentication                */
        struct sqledbcinfo *,                /* database country info         */
        struct sqlca *);                     /* SQLCA                         */

/******************************************************************************
** 
** End of obsolete functions and symbols
** 
*******************************************************************************/
#pragma options align=reset

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLENV */
*/
#k  i  $        0x  	R1	R1ZU1         0  0x      ./usr/lpp/db2_02_01/include/sqlstate.h .                    $          /******************************************************************************
** 
** Source File Name: sqlstate
** 
** (C) COPYRIGHT International Business Machines Corp. 1991, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function: Include File defining:
**             Labels for the SQL Council's SQL States
** 
** Operating System: AIX
** 
** 
** The last five bytes of the SQLCA contain a diagnostic code called
** SQLSTATE, which is consistent across all IBM SQL products.  The first
** character of SQLSTATE indicates whether the execution of the SQL
** statement was successful or unsuccessful ('0' or not).  The first two
** characters of SQLSTATE represent classes of successful and unsuccessful
** execution conditions (with '00' through '49' reserved for ANS-defined
** classes). The class codes and their meanings are:
** 
** 00  Unqualified Successful Completion
** 01  Warning
** 02  No Data
** 08  Connection exception was detected
** 21  Cardinality Violation
** 22  Data Exception
** 23  Constraint Violation
** 24  Invalid Cursor State
** 26  Invalid SQL Statement Identifier
** 37  Syntax Error
** 40  Serialization Failure
** 42  Authorization Violation
** 51  Invalid Application State
** 52  Duplicate or Undefined Name
** 53  Invalid Operand or Inconsistent Specification
** 54  SQL or Product Limit Exceeded
** 55  Object Not in Prerequisite State
** 56  Miscellaneous SQL or Product Restriction
** 57  Resource Not Available or Operator Intervention
** 58  System Error
** 
*******************************************************************************/
#ifndef SQL_H_SQLSTATE
#define SQL_H_SQLSTATE

#ifdef __cplusplus
extern "C" {
#endif


/* SQLSTATE CLASSES                                                           */

#define SQLSTATE_CLASS_SUCCESS              "00"
#define SQLSTATE_CLASS_WARNING              "01"
#define SQLSTATE_CLASS_NO_DATA              "02"
#define SQLSTATE_CLASS_CONNECT_EXCEPT       "08"
#define SQLSTATE_CLASS_CARDINALITY          "21"
#define SQLSTATE_CLASS_DATA_EXCEPT          "22"
#define SQLSTATE_CLASS_CONSTRAINT           "23"
#define SQLSTATE_CLASS_INV_CURS_STATE       "24"
#define SQLSTATE_CLASS_INV_STMT_ID          "26"
#define SQLSTATE_CLASS_SYNTAX               "37"
#define SQLSTATE_CLASS_SERIALIZATION        "40"
#define SQLSTATE_CLASS_AUTHORZATION         "42"
#define SQLSTATE_CLASS_INV_APP_STATE        "51"
#define SQLSTATE_CLASS_DUP_UNDEF_NAME       "52"
#define SQLSTATE_CLASS_INV_OPERAND          "53"
#define SQLSTATE_CLASS_LIMIT                "54"
#define SQLSTATE_CLASS_PREREQ_STATE         "55"
#define SQLSTATE_CLASS_MISC_RESTRICT        "56"
#define SQLSTATE_CLASS_RESOURCE             "57"
#define SQLSTATE_CLASS_SYSTEM_ERROR         "58"

/* SQLSTATES                                                                  */

#define SQL_EXEC_OK                         "00000"
#define SQL_WARN_DISCONNECT_ERR             "01002"
#define SQL_WARN_NULL_VAL_ELIMINATED        "01003"
#define SQL_WARN_VAL_TRUNC                  "01004"
#define SQL_WARN_INSUFF_ITEM_DESCRIPT       "01005"
#define SQL_WARN_STR_TRUNC                  "01501"
#define SQL_WARN_NULLS_ELIM                 "01502"
#define SQL_WARN_COLS_TOOMANY               "01503"
#define SQL_WARN_STMT_NOWHERE               "01504"
#define SQL_WARN_STMT_NOTEXEC               "01505"
#define SQL_WARN_DATE_ADJ                   "01506"
#define SQL_WARN_CURSOR_NOT_BLOCKED         "01509"
#define SQL_WARN_CHAR_SUB                   "01517"
#define SQL_WARN_VAR_NOWNULL                "01520"
#define SQL_WARN_TABLE_UNDEF                "01522" /* Planned                */
#define SQL_WARN_ISO_ESCAL                  "01526"
#define SQL_WARN_REG_NOTEXIST               "01527" /* Planned                */
#define SQL_WARN_WHERE_IGNORE               "01528" /* Planned                */
#define SQL_WARN_NAME_UNDEF                 "01532" /* Planned                */
#define SQL_WARN_USE_SBCS_CHARS_ONLY        "01539"
#define SQL_WARN_OP_NOPRIV                  "01542" /* Planned                */
#define SQL_WARN_REF_IGNORE                 "01543"
#define SQL_WARN_NAME_INTERP                "01545"
#define SQL_WARN_OBJ_NOPRIV                 "01548"
#define SQL_WARN_PACK_PRIV                  "01549" /* Planned                */
#define SQL_WARN_INDEX_EXIST                "01550"
#define SQL_WARN_NEWLOGPATH_INV             "01562"
#define SQL_WARN_CURR_LOGPATH_INV           "01563"
#define SQL_WARN_AUTO_CHECK_PEND_STATE      "01586"
#define SQL_WARN_KEYWORD_REDUNDANT          "01589"
#define SQL_WARN_VAL_MAY_BE_TRUNC           "01592"
#define SQL_WARN_VAL_COULD_BE_TRUNC         "01593"
#define SQL_WARN_INSUFF_DESCRIPTORS         "01594"
#define SQL_WARN_OLD_VIEW_REPLACED          "01595"
#define SQL_WARN_NO_COMPFUNC_FOR_LSTR       "01596"
#define SQL_WARN_EVMON_STATE_NOT_SET        "01598"
#define SQL_WARN_REBIND_OPTS_IGNORED        "01599"
#define SQL_WARN_CONN_DISABLED              "01601"
#define SQL_WARN_SUB_OPTIMAL_QUERY          "01602"
#define SQL_WARN_CONSTRAINT_VIO_MOVED       "01603"
#define SQL_WARN_EXPLAIN_MODE_RESTRICT      "01604"
#define SQL_WARN_POSSIBLE_INFINIT_LOOP      "01605"
#define SQL_WARN_DIR_EMPTY                  "01606"
#define SQL_WARN_CLAUSE_VAL_REPLACED        "01608"
#define SQL_WARN_UDF_RETURNS_STATE          "01Hxx"
#define SQL_NODATA_EXCEPTION                "02000"
#define SQL_NODATA_UHOLE                    "02501" /* Planned                */
#define SQL_NODATA_DHOLE                    "02502" /* Planned                */
#define SQL_INV_NUM_HOST_VARS               "07001"
#define SQL_INV_PARM_OR_CB                  "07002"
#define SQL_INV_EXECUTE_STMT                "07003"
#define SQL_USING_CLAUSE_REQUIRED           "07004"
#define SQL_INV_PREP_STMT_CURSOR            "07005"
#define SQL_HOSTVAR_NOT_USABLE              "07006"
#define SQL_CONN_FAILED                     "08001"
#define SQL_CONN_ALREADY_EXIST              "08002"
#define SQL_CONN_DOES_NOT_EXIT              "08003"
#define SQL_CONN_REJECTED_BY_SERVER         "08004"
#define SQL_CONN_FAILED_NO_TM               "08502"
#define SQL_TRIGGER_ERROR                   "09000"
#define SQL_PROC_NOT_CONNECTABLE            "0A001"
#define SQL_LOB_NOVALUE_TOKEN_VAR           "0F001"
#define SQL_CARD_VALUE_TOOMANY              "21000"
#define SQL_CARD_INS_MULTIROW               "21501"
#define SQL_CARD_UPD_MULTIROW               "21502"
#define SQL_CARD_DEL_MULTIROW               "21504"
#define SQL_DATA_CHAR_RTRUNC                "22001"
#define SQL_DATA_INDICATOR_NULL             "22002"
#define SQL_DATA_NUM_RANGE                  "22003"
#define SQL_DATA_FETCH_INV                  "22006" /* Planned                */
#define SQL_DATA_FORMAT_INV                 "22007"
#define SQL_DATA_DATETIME_OV                "22008"
#define SQL_DATA_STR_RANGE                  "22011"
#define SQL_DATA_DIV_ZERO                   "22012"
#define SQL_DATA_INV_CAST_CHAR              "22018"
#define SQL_DATA_LIKE_INV_CHAR              "22019" /* Planned                */
#define SQL_DATA_NULL_MISSING               "22024"
#define SQL_DATA_LIKE_INV_ESC               "22025"
#define SQL_DATA_LENGTH_RANGE               "22501"
#define SQL_DATA_STR_INV                    "22503"
#define SQL_DATA_DATA_BADFORM               "22504"
#define SQL_DATA_DATETIME_REG_INV           "22506"
#define SQL_DATA_TYPE_CANTUSE               "22507"
#define SQL_DATA_TYPE_INCOMPAT              "22509"
#define SQL_HOSTVAR_NEG_INDVAR              "22512"
#define SQL_DATA_INDEX_DUP                  "22515"
#define SQL_DATA_STR_CANTUSE_XLATE          "22517"
#define SQL_DATA_STR_CANTASGN_XLATE         "22518"
#define SQL_DATA_KEY_NOTEQUAL               "22520"
#define SQL_DATA_CCSIDVAL_INV               "22522"
#define SQL_DATA_CONVERSION_TRUNC           "22524"
#define SQL_CONSTR_CHG_KEY_NOTALLOW         "23001"
#define SQL_CONSTR_ROW_NOTSATISFY_VIEW      "23501"
#define SQL_CONSTR_NULL_NOTALLOW            "23502"
#define SQL_CONSTR_VALUE_INV                "23503"
#define SQL_CONSTR_OP_RESTRICT              "23504"
#define SQL_CONSTR_INDEX_UNIQUE             "23505"
#define SQL_CONSTR_PAR_ROW_DEL_NOALLOW      "23511"
#define SQL_CONSTR_ROW_INVALID              "23512"
#define SQL_CONSTR_ROW_NONCONFORM           "23513"
#define SQL_CONSTR_VIOLATIONS               "23514"
#define SQL_CONSTR_DUP_KEY_VALUES           "23515"
#define SQL_CONSTR_FOREIGN_KEY_NOALLOW      "23520"
#define SQL_CONSTR_UPDATE_CAT_STATS         "23521"
#define SQL_CURSOR_NOTOPEN                  "24501"
#define SQL_CURSOR_OPEN_ALREADY             "24502"
#define SQL_CURSOR_NOTPOS                   "24504"
#define SQL_CURSOR_OPEN_NO_COMMIT           "24505"
#define SQL_CURSOR_PD_OPEN                  "24506"
#define SQL_CURSOR_DELETED                  "24507" /* Planned                */
#define SQL_CURSOR_DHOLE                    "24510" /* Planned                */
#define SQL_CURSOR_UHOLE                    "24511" /* Planned                */
#define SQL_CURSOR_AGREE                    "24512" /* Planned                */
#define SQL_CURSOR_MOVED                    "24513" /* Planned                */
#define SQL_INV_EXECUTION_ENVIRONMENT       "25000" /* Planned                */
#define SQL_ONLY_AS_FIRST_STATEMENT         "25501" /* Planned                */
#define SQL_IDENT_NOTEXIST                  "26501"
#define SQL_IDENT_NOASSOC                   "26503"
#define SQL_IDENT_SELECT                    "26504"
#define SQL_IDENT_NOTSPEC                   "26506" /* Planned                */
#define SQL_IDENT_NOTSRSEL                  "26507"
#define SQL_IDENT_NOTSELECT                 "26508" /* Planned                */
#define SQL_IDENT_DUP                       "26509" /* Planned                */
#define SQL_IDENT_HASCURSOR                 "26510" /* Planned                */
#define SQL_INV_AUTHORIZATION_SPEC          "28000"
#define SQL_INV_OPERATION_FOR_ENVIR         "2D521"
#define SQL_DYNAMIC_COMMIT_INVALID          "2D528"
#define SQL_DYNAMIC_ROLLBACK_INVALID        "2D529"
#define SQL_INV_CONN_NAME                   "2E000"
#define SQL_INV_CURSOR_NAME                 "34000"
#define SQL_SYNTAX_TOKEN_MISSING            "37501"
#define SQL_SYNTAX_NAME_INVCHAR             "37502"
#define SQL_SYNTAX_STR_UNTERM               "37503"
#define SQL_SYNTAX_CONST_INV                "37504"
#define SQL_SYNTAX_NUMARGS_INV              "37505"
#define SQL_SYNTAX_HCONST_INV               "37506" /* Planned                */
#define SQL_SYNTAX_OP_INV_COL               "37507"
#define SQL_SYNTAX_OP_MARKER                "37509"
#define SQL_SYNTAX_MARKER_INV               "37510"
#define SQL_SYNTAX_COL_INV                  "37511"
#define SQL_SYNTAX_STMT_BAD                 "37512"
#define SQL_SYNTAX_CLAUSE_EXCLUSIVE         "37513" /* Planned                */
#define SQL_SYNTAX_KEYWORD_DUP              "37514"
#define SQL_SYNTAX_OPT_INV                  "37516" /* Planned                */
#define SQL_SYNTAX_STMT_EMPTY               "37517"
#define SQL_SYNTAX_HOSTVAR_NOTALLOW         "37518"
#define SQL_SYNTAX_READONLY_NOTALLOW        "37520" /* Planned                */
#define SQL_UDF_RETURNS_ERROR_STATE         "38xxx"
#define SQL_UDF_EXCUTE_SQL_NOTALLOW         "38502"
#define SQL_UDF_ABNORMAL_END                "38503"
#define SQL_UDF_INTERRUPTED                 "38504"
#define SQL_UDF_RETURNS_INV_STATE           "39001"
#define SQL_UDF_RETURNS_RESULT_TOOLONG      "39501"
#define SQL_OUT_SQLDA_CHANGED               "39502"
#define SQL_SERIAL_ROLLBACK                 "40000"
#define SQL_ROLLBK_AUTOMATIC                "40001"
#define SQL_STMT_COMPLETION_UNKNOWN         "40003"
#define SQL_ROLLBK_DIST_ENV                 "40502"
#define SQL_ROLLBK_CONN_LOST                "40504"
#define SQL_ACCESS_AUTH_NOTPRIV_OBJ         "42501"
#define SQL_ACCESS_AUTH_NOTPRIV_OP          "42502"
#define SQL_ACCESS_AUTH_NOT_AUTHORIZED      "42503"
#define SQL_ACCESS_PRIV_CANTREVOKE          "42504"
#define SQL_ACCESS_AUTH_FAIL_CONNECTION     "42505"
#define SQL_ACCESS_AUTH_FAIL_OWNER          "42506"
#define SQL_ACCESS_AUTH_FAIL_SERVER         "42507"
#define SQL_ACCESS_PRIV_CANTPUBLIC          "42508"
#define SQL_SYNTAX_KEYWORD_INCOMPAT         "42601"
#define SQL_SYNTAX_INVALID                  "42601"
#define SQL_INVALID_CHAR_IN_NAME            "42602"
#define SQL_UNTERMINATED_STRING_CONST       "42603"
#define SQL_INVALID_NUM_OR_STR_CONST        "42604"
#define SQL_INVALID_NUM_ARGS                "42605"
#define SQL_INVALID_HEX_CONST               "42606"
#define SQL_INVALID_COL_FUNC_OPERAND        "42607"
#define SQL_INV_USE_OF_NULL_OR_DFLT         "42608"
#define SQL_ALL_OPERANDS_PARM_MARKERS       "42609"
#define SQL_PARAMETER_MARKERS_INVALID       "42610"
#define SQL_SYNTAX_LEN_SCALE_INV            "42611"
#define SQL_STMT_NOT_IN_CONTEXT             "42612"
#define SQL_SYNTAX_KEYWORD_CONFLICT         "42613"
#define SQL_DUP_KEYWORD_INV                 "42614"
#define SQL_INV_ALTERNATIVE                 "42615"
#define SQL_STMT_STR_BLANK_OR_EMPTY         "42617"
#define SQL_HOST_VAR_NOT_ALLOWED            "42618"
#define SQL_CHECK_CONSTRAINT_INVALID        "42621"
#define SQL_NAME_OR_LABEL_IS_TOO_LONG       "42622"
#define SQL_CASE_RES_NOT_EXPRESSION         "42625"
#define SQL_DUP_COL_IN_INS_OR_UPD           "42701"
#define SQL_COLUMN_NAME_AMBIGUOUS           "42702"
#define SQL_UNDEFINED_COLUMN_NAME           "42703"
#define SQL_NAME_OBJECT_UNDEF               "42704"
#define SQL_NAME_SERVER_UNDEFINED           "42705"
#define SQL_UNNAMED_COLS_IN_RESULT_TBL      "42706"
#define SQL_NAME_NOT_IN_RESULT_TABLE        "42707"
#define SQL_NAME_DUP_COL_IN_KEY             "42709"
#define SQL_NAME_DUP_OBJ_NAME               "42710"
#define SQL_NAME_DUP_COL_NAME               "42711"
#define SQL_NAME_DUP_IN_FROM_CLAUSE         "42712"
#define SQL_NAME_NODE_NOT_FOUND_IN_DIR      "42720"
#define SQL_NAME_DUP_SIGNATURE              "42723"
#define SQL_ACCESS_UNABLE                   "42724"
#define SQL_NAME_AMBIGUOUS                  "42725"
#define SQL_DUP_DERIVED_TABLE_NAME          "42726"
#define SQL_NEED_DEFAULT_PRIM_TBLSPACE      "42727"
#define SQL_CONTNR_NAME_USEDBY_ANOTHER      "42730"
#define SQL_CONTNR_NAME_USED                "42731"
#define SQL_DUP_SCHEMA_NAME_IN_PATH         "42732"
#define SQL_NUM_INSERTS_INVALID             "42802"
#define SQL_COLUMN_REF_INVALID              "42803"
#define SQL_CASE_RES_NOT_COMPATIBLE         "42804"
#define SQL_ORDER_BY_INT_NOT_IN_RESULT      "42805"
#define SQL_DATA_TYPES_INCOMPAT             "42806"
#define SQL_OPERATION_NOTPERMIT_ON_OBJ      "42807"
#define SQL_COLUMN_NOT_UPDATEABLE           "42808"
#define SQL_STATEMENT_NOT_APPLICABLE        "42809"
#define SQL_FOREIGN_KEY_HAS_VIEW            "42810"
#define SQL_NUM_COLS_NOT_MATCH_SELECT       "42811"
#define SQL_VIEW_NOTALLOW_WITH_CHECK        "42813"
#define SQL_SYNTAX_LANG_TYPE_INV            "42815"
#define SQL_INV_USE_DATATIME_OR_DUR         "42816"
#define SQL_OPERANDS_NOT_COMPATIBLE         "42818"
#define SQL_NUMBER_IS_REQUIRED              "42819"
#define SQL_NUM_CONST_OUT_OF_RANGE          "42820"
#define SQL_VALUE_INCOMPAT_WITH_COLUMN      "42821"
#define SQL_BAD_GROUP_ORDER_BY_EXPR         "42822"
#define SQL_MULT_COLS_IN_SELECT_SUBQ        "42823"
#define SQL_LIKE_OPERAND_INVALID            "42824"
#define SQL_UNION_OPERANDS_COL_INCOMP       "42825"
#define SQL_NUM_COLUMNS_DO_NOT_MATCH        "42826"
#define SQL_TABLE_DIFFERS_FROM_CURSOR       "42827"
#define SQL_TABLE_CANNOT_BE_MODIFIED        "42828"
#define SQL_CANNOT_MODIFY_RESULT_TBL        "42829"
#define SQL_FOREIGNKEY_NOT_LIKE_PARENT      "42830"
#define SQL_NO_NULLS_ALLOWED_IN_KEY         "42831"
#define SQL_AUTH_OPER_SYSOBJ_NOTALLOW       "42832"
#define SQL_NULL_VALUE_NOTALLOW             "42834"
#define SQL_UDF_INVALID_HANDLE_PLACED       "42835"
#define SQL_RECURS_NAME_DERIVE_TBL_INV      "42836"
#define SQL_INV_USE_OF_TABLESPACE           "42838"
#define SQL_MUST_USE_SAME_TABLESPACE        "42839"
#define SQL_AS_CAST_USE_ERROR               "42840"
#define SQL_PARM_MARKER_INV_NAME            "42841"
#define SQL_SYNTAX_TYPE_OPT_INV             "42842"
#define SQL_INV_BOOL_IN_SELECT_LIST         "42844"
#define SQL_INV_VARIANT_FUNCTION            "42845"
#define SQL_INV_CAST                        "42846"
#define SQL_PRIVS_INV_OR_INCONSIST          "42852"
#define SQL_SYNTAX_TYPE_NOTMATCH            "42866"
#define SQL_CANNOT_QUALIFY_COLUMN           "42877"
#define SQL_SYNTAX_XTERN_NAME_INV           "42878"
#define SQL_SYNTAX_FUNC_SRC_NOTMATCH        "42879"
#define SQL_SYNTAX_CAST_ERROR               "42880"
#define SQL_NAME_SCHEMA_DIFF                "42882"
#define SQL_NAME_FUNC_SIGNATURE_UNDEF       "42883"
#define SQL_NAME_FUNC_ARGUMENT_UNDEF        "42884"
#define SQL_SYNTAX_PARM_NUM_NOTMATCH        "42885"
#define SQL_TABLE_HAS_NO_PRIMKEY            "42888"
#define SQL_PRIMARY_KEY_ALREADY_EXIST       "42889"
#define SQL_NOT_UNIQUE_CONSTRAINT_COLS      "42890"
#define SQL_OBJ_DEPENDS_ON_THIS             "42893"
#define SQL_DEFAULT_VALUE_INV               "42894"
#define SQL_SYNTAX_HOSTVAR_TYPE_INCOMP      "42895"
#define SQL_INV_CORRELATION_REF             "42898"
#define SQL_CORRELATION_REF_NOT_ALLOW       "42899"
#define SQL_ERROR_IN_UDF                    "428A0"
#define SQL_NOACCESS_HOSTFILE_VAR_FILE      "428A1"
#define SQL_EVMON_BAD_PATH_SPECIFIED        "428A3"
#define SQL_EVMON_BAD_OPTION_SPECIFIED      "428A4"
#define SQL_INV_EXCEPTION_TABLE             "428A5"
#define SQL_EXCEP_TBL_SAME_AS_CHK_TBL       "428A6"
#define SQL_NUM_CHECK_TBLS_MISMATCH         "428A7"
#define SQL_PARENT_TBL_IN_CHCK_PEND_ST      "428A8"
#define SQL_CONTNR_PATH_NM_NOT_VALID        "428B2"
#define SQL_INV_SQLSTATE_FROM_APP           "428B3"
#define SQL_COL_FUNC_NEEDS_COL_NAME         "42901"
#define SQL_OBJECT_ALSO_IN_FROM_CLAUSE      "42902"
#define SQL_WHERE_OR_SET_HAS_INV_REF        "42903"
#define SQL_STRING_IS_TOO_LONG              "42907"
#define SQL_COLUMN_LIST_MISSING             "42908"
#define SQL_INVALID_DECIMAL_DIVIDE          "42911"
#define SQL_COLUMN_NOT_IN_UPD_CLAUSE        "42912"
#define SQL_UPDATE_OR_DELETE_INVALID        "42913"
#define SQL_TABLE_IN_SUBQUERY_AFFECTED      "42914"
#define SQL_INV_REFERENTIAL_CONSTRAINT      "42915"
#define SQL_REP_CHAIN_ALIAS_INVALID         "42916"
#define SQL_CANNOT_EXPLICITLY_DROP_OBJ      "42917"
#define SQL_NAME_RESERVED                   "42918"
#define SQL_CANNOT_ADD_CONTAINERS           "42921"
#define SQL_REC_NAME_DER_TLB_SPEC_INV       "42925"
#define SQL_PROG_ASSUMPTIONS_INCORRECT      "42932"
#define SQL_AUTH_CREATE_SYSOBJ_NOALLOW      "42939"
#define SQL_INV_USE_LONG_COLUMN             "42962"
#define SQL_NO_SW_LICENSE                   "42968"
#define SQL_INV_CONN_RESET                  "42986"
#define SQL_STMT_INV_FOR_STORPROC_TRIG      "42987"
#define SQL_SYNTAX_SYSTEM_USE_ONLY          "42991"
#define SQL_LOB_COL_TOO_BIG_TO_LOG          "42993"
#define SQL_RAW_DEVICE_NOT_SUPP             "42994"
#define SQL_VIEW_DEF_NOT_SATISFIED          "44000"
#define SQL_STATE_CALL_INV                  "51001"
#define SQL_STATE_PACKAGE_NOTFOUND          "51002"
#define SQL_STATE_TOKENS_NOTMATCH           "51003"
#define SQL_STATE_ADDR_INV_DA               "51004"
#define SQL_STATE_STMT_NOTEXEC              "51007"
#define SQL_STATE_RELEASE_INV               "51008"
#define SQL_STATE_PROC_NOTCONNECTABLE       "51011"
#define SQL_STATE_SECTION_BINDERR           "51015"
#define SQL_STATE_USER_NOTLOGGEDON          "51017"
#define SQL_STATE_APP_UNCONNECTED           "51018"
#define SQL_STATE_CRTPACK_BUSY              "51019" /* Planned                */
#define SQL_STATE_PACK_NONE                 "51020" /* Planned                */
#define SQL_ROLLBACK_REQUIRED               "51021"
#define SQL_CONN_WITH_AUTH_ALREADY          "51022"
#define SQL_STATE_DB_INUSE_ANOTH_INST       "51023"
#define SQL_INOPERAITVE_VIEW                "51024"
#define SQL_CONN_SETTINGS_IN_USE            "51025"
#define SQL_EVMON_PATH_INUSE                "51026"
#define SQL_IMMEDIATE_CHECKED_OPT_INV       "51027"
#define SQL_PACKAGE_INOPERATIVE             "51028"
#define SQL_NAME_COL_DUP_STMT               "52001"
#define SQL_NAME_COLREF_DUP_NAME            "52002"
#define SQL_NAME_COL_UNDEF                  "52003"
#define SQL_NAME_OBJ_UNDEF                  "52004"
#define SQL_NAME_SERVER_UNDEF               "52005"
#define SQL_NAME_COL_INV                    "52006"
#define SQL_NAME_COL_NOTRESULT              "52007"
#define SQL_NAME_CURSOR_UNDEF               "52008"
#define SQL_NAME_COL_DUP_KEYCLAUSE          "52009"
#define SQL_NAME_OBJ_DUP                    "52010"
#define SQL_NAME_COL_DUP_OBJDEF             "52011"
#define SQL_NAME_TABLE_DUP                  "52012"
#define SQL_NAME_CURSOR_DUP                 "52013" /* Planned                */
#define SQL_NAME_CURSOR_NOTQUAL             "52015" /* Planned                */
#define SQL_NAME_COLREF_DUP_SET             "52016" /* Planned                */
#define SQL_NAME_AS_NONAME                  "52017"
#define SQL_NAME_CURSOR_UNDECL              "52019" /* Planned                */
#define SQL_NAME_NODE_NOTFOUND              "52020"
#define SQL_NAME_REG_UNKNOWN                "52021" /* Planned                */
#define SQL_OPSPEC_NUMVAL_NOTSAME           "53002"
#define SQL_OPSPEC_COLUMN_INV               "53003"
#define SQL_OPSPEC_CLAUSE_NOTCOLUMN         "53005"
#define SQL_OPSPEC_OP_NOTPERMIT             "53007"
#define SQL_OPSPEC_COL_NOTUPDATABLE         "53008"
#define SQL_OPSPEC_OBJ_WRONGTYPE            "53009"
#define SQL_OPSPEC_CLAUSE_ISVIEW            "53010"
#define SQL_OPSPEC_NUMCOL_NOTSAME           "53011"
#define SQL_OPSPEC_OPTION_BAD               "53013"
#define SQL_OPSPEC_DATA_INV                 "53015"
#define SQL_OPSPEC_DATETIME_INV_EXPR        "53016"
#define SQL_OPSPEC_NUMVAR_NOTSAME           "53017"
#define SQL_OPSPEC_OPERANDS_NOTCOMPAT       "53018"
#define SQL_OPSPEC_OP_NOTNUMB               "53019"
#define SQL_OPSPEC_CONS_TOOLONG             "53020"
#define SQL_OPSPEC_VAL_NOTCOMPAT_COL        "53021"
#define SQL_OPSPEC_CLAUSE_TOOMANY           "53023"
#define SQL_OPSPEC_LIKEOP_BAD               "53024"
#define SQL_OPSPEC_UNIONOP_INCOMPAT_COL     "53025"
#define SQL_OPSPEC_UNIONOP_BADNUM_COL       "53026"
#define SQL_OPSPEC_TABLE_NOTSAME_CURSOR     "53027"
#define SQL_OPSPEC_TABLE_CANTMODIFY         "53028"
#define SQL_OPSPEC_UPDATE_INV_ROTABLE       "53029"
#define SQL_OPSPEC_FKEY_NOTCONFORM          "53030"
#define SQL_OPSPEC_NULL_NOTALLOW            "53031"
#define SQL_OPSPEC_OP_NOTALLOW_SYSOBJ       "53032"
#define SQL_OPSPEC_FKEY_NOTALLOW_NULL       "53034"
#define SQL_OPSPEC_COL_INV                  "53042"
#define SQL_OPSPEC_PRIV_INV                 "53052"
#define SQL_OPSPEC_OPT_BOTH                 "53053" /* Planned                */
#define SQL_OPSPEC_AUTH_BAD                 "53056"
#define SQL_OPSPEC_STMT_CANTUSE             "53059" /* Planned                */
#define SQL_OPSPEC_DB_CANTUSE               "53061"
#define SQL_OPSPEC_STMT_CANTEXEC            "53062" /* Planned                */
#define SQL_OPSPEC_HOSTVAR_UNDEF            "53063"
#define SQL_OPSPEC_INFO_NOTMATCH            "53064" /* Planned                */
#define SQL_OPSPEC_OPTIONS_CONFLICT         "53067" /* Planned                */
#define SQL_OPSPEC_DESCRIPTORS_TOOFEW       "53070" /* Planned                */
#define SQL_OPSPEC_NUMSTRUCTS_NOTMATCH      "53071" /* Planned                */
#define SQL_OPSPEC_CLAUSE_INCOMPAT          "53072" /* Planned                */
#define SQL_OPSPEC_NUMROWS_INV              "53073" /* Planned                */
#define SQL_LIMIT_STMT_TOOLONG              "54001"
#define SQL_LIMIT_SCONST_TOOLONG            "54002"
#define SQL_LIMIT_NAME_TOOLONG              "54003"
#define SQL_LIMIT_NAMES_TOOMANY             "54004"
#define SQL_LIMIT_CONCAT_TOOLONG            "54006"
#define SQL_LIMIT_AS_TOOBIG                 "54007" /* Planned                */
#define SQL_LIMIT_KEY_TOOLONG               "54008"
#define SQL_LIMIT_TABLE_TOOLONG             "54010"
#define SQL_LIMIT_COLS_TOOMANY              "54011"
#define SQL_LIMIT_DESCRIPTORS_TOOMANY       "54019"
#define SQL_LIMIT_ARGUMENTS_TOOMANY         "54023"
#define SQL_LIMIT_CONCUR_LOB_HANDLES        "54028"
#define SQL_LIMIT_OPEN_DIR_SCANS            "54029"
#define SQL_LIMIT_EVMON_TOOMANY             "54030"
#define SQL_LIMIT_EVTFILES_TOOMANY          "54031"
#define SQL_LIMIT_MAX_TABLE_SIZE            "54032"
#define SQL_LIMIT_CONTNR_NAMES_LEN          "54034"
#define SQL_LIMIT_TBLSPACE_SIZE             "54035"
#define SQL_LIMIT_CONTNR_PATH_LEN           "54036"
#define SQL_LIMIT_CONTAIN_MAP_COMPLX        "54037"
#define SQL_LIMIT_CASCADED_TRIGGERS         "54038"
#define SQL_LIMIT_CONTAINER_SIZE            "54039"
#define SQL_LIMIT_TRANSITION_TBL            "54040"
#define SQL_STATE_DB_NOTMIGR                "55001"
#define SQL_STATE_EXPL_TBL_NOT_DEFINED      "55002"
#define SQL_STATE_OBJ_INUSE                 "55006"
#define SQL_STATE_OBJ_NOTALTER              "55007"
#define SQL_STATE_TABLE_NOKEY               "55008"
#define SQL_STATE_FILE_READONLY             "55009"
#define SQL_STATE_OBJ_HASDEPS               "55010" /* Planned                */
#define SQL_STATE_TABLE_HASKEY              "55013"
#define SQL_STATE_REFRESH_RUNNING           "55022" /* Planned                */
#define SQL_CHK_CONSTRAINT_TOO_LONG         "55024"
#define SQL_STATE_DB_NEEDRESTART            "55025"
#define SQL_TRIGGER_DEF_TOO_LONG            "55026"
#define SQL_STATE_OS2_RESERVED              "55031" /* Planned                */
#define SQL_CONN_INV_DBM_STOPPED            "55032" /* Planned                */
#define SQL_MUST_COMMIT_FOR_EVMON           "55033"
#define SQL_EVMON_ACTIVE_CANT_DROP          "55034"
#define SQL_INV_STATE_CHANGE                "55039"
#define SQL_REBALANCE_IN_PROGRESS           "55041"
#define SQL_MISC_NONAME                     "56001"
#define SQL_MISC_FROM_INV                   "56002"
#define SQL_MISC_WHERE_INV                  "56003"
#define SQL_MISC_DISTINCT_TOOMANY           "56005"
#define SQL_MISC_STR_TOOLONG                "56007"
#define SQL_MISC_LIST_MISSING               "56008"
#define SQL_MISC_DIVIDE_NEG                 "56011"
#define SQL_MISC_COL_NOUPDATE               "56012"
#define SQL_MISC_UPDDEL_INV                 "56013"
#define SQL_MISC_DEL_INV                    "56014"
#define SQL_MISC_CONSTR_INV                 "56015"
#define SQL_MISC_OBJECT_NODROP              "56017"
#define SQL_MISC_INV_COMM_ROLL              "56021"
#define SQL_MISC_REF_INV                    "56023" /* Planned                */
#define SQL_MISC_ALIAS_NOTTABLE             "56024" /* Planned                */
#define SQL_MISC_OP_INV                     "56026"
#define SQL_MISC_MIXED_DBCS_INV             "56031"
#define SQL_MISC_PREP_INV                   "56032"
#define SQL_MISC_OBJ_NOTCRT                 "56039"
#define SQL_MISC_PACKAGE_NOTCOMMIT          "56043" /* Planned                */
#define SQL_MISC_NAME_NOTID                 "56052" /* Planned                */
#define SQL_MISC_DATA_NOTSUPP               "56059" /* Planned                */
#define SQL_MISC_STMT_NOTEXEC               "56060" /* Planned                */
#define SQL_MISC_NAME_NOTMATCH              "56061"
#define SQL_MISC_ISO_NOTUSER                "56068"
#define SQL_MISC_JOIN_BADCOLS               "56072" /* Planned                */
#define SQL_MISC_NAME_REQUIRED              "56073" /* Planned                */
#define SQL_MISC_NAME_NOTQUAL               "56074" /* Planned                */
#define SQL_LOB_NOSUPP_IN_DRDA              "56084"
#define SQL_MISC_N_A_COMPOUND_SQL_ERR       "56091"
#define SQL_MISC_NAME_BOTH_USER_GROUP       "56092"
#define SQL_MISC_NO_BLOB_IN_DWNLVL_CL       "56093"
#define SQL_MISC_NOT_ALIGNED                "56097"
#define SQL_RESOURCE_PENDING                "57007"
#define SQL_RESOURCE_VSDB_TUNAVAIL          "57009"
#define SQL_RESOURCE_VSDB_UNAVAIL           "57011"
#define SQL_RESOURCE_NONDB_UNAVAIL_CONT     "57012"
#define SQL_RESOURCE_NONDB_UNAVAIL_STOP     "57013"
#define SQL_RESOURCE_CANCEL                 "57014"
#define SQL_RESOURCE_TABLE_INACTIVE         "57016"
#define SQL_RESOURCE_CXLATE_NOTDEF          "57017"
#define SQL_RESOURCE_DRIVE_NOTEXIST         "57019"
#define SQL_RESOURCE_DRIVE_LOCKED           "57020"
#define SQL_RESOURCE_DRIVE_OPEN             "57021"
#define SQL_RESOURCE_MAXAPPS                "57030"
#define SQL_RESOURCE_MAXDB                  "57032"
#define SQL_RESOURCE_DB_STARTED             "57033"
#define SQL_RESOURCE_DB_ACQUIRED            "57034"
#define SQL_RESOURCE_DBFILE_NOTOWN          "57035"
#define SQL_RESOURCE_LOG_NOTOWN             "57036"
#define SQL_RESOURCE_STANDALONE             "57041"
#define SQL_RESOURCE_QUIESCE_BACKUP         "57046"
#define SQL_RESOURCE_DIR_NOT_ACCESS         "57047"
#define SQL_RESOURCE_CONTNR_ACC_ERR         "57048"
#define SQL_RESOURCE_SYS_LIMIT              "57049"
#define SQL_RESOURCE_PATH                   "57050"
#define SQL_RESOURCE_DISK_STUFFIT           "57901"
#define SQL_RESOURCE_DISK_BAD               "57902"
#define SQL_RESOURCE_DISK_FULL              "57903"
#define SQL_SYSERR_INV_SECT                 "58003"
#define SQL_SYSERR_ERR_CONT                 "58004"
#define SQL_SYSERR_ERR_STOP                 "58005"
#define SQL_SYSERR_DIST_CONT                "58008"
#define SQL_SYSERR_DIST_DEALLOC             "58009"
#define SQL_SYSERR_DIST_STOP                "58010"
#define SQL_SYSERR_BIND_ACTIVE              "58011"
#define SQL_SYSERR_BIND_INACTIVE            "58012"
#define SQL_SYSERR_CMD_NOTSUPP              "58014"
#define SQL_SYSERR_OBJ_NOTSUPP              "58015"
#define SQL_SYSERR_PARAM_NOTSUPP            "58016"
#define SQL_SYSERR_VALUE_NOTSUPP            "58017"
#define SQL_SYSERR_MSG_NOTSUPP              "58018"
#define SQL_SYSERR_COMMERR                  "58019"
#define SQL_SYSERR_NOTDEF                   "58020"
#define SQL_SYSERR_HOSTVARS                 "58026" /* Planned                */
#define SQL_SYSERR_IOERR                    "58030"
#define SQL_SYSERR_DBFILE                   "58031"
#define SQL_SYSERR_STR_FENCED_FUN_FAIL      "58032"
#define SQL_SYSERR_FIND_TBSP_PG_FAIL        "58034"
#define SQL_SYSERR_FREE_TBSP_PG_FAIL        "58035"
#define SQL_SYSERR_TBLSPC_ID_NOEXIST        "58036"

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLSTATE */
kd m  $        . 
R1
R1ZU1         D  .     ./usr/lpp/db2_02_01/include/sqlutil.h  .                    $          /******************************************************************************
** 
** Source File Name: SQLUTIL
** 
** (C) COPYRIGHT International Business Machines Corp. 1987, 1995
** All Rights Reserved
** Licensed Materials - Property of IBM
** 
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
** 
** Function = Include File defining:
**              Utility / Configuration Commands - Constants
**              Utility / Configuration Commands - Data Structures
**              Utility / Configuration Commands - Function Prototypes
**              Utility / Configuration Commands - Labels for SQLCODES
** 
** Operating System:AIX
** 
*******************************************************************************/
#ifndef SQL_H_SQLUTIL
#define SQL_H_SQLUTIL

#ifdef __cplusplus
extern "C" {
#endif

/* Note: _SQLOLDCHAR defaults to 'char'.  See sqlsystm.h for details.         */

#include "sql.h"                       /* Includes sqlca.h & sqlsystm.h */

#pragma options align=power

/* Interface Parameters/Structures/Return Codes                               */

/* Parameters for Rollforward caller action                                   */
#define SQLUM_ROLLFWD          1       /* Roll forward to requested point     */
#define SQLUM_STOP             2       /* End roll-forward recovery           */
#define SQLUM_ROLLFWD_STOP     3       /* Roll forward to requested point     */
                                       /* and end roll-forward recovery       */
#define SQLUM_QUERY            4       /* Query nextArcFile, firstDeleteArc,  */
                                       /* lastDeleteArc, lastCommitTime       */
#define SQLUM_PARM_CHECK       10      /* Parameter check                     */
#define SQLUM_LOADREC_CONTINUE 11      /* Continue load recovery.             */
#define SQLUM_LOADREC_TERMINATE 12     /* Terminate load recovery.            */
#define SQLUM_LOADREC_DEVICE_TERMINATE 13 /* Terminate device.Caller action   */
                                       /* codes 31 - 35 reserved for          */
                                       /* internal use.                       */

/* Constants used for Rollforward                                             */
#define SQLUM_INFINITY_TIMESTAMP "9999-12-31-23.59.59.999999" /* Roll         */
                                       /* forward until STOP specified        */
#define SQLUM_ARCHIVE_FILE_LEN 12      /* Length of Archive File name         */
#define SQLUM_TIMESTAMP_LEN    26      /* Length of ISO format Timestamp      */

/* Rollforward connect mode                                                   */
#define SQLUM_OFFLINE          0x0     /* Offline rollforward mode            */
#define SQLUM_ONLINE           0x1     /* Online rollforward mode             */

/* Backup backup mode                                                         */
#define SQLUB_OFFLINE          0x0     /* Offline backup mode                 */
#define SQLUB_ONLINE           0x1     /* Online backup mode                  */

/* Backup type                                                                */
#define SQLUB_FULL             0
#define SQLUB_TABLESPACE       3

/* Backup calling action values                                               */
#define SQLUB_BACKUP           0       /* initial call                        */
#define SQLUB_CONTINUE         1       /* Subsequent call                     */
#define SQLUB_TERMINATE        2       /* Terminating call                    */
#define SQLUB_NOINTERRUPT      3       /* Initial call to run without         */
                                       /* prompting                           */
#define SQLUB_DEVICE_TERMINATE 9       /* End media device.                   */
#define SQLUB_PARM_CHECK       10      /* for parameter check only.           */

/* Restore mode                                                               */
#define SQLUD_ROLLFWD          0x0
#define SQLUD_NOROLLFWD        0x1

/* Restore calling action values                                              */
#define SQLUD_RESTORE          0       /* initial call                        */
#define SQLUD_CONTINUE         1       /* Subsequent call                     */
#define SQLUD_TERMINATE        2       /* Terminating call                    */
#define SQLUD_NOINTERRUPT      3       /* Initial call to run without         */
                                       /* prompting                           */
#define SQLUD_DEVICE_TERMINATE 9       /* End media device.                   */
#define SQLUD_PARM_CHECK       10      /* for parameter check only.           */
#define SQLUD_RESTORE_STORDEF  100     /* initial call, tablespace container  */
                                       /* redefinition requested              */

/* Restore type                                                               */
#define SQLUD_FULL             0
#define SQLUD_ONLINE_TABLESPACE 3
#define SQLUD_HISTORY          5
/* The following are not supported in V2.1.0                                  */
#define SQLUD_TABLESPACE_TBL   6
#define SQLUD_HIST_TBLSPACE_TBL 7

/* Backup/Restore Definitions                                                 */
#define SQLU_ALIAS_SZ          8       /* length of database alias name       */
#define SQLU_USERID_LEN        8       /* length of userid                    */
#define SQLU_PWD_LEN           18      /* length of password                  */
#define SQLU_TIME_STAMP_LEN    14      /* length of the backup timestamp in   */
                                       /* yyyymmddhhmmss format               */

/* length of filename of backup image:                                        */
/* dbalias.type.db2instance.node.timestamp.seq                                */
#define SQLU_BACKUP_NAME_SZ    (SQLU_ALIAS_SZ+5+SQLU_USERID_LEN+5+SQLU_TIME_STAMP_LEN+4)

/* length of directory where backup file will reside:dir - '/' - filename     */
#define SQLU_BACKUP_DIR_SZ     (1023-1-SQLU_BACKUP_NAME_SZ)

/* Parameters for Backup/Restore old api's                                    */
#define SQLU_NSD_ID            '0'     /* User exit used, not SD interface    */

/* Media type for old api's                                                   */
#define SQLUB_MEDIA_TARGET     0x0
#define SQLUB_ADSM             0x1
#define SQLUB_OTHER            0x2

/* Old OS/2 Backup/restore media type values                                  */
#define SQLUD_MEDIA_SRC        0x0
#define SQLUD_ADSM             0x1
#define SQLUD_OTHER            0x2

/* Parameters for SQLUHPRN force option                                       */
#define SQLUH_NO_FORCE         0
#define SQLUH_FORCE            1

/* Parameters for SQLUHOPS caller action                                      */
#define SQLUH_LIST_BACKUP      0
#define SQLUH_LIST_HISTORY     1

/* History File structure sizes                                               */
#define SQLUH_OP_SZ            1
#define SQLUH_OBJ_SZ           1
#define SQLUH_OBJPART_SZ       17
#define SQLUH_OPTYPE_SZ        1
#define SQLUH_DEVTYPE_SZ       1
#define SQLUH_FIRSTLOG_SZ      12
#define SQLUH_LASTLOG_SZ       12
#define SQLUH_BACKID_SZ        14
#define SQLUH_TCREATE_SZ       8
#define SQLUH_TNAME_SZ         18
#define SQLUH_NUMTABLESPACE_SZ 5
#define SQLUH_LOC_SZ           255
#define SQLUH_COMMENT_SZ       30
#define SQLUH_TABLESPACENAME_SZ 18

/* Parameters for RUNSTATS                                                    */
#define SQL_STATS_TABLE           'T'  /* TABLEOPT = Table w/o Indexes        */
#define SQL_STATS_BOTH            'B'  /* TABLEOPT = Table and Indexes        */
#define SQL_STATS_INDEX           'I'  /* TABLEOPT = Indexes w/o Table        */
#define SQL_STATS_EXTTABLE_ONLY   'D'  /* TABLEOPT = Table and dist stats     */
#define SQL_STATS_EXTTABLE_INDEX  'E'  /* TABLEOPT = Table and dist stats     */
                                       /* and basic indexes                   */
#define SQL_STATS_EXTINDEX_ONLY   'X'  /* TABLEOPT = Ext stats for indexes    */
                                       /* only                                */
#define SQL_STATS_EXTINDEX_TABLE  'Y'  /* TABLEOPT = Ext stats for indexes    */
                                       /* and basic table stats               */
#define SQL_STATS_ALL             'A'  /* TABLEOPT = Ext stats for indexes    */
                                       /* and table with dist stats           */
#define SQL_STATS_REF             'R'  /* SHAREOPT = Reference                */
#define SQL_STATS_CHG             'C'  /* SHAREOPT = Change                   */

#define SQLU_STATS_NONE           ' '  /* TABLEOPT - no statistics are to be  */
                                       /* gathered - Load only                */

/* Parameters for selection method in sqldcol                                 */
#define SQL_METH_N             78      /* Names                               */
#define SQL_METH_P             80      /* Positional                          */
#define SQL_METH_D             68      /* Default                             */
#define SQL_METH_L             76      /* Locations                           */

/* File Types for Import/Export                                               */
#define SQL_IXF                "IXF"
#define SQL_WSF                "WSF"
#define SQL_DEL                "DEL"
#define SQL_ASC                "ASC"
#define SQL_DB2CS              "DB2CS" /* load/unload                         */

/* Client Communication Protocols                                             */
#define SQLF_PROTOCOL_TCPIP    "TCPIP"
#define SQLF_PROTOCOL_APPC     "APPC"

/* Import/Export/Load/Unload calling action values                            */
#define SQLU_INITIAL           0x0     /* Initial call                        */
#define SQLU_CONTINUE          0x1     /* Subsequent call                     */
#define SQLU_TERMINATE         0x2     /* Terminating call                    */
#define SQLU_NOINTERRUPT       0x3     /* Initial call - Load/Unload only     */
#define SQLU_ABORT             0x4     /* Abort call - Load only              */
#define SQLU_RESTART           0x5     /* Restart call - Load only            */
#define SQLU_DEVICE_TERMINATE  0x9     /* Subsequent call - Load/Unload only  */

/* Actions for quiesce tablespaces for table                                  */
#define SQLU_QUIESCEMODE_SHARE              0
#define SQLU_QUIESCEMODE_INTENT_UPDATE      1
#define SQLU_QUIESCEMODE_EXCLUSIVE          2
#define SQLU_QUIESCEMODE_RESET              9
#define SQLU_QUIESCEMODE_RESET_OWNED        10

/* Equates for Configuration Utilities                                        */

/* Token equates for SQLFupd structure for Kernel config file                 */
#define SQLF_KTN_RQRIOBLK      1
#define SQLF_KTN_NUMDB         6
#define SQLF_KTN_NNAME         7
#define SQLF_KTN_MAXAGENTS     12
#define SQLF_KTN_MAXCAGENTS    13
#define SQLF_KTN_ASLHEAPSZ     15
#define SQLF_KTN_SQLSTMTSZ     17
#define SQLF_KTN_BACKBUFSZ     18
#define SQLF_KTN_RESTBUFSZ     19
#define SQLF_KTN_INDEXREC      20
#define SQLF_KTN_SHEAPTHRES    21
#define SQLF_KTN_MAXDARI       80
#define SQLF_KTN_KEEPDARI      81
#define SQLF_KTN_SVCENAME      24
#define SQLF_KTN_TPNAME        25
#define SQLF_KTN_AGENTPRI      26
#define SQLF_KTN_DFTDBPATH     27

/* tokens for new Version 2.1 parameters                                      */
#define SQLF_KTN_DFT_ACCOUNT_STR  28

/* You may manipulate the bits of SQLF_KTN_DFT_MONSWITCHES or you can enable  */
/* disable, or query the current setting through the individual tokens        */
#define SQLF_KTN_DFT_MONSWITCHES  29
#define SQLF_KTN_DFT_MON_UOW      30   /* Bit 1 of SQLF_KTN_DFT_MONSWITCHES   */
#define SQLF_KTN_DFT_MON_STMT     31   /* Bit 2 of SQLF_KTN_DFT_MONSWITCHES   */
#define SQLF_KTN_DFT_MON_TABLE    32   /* Bit 3 of SQLF_KTN_DFT_MONSWITCHES   */
#define SQLF_KTN_DFT_MON_BUFPOOL  33   /* Bit 4 of SQLF_KTN_DFT_MONSWITCHES   */
#define SQLF_KTN_DFT_MON_LOCK     34   /* Bit 5 of SQLF_KTN_DFT_MONSWITCHES   */
#define SQLF_KTN_DFT_MON_SORT     35   /* Bit 6 of SQLF_KTN_DFT_MONSWITCHES   */

#define SQLF_KTN_SYSADM_GROUP     39
#define SQLF_KTN_DIR_CACHE        40
#define SQLF_KTN_DRDA_HEAP_SZ     41
#define SQLF_KTN_CPUSPEED         42
#define SQLF_KTN_MIN_PRIV_MEM     43
#define SQLF_KTN_PRIV_MEM_THRESH  44
#define SQLF_KTN_MAXTOTFILOP      45
#define SQLF_KTN_FILESERVER       47
#define SQLF_KTN_OBJECTNAME       48
#define SQLF_KTN_QUERY_HEAP_SZ    49

#define SQLF_KTN_MAX_IDLEAGENTS   60
#define SQLF_KTN_AGENT_STACK_SZ   61
#define SQLF_KTN_SYSMAINT_GROUP   62
#define SQLF_KTN_SYSCTRL_GROUP    63

#define SQLF_KTN_DIAGLEVEL        64
#define SQLF_KTN_DIAGPATH         65

#define SQLF_KTN_TP_MON_NAME      66
#define SQLF_KTN_TM_DATABASE      67
#define SQLF_KTN_RESYNC_INTERVAL  68
#define SQLF_KTN_UDF_MEM_SZ       69

#define SQLF_KTN_IPX_SOCKET       71
#define SQLF_KTN_DOS_RQRIOBLK     72

#define SQLF_KTN_DIR_TYPE         73   /* token for directory services        */
#define SQLF_KTN_DIR_PATH_NAME    74   /* token for directory services        */
#define SQLF_KTN_DIR_OBJ_NAME     75   /* token for directory services        */
#define SQLF_KTN_ROUTE_OBJ_NAME   76   /* token for directory services        */
#define SQLF_KTN_DFT_CLIENT_COMM  77   /* token for directory services        */
#define SQLF_KTN_AUTHENTICATION   78
#define SQLF_KTN_MON_HEAP_SZ      79

/* tokens for syncpoint manager                                               */
#define SQLF_KTN_SPM_LOG_FILE_SZ  90
#define SQLF_KTN_SPM_MAX_RESYNC   91
#define SQLF_KTN_SPM_NAME         92

/* tokens for adsm                                                            */
#define SQLF_KTN_ADSM_PASSWORD    93
#define SQLF_KTN_ADSM_NODENAME    94
#define SQLF_KTN_ADSM_OWNER       95

/* equates for diretory type                                                  */
#define SQLF_DIRTYPE_NONE         0
#define SQLF_DIRTYPE_DCE          1

/* tokens for internal parameters                                             */
#define SQLF_KTN_NODETYPE         100
#define SQLF_KTN_RELEASE          101
#define SQLF_KTN_NOTOKEN          200

/* Nodetype equates                                                           */
#define SQLF_NT_STANDALONE        0
#define SQLF_NT_SERVER            1
#define SQLF_NT_REQUESTOR         2
#define SQLF_NT_STAND_REQ         3

/******************************************************************************
** Defines for Database Monitor Switches - SQLF_KTN_DFT_MONSWITCHES
** 
** The following meanings apply when the bits are set on.
** 
** SQLF_ENABLE_MON_UOW     -
** SQLF_ENABLE_MON_STMT    -
** SQLF_ENABLE_MON_TABLE   -
** SQLF_ENABLE_MON_BUFPOOL -
** SQLF_ENABLE_MON_LOCK    -
** SQLF_ENABLE_MON_SORT    -
*******************************************************************************/

#define SQLF_ENABLE_MON_UOW       0x1  /* xxxx xxxx xxxx xxx1                 */
#define SQLF_ENABLE_MON_STMT      0x2  /* xxxx xxxx xxxx xx1x                 */
#define SQLF_ENABLE_MON_TABLE     0x4  /* xxxx xxxx xxxx x1xx                 */
#define SQLF_ENABLE_MON_BUFPOOL   0x8  /* xxxx xxxx xxxx 1xxx                 */
#define SQLF_ENABLE_MON_LOCK      0x10 /* xxxx xxxx xxx1 xxxx                 */
#define SQLF_ENABLE_MON_SORT      0x20 /* xxxx xxxx xx1x xxxx                 */

/* Token equates for SQLFupd structure for DB config file                     */
#define SQLF_DBTN_LOCKLIST        1
#define SQLF_DBTN_BUFF_PAGE       90
#define SQLF_DBTN_MAXFILOP        3
#define SQLF_DBTN_SOFTMAX         5
#define SQLF_DBTN_MAXAPPLS        6
#define SQLF_DBTN_APPLHEAPSZ      51
#define SQLF_DBTN_DBHEAP          50
#define SQLF_DBTN_DLCHKTIME       9
#define SQLF_DBTN_SORT_HEAP       52
#define SQLF_DBTN_MAXLOCKS        15
#define SQLF_DBTN_LOGPRIMARY      16
#define SQLF_DBTN_LOGSECOND       17
#define SQLF_DBTN_LOGFILSIZ       18
#define SQLF_DBTN_STMTHEAP        53
#define SQLF_DBTN_NEWLOGPATH      20
#define SQLF_DBTN_DETS            21
#define SQLF_DBTN_COPY_PROTECT    22
#define SQLF_DBTN_LOG_RETAIN      23
#define SQLF_DBTN_USER_EXIT       24
#define SQLF_DBTN_AUTO_RESTART    25
#define SQLF_DBTN_INDEXREC        30
#define SQLF_DBTN_PCKCACHESZ      31
#define SQLF_DBTN_MINCOMMIT       32
#define SQLF_DBTN_LOGBUFSZ        33

/* tokens for new Version 2.1 parameters                                      */
#define SQLF_DBTN_LOCKTIMEOUT     34
#define SQLF_DBTN_INDEXSORT       35
#define SQLF_DBTN_NUM_FREQVALUES  36
#define SQLF_DBTN_NUM_IOCLEANERS  37
#define SQLF_DBTN_CHNGPGS_THRESH  38
#define SQLF_DBTN_NUM_IOSERVERS   39
#define SQLF_DBTN_DFT_PREFETCH_SZ 40
#define SQLF_DBTN_SEQDETECT       41
#define SQLF_DBTN_DFT_LOADREC_SES 42
#define SQLF_DBTN_REC_HIS_RETENTN 43
#define SQLF_DBTN_COLLATE_INFO    44
#define SQLF_DBTN_STAT_HEAP_SZ    45
#define SQLF_DBTN_DIR_OBJ_NAME    46   /* token for directory services        */
#define SQLF_DBTN_AVG_APPLS       47
#define SQLF_DBTN_NUM_QUANTILES   48
#define SQLF_DBTN_DFT_EXTENT_SZ   54
#define SQLF_DBTN_UTIL_HEAP_SZ    55
#define SQLF_DBTN_CATALOGCACHE_SZ 56
#define SQLF_DBTN_DFT_QUERYOPT    57

/* tokens for internal parameters                                             */
#define SQLF_DBTN_COUNTRY         100
#define SQLF_DBTN_CODEPAGE        101
#define SQLF_DBTN_RELEASE         102
#define SQLF_DBTN_LOGPATH         103
#define SQLF_DBTN_INTFLAGS        104
#define SQLF_DBTN_LOGHEAD         105
#define SQLF_DBTN_NEXTACTIVE      107
#define SQLF_DBTN_CONSISTENT      111
#define SQLF_DBTN_BACKUP_PENDING  112
#define SQLF_DBTN_ROLLFWD_PENDING 113
#define SQLF_DBTN_LOG_RETAIN_STATUS 114
#define SQLF_DBTN_USER_EXIT_STATUS 115
#define SQLF_DBTN_CODESET         120
#define SQLF_DBTN_TERRITORY       121
#define SQLF_DBTN_NUMSEGS         122
#define SQLF_DBTN_DATABASE_LEVEL  124
#define SQLF_DBTN_NOTOKEN         200

/* Index recreate type                                                        */
#define SQLF_INX_REC_SYSTEM       0
#define SQLF_INX_REC_REFERENCE    1
#define SQLF_INX_REC_RESTART      2

/* Special values for configuration defaults                                  */
#define SQLFDMCA                  -1   /* Default maxcagents                  */
#define SQLFDMXD                  -1   /* Default maxdari                     */
#define SQLFDAPR                  -1   /* Default agentpri                    */
#define SQLFMKPD                  0    /* keepdari - no                       */
#define SQLFXKPD                  1    /* keepdari - yes                      */

/******************************************************************************
** You may manipulate the bits of SQLF_DBTN_DETS and SQLF_DBTN_INTFLAGS
** or you can enable, disable, or query the current setting through
** the individual tokens.
** 
** Defines for: SQLF_DBTN_COPY_PROTECT    , SQLF_DBTN_LOG_RETAIN
**              SQLF_DBTN_USER_EXIT       , SQLF_DBTN_AUTO_RESTART
**              SQLF_DBTN_CONSISTENT      , SQLF_DBTN_BACKUP_PENDING
**              SQLF_DBTN_ROLLFWD_PENDING , SQLF_DBTN_LOG_RETAIN_STATUS
**              SQLF_DBTN_USER_EXIT_STATUS
*******************************************************************************/

#define SQLF_DISABLE              0
#define SQLF_ENABLE               1
#define SQLF_ROLLFWD_TABLESPACE   2    /* The third state of rollfwd_pending  */
/******************************************************************************
** Defines for Database Details - SQLF_DBTN_DETS
** 
** The following meanings apply when the bits are set on.
** 
** SQLF_COPY_PROTECT       - Database is copy protected.
** SQLF_ENABLE_LOG_RETAIN  - Next time database is started in normal
**                           conditions, the log files will be retained
**                           for the purpose of roll-forward recovery.
** SQLF_ENABLE_USER_EXIT   - Next time database is started in normal
**                           conditions, the user log exit will be enabled
**                           for the purpose of roll-forward recovery.
** SQLF_ENABLE_AUTO_RESTART- The RESTART DATABASE function will be
**                           invoked when needed.
*******************************************************************************/

#define SQLF_COPY_NOPROT          0x0  /* xxxx xxxx xxxx xxx0                 */
#define SQLF_COPY_PROTECT         0x1  /* xxxx xxxx xxxx xxx1                 */
#define SQLF_ENABLE_LOG_RETAIN    0x2  /* xxxx xxxx xxxx xx1x                 */
#define SQLF_ENABLE_USER_EXIT     0x4  /* xxxx xxxx xxxx x1xx                 */
#define SQLF_ENABLE_AUTO_RESTART  0x8  /* xxxx xxxx xxxx 1xxx                 */

/******************************************************************************
** Defines for Logging Flags    - SQLF_DBTN_INTFLAGS
** 
** The following meanings apply when the bits are set on.
** 
** SQLF_CONSISTENT      - Database is in a consistent state.
** SQLF_BACKUP_PENDING  - User is required to take a backup of the
**                        database before the system will allow the
**                        database to be opened for normal processing.
** SQLF_ROLLFWD_PENDING - User is required to roll forward the database
**                        before the system will allow the database to
**                        be opened for normal processing.
** SQLF_LOG_RETAIN      - Log files are retained so that a database can be
**                        rolled forward after it has been restored from
**                        a backup copy.
** SQLF_USER_EXIT       - User exit is taken when log files are filled and
**                        when log files are needed and not found.
** SQLF_TBS_ROLLFWD     - If the SQLF_ROLLFWD_PENDING bit is off, and this
**                        bit is on, then the tablespace needs to be
**                        rolled forward.
** 
*******************************************************************************/

#define SQLF_CONSISTENT           0x1  /* xxxx xxxx xxxx xxx1                 */
#define SQLF_BACKUP_PENDING       0x4  /* xxxx xxxx xxxx x1xx                 */
#define SQLF_ROLLFWD_PENDING      0x8  /* xxxx xxxx xxxx 1xxx                 */
#define SQLF_LOG_RETAIN           0x10 /* xxxx xxxx xxx1 xxxx                 */
#define SQLF_USER_EXIT            0x20 /* xxxx xxxx xx1x xxxx                 */
#define SQLF_TBS_ROLLFWD          0x40 /* xxxx xxxx x1xx xxxx                 */

#define SQL_TPNAME_SZ             64   /* length of tpname config parm        */

#define SQL_SPM_NAME_SZ           8    /* length of syncpoint manager name    */

#define SQL_LOGPATH_SZ            242  /* max length of log parms             */
#define SQL_LOGFILE_NAME_SZ       12   /* max length of log file name         */
#define SQL_DBPATH_SZ             215  /* max length of db path parm          */
#define SQL_FFDCPATH_SZ           215  /* max length of diagpath parm         */

/* LOAD and UNLOAD defines                                                    */
#define SQLU_LOAD_PHASE        'L'     /* restart at load phase               */
#define SQLU_BUILD_PHASE       'B'     /* restart at build phase              */
#define SQLU_DELETE_PHASE      'D'     /* restart at delete phase             */

SQL_STRUCTURE sqldcoln
{
   short           dcolnlen;
   char            *dcolnptr;
};

SQL_STRUCTURE sqldcol
{
   short           dcolmeth;
   short           dcolnum;
   struct sqldcoln dcolname[1];   /* actual size must be dcolnum              */
};

/* Structure for Pairs of Locations for ASC files                             */
SQL_STRUCTURE sqllocpair
{
   short           begin_loc;
   short           end_loc;
};

SQL_STRUCTURE sqlloctab
{
   struct sqllocpair locpair[1];  /* actual size must be dcolnum              */
};

/* Structures for Input and Output Data for Import and Export                 */

SQL_STRUCTURE sqluimpt_in
{
   unsigned long   sizeOfStruct;
   unsigned long   commitcnt;
   unsigned long   restartcnt;
};

SQL_STRUCTURE sqluimpt_out
{
   unsigned long   sizeOfStruct;
   unsigned long   rowsRead;
   unsigned long   rowsSkipped;
   unsigned long   rowsInserted;
   unsigned long   rowsUpdated;
   unsigned long   rowsRejected;
   unsigned long   rowsCommitted;
};

SQL_STRUCTURE sqluexpt_out
{
   unsigned long   sizeOfStruct;
   unsigned long   rowsExported;
};

#define SQLUIMPT_IN_SIZE       sizeof(struct sqluimpt_in)
#define SQLUIMPT_OUT_SIZE      sizeof(struct sqluimpt_out)
#define SQLUEXPT_OUT_SIZE      sizeof(struct sqluexpt_out)

/* Structures for Input and Output Data for Load and Unload                   */

SQL_STRUCTURE sqluload_in
{
   unsigned long   sizeOfStruct;
   unsigned long   savecnt;
   unsigned long   restartcnt;
   unsigned long   rowcnt;
   unsigned long   warningcnt;
   unsigned long   data_buffer_size;
   unsigned long   sort_buffer_size;
   unsigned short  hold_quiesce;
   char            restartphase;
   char            statsopt;
};

SQL_STRUCTURE sqluload_out
{
   unsigned long   sizeOfStruct;
   unsigned long   rowsRead;
   unsigned long   rowsSkipped;
   unsigned long   rowsLoaded;
   unsigned long   rowsRejected;
   unsigned long   rowsDeleted;
   unsigned long   rowsCommitted;
};

SQL_STRUCTURE sqluunld_in
{
   unsigned long   sizeOfStruct;
   unsigned long   data_buffer_size;
   unsigned long   sort_buffer_size;
   unsigned short  hold_quiesce;
   unsigned short  intent_update;
   unsigned short  serial_write;
   unsigned short  num_buffers;
   unsigned short  reorg_lobs;
   unsigned short  filler;
};

SQL_STRUCTURE sqluunld_out
{
   unsigned long   sizeOfStruct;
   unsigned long   rowsUnloaded;
};

#define SQLULOAD_IN_SIZE       sizeof(struct sqluload_in)
#define SQLULOAD_OUT_SIZE      sizeof(struct sqluload_out)
#define SQLUUNLD_IN_SIZE       sizeof(struct sqluunld_in)
#define SQLUUNLD_OUT_SIZE      sizeof(struct sqluunld_out)

/* Constants and Structures for the Asynchronous Read Log API                 */

#define SQLU_RLOG_READ         1       /* read the database log               */
#define SQLU_RLOG_READ_SINGLE  2       /* read a single log record            */
#define SQLU_RLOG_QUERY        3       /* query the database log              */

typedef union SQLU_LSN
{
   unsigned char   lsnChar[6];         /* 6 byte character representation     */
   unsigned short  lsnWord[3];         /* 6 byte short representation         */
} SQLU_LSN;

typedef SQL_STRUCTURE SQLU_RLOG_INFO
{
   SQLU_LSN        initialLSN;         /* initial lsn at first connect        */
   SQLU_LSN        firstReadLSN;       /* first lsn read on call              */
   SQLU_LSN        lastReadLSN;        /* last lsn read on call               */
   SQLU_LSN        curActiveLSN;       /* current active lsn                  */
   unsigned long   logRecsWritten;     /* number of log records returned      */
   unsigned long   logBytesWritten;    /* number of log bytes returned        */
} SQLU_RLOG_INFO;

/* Structures for Configuration Utility APIs.                                 */

SQL_STRUCTURE sqlfupd
{
   unsigned short  token;
   char            *ptrvalue;
};

/* Constants and structure used by sqlgadau and sqluadau.                     */
#define SQL_USER_AUTHORIZED                 1
#define SQL_USER_UNAUTHORIZED               0
#define SQL_AUTHORIZATION_SIZE_OLD          22
#define SQL_AUTHORIZATION_SIZE              34

SQL_STRUCTURE sql_authorizations
{
   short           sql_authorizations_len;
   short           sql_sysadm_auth;
   short           sql_dbadm_auth;
   short           sql_createtab_auth;
   short           sql_bindadd_auth;
   short           sql_connect_auth;
   short           sql_sysadm_grp_auth;
   short           sql_dbadm_grp_auth;
   short           sql_createtab_grp_auth;
   short           sql_bindadd_grp_auth;
   short           sql_connect_grp_auth;
   short           sql_sysctrl_auth;
   short           sql_sysctrl_grp_auth;
   short           sql_sysmaint_auth;
   short           sql_sysmaint_grp_auth;
   short           sql_create_not_fenc_auth;
   short           sql_create_not_fenc_grp_auth;
};

/* Constants and structure used for backup and restore                        */
#define SQLU_MAX_TBS_NAME_LEN     18
#define SQLU_DB_DIR_LEN           215
#define SQLU_SHR_LIB_LEN          255
#define SQLU_MEDIA_LOCATION_LEN   255
#define SQLU_APPLID_LEN           32
#define SQLU_MAX_SESSIONS         999

typedef SQL_STRUCTURE sqlu_tablespace_entry
{
   unsigned long   reserve_len;
   char            tablespace_entry[SQLU_MAX_TBS_NAME_LEN+1];
   char            filler[1];
} sqlu_tablespace_entry;

typedef SQL_STRUCTURE sqlu_tablespace_bkrst_list
{
   long            num_entry;
   struct sqlu_tablespace_entry *tablespace;
} sqlu_tablespace_bkrst_list;

typedef SQL_STRUCTURE sqlu_media_entry
{
   unsigned long   reserve_len;
   char            media_entry[SQLU_DB_DIR_LEN+1];
} sqlu_media_entry;

typedef SQL_STRUCTURE sqlu_vendor
{
   unsigned long   reserve_len1;
   char            shr_lib[SQLU_SHR_LIB_LEN+1];
   unsigned long   reserve_len2;
   char            filename[SQLU_SHR_LIB_LEN+1];
} sqlu_vendor;

typedef SQL_STRUCTURE sqlu_location_entry
{
   unsigned long   reserve_len;
   char            location_entry[SQLU_MEDIA_LOCATION_LEN+1];
} sqlu_location_entry;

#define SQLU_LOCAL_MEDIA       'L'     /* path/device                         */
#define SQLU_SERVER_LOCATION   'S'     /* remote file/device/named pipe       */
#define SQLU_CLIENT_LOCATION   'C'     /* local file/device/named pipe        */
#define SQLU_ADSM_MEDIA        'A'     /* ADSM                                */
#define SQLU_OTHER_MEDIA       'O'     /* vendor library                      */
#define SQLU_USER_EXIT         'U'     /* user exit                           */
#define SQLU_DISK_MEDIA        'D'     /* Generated only by vendors           */
#define SQLU_DISKETTE_MEDIA    'K'     /* Generated only by vendors           */
#define SQLU_TAPE_MEDIA        'T'     /* Generated only by vendors           */
#define SQLU_PIPE_MEDIA        'P'     /* Generated only by vendors           */

union sqlu_media_list_targets
{
   struct sqlu_media_entry        *media;      /* For media_type L - for      */
                                               /* BACKUP, RESTORE and LOAD    */
                                               /* copytarget, workdirectory,  */
                                               /* lobpaths, IMPORT and        */
                                               /* EXPORT lobpaths             */
   struct sqlu_vendor             *vendor;     /* For media_type O            */
   struct sqlu_location_entry     *location;   /* For media_type S - for      */
                                               /* LOAD and LOAD recovery      */
                                               /* For media type C - for      */
                                               /* EXPORT lobfile              */
};

typedef SQL_STRUCTURE sqlu_media_list
{
   char            media_type;
   char            filler[3];
   long            sessions;
   union sqlu_media_list_targets target;
} sqlu_media_list;

SQL_STRUCTURE sqluhtsp
{
   char            tablespace_name[SQLUH_TABLESPACENAME_SZ+1]; /* tablespace  */
                               /* name                                        */
   char            filler;
};

SQL_STRUCTURE sqluhinfo
{
   char      sqluhinfoid[8];                   /* Eye catcher = 'SQLUHINF'    */
   long      sqluhinfobc;                      /* SQLUHINFO  in bytes=(   )   */
   short     sqln;                             /* Number of tablespace        */
                                               /* elements                    */
   short     sqld;                             /* # of used tablespace        */
                                               /* elements                    */
   char      operation[SQLUH_OP_SZ+1];         /* operation                   */
   char      object[SQLUH_OBJ_SZ+1];           /* object                      */
   char      object_part[SQLUH_OBJPART_SZ+1];  /* object part                 */
   char      optype[SQLUH_OPTYPE_SZ+1];        /* optype                      */
   char      device_type[SQLUH_DEVTYPE_SZ+1];  /* device type                 */
   char      first_log[SQLUH_FIRSTLOG_SZ+1];   /* first log                   */
   char      last_log[SQLUH_LASTLOG_SZ+1];     /* last log                    */
   char      backup_id[SQLUH_BACKID_SZ+1];     /* backup id                   */
   char      table_creator[SQLUH_TCREATE_SZ+1]; /* table creator              */
   char      table_name[SQLUH_TNAME_SZ+1];     /* table name                  */
   char      num_of_tablespaces[SQLUH_NUMTABLESPACE_SZ+1]; /* # of            */
                                               /* tablespaces                 */
   char      location[SQLUH_LOC_SZ+1];         /* location                    */
   char      comment[SQLUH_COMMENT_SZ+1];      /* comment                     */
   struct sqluhtsp tablespace[1];
};

/* Macro for size of sqluhinfo                                                */
#define   SQLUHINFOSIZE(n) \
(sizeof(struct sqluhinfo) + (n-1)*sizeof(struct sqluhtsp))

/* Definitions needed for the sqlb api calls                                  */
/*                                                                            */
/* nb: 'tbs' is an abbreviaton for 'TABLESPACE'                               */

#define SQLB_MAX_TBS_NAME_SZ   128     /* maximum length of a table space     */
                                       /* name                                */
/* NB: this constant is set to the maximum size that is likely to be needed   */
/* in future.  Don't confuse this with SQLU_MAX_TBS_NAME_LEN which is set to  */
/* the current maximum size (18).                                             */

/* Externally visibile flags of a table space                                 */
/* storage manager class                                                      */
#define SQLB_TBS_SMS           0x1     /* System   Managed Space              */
#define SQLB_TBS_DMS           0x2     /* Database Managed Space              */
/* table space contents                                                       */
#define SQLB_TBS_ANY           0x0     /* regular contents                    */
#define SQLB_TBS_LONG          0x20    /* long field data                     */
#define SQLB_TBS_TMP           0x10    /* temp data                           */
/* other flags values                                                         */
#define SQLB_TBS_TMP_RECOVERY  0x20000 /* temp table space is reserved for    */
                                       /* completion of reorg recovery        */

/* The externally visible state of a table space is composed of the           */
/* hexadecimal sum of various of the following state values.  For example if  */
/* the state is 'quiesced exclusive' and 'load pending', the value would be   */
/* 0x0004 + 0x0008 which is 0x000c.                                           */
/*                                                                            */
/* You may use the tool db2tbst to do the reverse calculation (from 0x000c    */
/* to 'load pending' and 'quiesced exclusive', for example) which is more     */
/* complex. In our example, execute:                                          */
/*                                                                            */
/*  db2tbst 0x000c                                                            */
/*                                                                            */
/* which yields:                                                              */
/*                                                                            */
/* State = Quiesced Exclusive                                                 */
/*       + Load Pending                                                       */
#define SQLB_NORMAL                  0x0    /* Normal                         */
#define SQLB_QUIESCED_SHARE          0x1    /* Quiesced: SHARE                */
#define SQLB_QUIESCED_UPDATE         0x2    /* Quiesced: UPDATE               */
#define SQLB_QUIESCED_EXCLUSIVE      0x4    /* Quiesced: EXCLUSIVE            */
#define SQLB_LOAD_PENDING            0x8    /* Load pending                   */
#define SQLB_DELETE_PENDING          0x10   /* Delete pending                 */
#define SQLB_BACKUP_PENDING          0x20   /* Backup pending                 */
#define SQLB_ROLLFORWARD_IN_PROGRESS 0x40   /* Roll forward in progress       */
#define SQLB_ROLLFORWARD_PENDING     0x80   /* Roll forward pending           */
#define SQLB_RESTORE_PENDING         0x100  /* Restore pending                */
#define SQLB_RECOVERY_PENDING        0x100  /* Recovery pending (use SQLB     */
                                            /* RESTORE_PENDING)               */
#define SQLB_DISABLE_PENDING         0x200  /* Disable pending                */
#define SQLB_REORG_IN_PROGRESS       0x400  /* Reorg in progress              */
#define SQLB_BACKUP_IN_PROGRESS      0x800  /* Backup in progress             */
#define SQLB_STORDEF_PENDING         0x1000 /* storage must be defined        */
#define SQLB_RESTORE_IN_PROGRESS     0x2000 /* Restore in progress            */
#define SQLB_STORDEF_ALLOWED         0x2000000 /* storage may be defined      */
#define SQLB_STORDEF_FINAL_VERSION   0x4000000 /* storDef is in 'final'       */
                                            /* state                          */
#define SQLB_STORDEF_CHANGED         0x8000000 /* storDef was changed prior   */
                                            /* to rollforward                 */
#define SQLB_REBAL_IN_PROGRESS       0x10000000 /* dms rebalancer is active   */
#define SQLB_PSTAT_DELETION          0x20000000 /* TBS deletion in progress   */
#define SQLB_PSTAT_CREATION          0x40000000 /* TBS creation in progress   */

/* Provide info about a tableSpace in a database                              */
SQL_STRUCTURE SQLB_TBSQRY_DATA
{
   unsigned long   id;                 /* internal id for the pool            */
   unsigned long   nameLen;            /* length of the name (for cobol &     */
                                       /* other nonC lang.)                   */
   char            name[SQLB_MAX_TBS_NAME_SZ]; /* NUL terminated name         */
   unsigned long   totalPages;         /* DMS : Pages specified by CREATE     */
                                       /* TABLESPACE.                         */
                                       /* SMS : N/A                           */
   unsigned long   useablePages;       /* DMS : totalPages - overhead         */
                                       /* SMS : N/A                           */
   unsigned long   flags;              /* bit attributes for the pool --      */
                                       /* includes 'class' & other stuff to   */
                                       /* be defined                          */
   unsigned long   pageSize;           /* pagesize of tablespace (in          */
                                       /* bytes)..currently fixed at 4K       */
   unsigned long   extSize;            /* extent size (in pages)              */
   unsigned long   prefetchSize;       /* prefetch size                       */
   unsigned long   nContainers;        /* number of containers                */
   unsigned long   tbsState;           /* SQLB_NORMAL, SQLB_LOAD_PENDING,     */
                                       /* etc.                                */
   char            lifeLSN[6];         /* 'timestamp' identifying the origin  */
                                       /* of the tbs                          */
   char            pad[2];             /* for alignment                       */
};

/* container type                                                             */
#define SQLB_CONT_PATH         0       /* SMS: directory path specs           */
#define SQLB_CONT_DISK         1       /* DMS: a 'raw' or 'device' spec       */
#define SQLB_CONT_FILE         2       /* DMS: a 'cooked file' -> file spec   */

/* provide information about the containers on which tablespaces are based    */
SQL_STRUCTURE SQLB_TBSCONTQRY_DATA
{
   unsigned long   id;                 /* container id                        */
   unsigned long   nTbs;               /* num table spaces sharing this       */
                                       /* container (is always 1 for DMS      */
                                       /* tablespaces)                        */
   unsigned long   tbsID;              /* tableSpace id, when 'nTbs' is 1     */
   unsigned long   nameLen;            /* length of name (for non-C lang.)    */
   char            name[SQLB_MAX_CONTAIN_NAME_SZ]; /* null term. name         */
   unsigned long   underDBDir;         /* 1 if container is under the DB      */
                                       /* directory, 0 if not                 */
   unsigned long   contType;           /* SQLB_CONT_PATH/DISK/FILE            */
   unsigned long   totalPages;         /* DMS : Pages specified by CREATE     */
                                       /* TABLESPACE. SMS : N/A               */
   unsigned long   useablePages;       /* DMS : totalPages - overhead SMS :   */
                                       /* N/A                                 */
   unsigned long   ok;                 /* 1 if container is accessible, 0 if  */
                                       /* there is a problem                  */
};

/* provide statistics on a tablespace                                         */
/* BETA NOTE: currently, we only provide stats on DMS tablespaces             */
/* SRSFIX: determine what SMS support to ship with V2                         */
SQL_STRUCTURE SQLB_TBS_STATS
{
   unsigned long   totalPages;         /* DMS : Pages specified by CREATE     */
                                       /* TABLESPACE.                         */
                                       /* SMS : Pages of all files in the     */
                                       /* directories.                        */
   unsigned long   useablePages;       /* DMS : totalPages - overhead         */
                                       /* SMS : same as totalPages            */
   unsigned long   usedPages;          /* DMS : used and allocated pages in   */
                                       /* the pool                            */
                                       /* SMS : same as totalPages            */
   unsigned long   freePages;          /* DMS : useablePages - usedPages      */
                                       /* SMS : N/A                           */
   unsigned long   highWaterMark;      /* DMS : high water mark of used page  */
                                       /* number                              */
                                       /* SMS : N/A                           */
};

/******************************************************************************
** Function proto-types: 'sqlb' prefix for internal use.
** All functions require a database connection, and return
** info about that database.
*******************************************************************************/

/* stsq - Single TableSpace Query                                             */
SQL_API_RC SQL_API_FN                            /* Single Tablespace Query   */
  sqlbstsq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long TablespaceId,                   /* in: tableSpace id         */
   struct SQLB_TBSQRY_DATA * pTablespaceData);   /* out: tableSpace data      */

/* otsq - Open TableSpace Query -> use for retrieving a full list             */
#define SQLB_OPEN_TBS_ALL 0x0                    /* all tablespaces in        */
                                                 /* database                  */
#define SQLB_OPEN_TBS_RESTORE 0x1                /* all tablespaces my agent  */
                                                 /* is restoring              */
#define SQLB_OPEN_TBS_STORDEF 0x2                /* all tablespaces where     */
                                                 /* storage definition is     */
                                                 /* allowed                   */
SQL_API_RC SQL_API_FN                            /* Open Tablespace Query     */
  sqlbotsq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long TablespaceQueryOptions,         /* in: processing options:   */
                                                 /* SQLB_TBS_OPEN_xxx         */
   unsigned long * pNumTablespaces);             /* out: # tablespaces        */
                                                 /* defined in db             */

/* ftsq - Fetch TableSpace Query -> fetch the next block of tbs data          */
SQL_API_RC SQL_API_FN                            /* Fetch Tablespace Query    */
  sqlbftsq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long MaxTablespaces,                 /* max num of tbs the        */
                                                 /* output area can hold      */
   struct SQLB_TBSQRY_DATA * pTablespaceData,    /* out: array of length      */
                                                 /* maxTbs                    */
   unsigned long * pNumTablespaces);             /* out: #data entries        */
                                                 /* returned                  */

/* ctsq - Close TableSpace Query -> terminate the query opened by sqlbotsq    */
SQL_API_RC SQL_API_FN                            /* Close Tablespace Query    */
  sqlbctsq (
   struct sqlca * pSqlca);                       /* SQLCA                     */

/* tsq - TableSpace Query -> uses the above primitives to return the FULL     */
/* list of tablespaces in an array allocated and returned to the              */
/* application.  The application should free this memory with the sqlefmem()  */
/* api when it is finished with it. Even if this api fails with an            */
/* 'insufficient memory' error, 'nTbs' is set to the number of tablespaces    */
/* in the database. 'nTbs' is set to zero if we fail to sucessfully open a    */
/* query. 'tbsData' is returned as NULL (0;no mem alloc) if we fail for any   */
/* reason.                                                                    */
SQL_API_RC SQL_API_FN                            /* Tablespace Query          */
  sqlbtsq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long * pNumTablespaces,              /* out: total number of      */
                                                 /* table spaces              */
   struct SQLB_TBSQRY_DATA ** ppTablespaceData); /* out: mem returned to      */
                                                 /* application               */

/* container level queries.They all accept either a tableSpace id (a single   */
/* tbs) ora special id (SQLB_ALL_TABLESPACES) which triggers the fetchof a    */
/* list of containers for the entire database.                                */

/* constant used in place of tablespace id to indicate all table spaces in    */
/* db                                                                         */
#define SQLB_ALL_TABLESPACES 0xfffe

/* otcq - Open Tablespace Container Query -- prepares for fetching a list of  */
/* container data                                                             */
SQL_API_RC SQL_API_FN                            /* Open Tablespace           */
                                                 /* Container Query           */
  sqlbotcq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long TablespaceId,                   /* in: id tbs or SQLB_ALL    */
                                                 /* TABLESPACES               */
   unsigned long * pNumContainers);              /* out:  output...the        */
                                                 /* number of containers for  */
                                                 /* the table space           */

/* ftcq - Fetch Tablespace Container Query. Fetch the next block of           */
/* container info.                                                            */
SQL_API_RC SQL_API_FN                            /* Fetch Tablespace          */
                                                 /* Container Query           */
  sqlbftcq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long MaxContainers,                  /* in:  max # entries to     */
                                                 /* return in 'data'          */
   struct SQLB_TBSCONTQRY_DATA * pContainerData, /* out: array of 'maxCont'   */
                                                 /* entries                   */
   unsigned long * pNumContainers);              /* out: # data entries       */
                                                 /* returned on this query    */

/* ctcq - Close Tablespace Container Query. Terminate processing for this     */
/* query                                                                      */
SQL_API_RC SQL_API_FN                            /* Close Tablespace          */
                                                 /* Container Query           */
  sqlbctcq (
   struct sqlca * pSqlca);

/* tcq - Tablespace Container Query                                           */
/* Like 'sqlbtsq', this api generates a complete list, allocating sufficient  */
/* memory.  The application is responsible for freeing the memory when it is  */
/* finished with it: call sqlefmem(ca,ptr).                                   */
SQL_API_RC SQL_API_FN
  sqlbtcq (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long TablespaceId,                   /* in: id a tbs or SQLB_ALL  */
                                                 /* TABLESPACES               */
   unsigned long * pNumContainers,               /* out: # entries returned   */
   struct SQLB_TBSCONTQRY_DATA ** ppContainerData);

/* stsc - Set TableSpace Containers                                           */
/* This api is to be used when the tablespace is in a 'storage definition     */
/* pending' or 'storage definition allowed' state.  These states are          */
/* possible during a restore operation, immediately prior to the restoration  */
/* of database pages.  This API is intended to assist in the provision of a   */
/* 'redirected' restore, where the user is restoring a database and a         */
/* different set of OS storage containers is desired/required.                */
/*                                                                            */
/* As input the application provides a list of storage definitions in the     */
/* SQLB_TBSCONTQRY_DATA structure (also used for query purposes). For this    */
/* api only the following fields are examined:                                */
/*                                                                            */
/* unsigned long   nameLen;    length of name (for non-C lang.)               */
/* char            name[SQLB_MAX_CONTAIN_NAME_SZ];  null term. name           */
/* unsigned long   contType;    SQLB_CONT_PATH/DISK/FILE                      */
/* unsigned long   totalPages;  DMS only                                      */
/*                                                                            */
/* processing options...pass 0 for 'nothing-special', OR in the special       */
/* bits.                                                                      */
/*                                                                            */
/* when setting containers prior to a restore/rollforward, the user may want  */
/* to IGNORE any 'add containers' in the logs.  He may simply be providing a  */
/* different 'final' state for the tablespace configuration.  The default     */
/* behavior is to redo 'alter' logrecords after a new container list has      */
/* been set.                                                                  */

#define SQLB_SET_CONT_INIT_STATE 0
#define SQLB_SET_CONT_FINAL_STATE 1

SQL_API_RC SQL_API_FN                            /* Set Tablespace            */
                                                 /* Containers                */
  sqlbstsc (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long SetContainerOptions,            /* in: processing options:   */
                                                 /* SQLB_SET_CONT_xxx         */
   unsigned long TablespaceId,                   /* in: table space which is  */
                                                 /* to be changed             */
   unsigned long NumContainers,                  /* in:#containers in the     */
                                                 /* list                      */
   struct SQLB_TBSCONTQRY_DATA * pContainerData); /* container                */
                                                 /* specifications            */

/* gtss - Get TableSpace Statistics                                           */
/* Provide some basic info about the utilization of a tablespace. BETA NOTE:  */
/* only DMS tablespace are supported at this time - SRSFIX                    */
SQL_API_RC SQL_API_FN                            /* Get Tablespace            */
                                                 /* Statistics                */
  sqlbgtss (
   struct sqlca * pSqlca,                        /* SQLCA                     */
   unsigned long TablespaceId,
   struct SQLB_TBS_STATS * pTablespaceStats);

/* END OF TABLESPACE RELATED API'S                                            */

/* Database Utility Commands -- Function Prototypes                           */

#ifndef SQLZ_STACK

#ifdef SQL_REL_10
#define sqluauth(ca) sqluauth_api(ca)
#define sqlustat(tn,idx,ilst,op,sl,ca) sqlustat_api(tn,idx,ilst,op,sl,ca)
#else
#define sqluauth(ca) sqluauth_api(ca)
#define sqluexpt(df,dcol,tcol,ft,ftm,mf,ac,out,ca)\
        sqluexpr_api(df,NULL,NULL,dcol,tcol,ft,ftm,mf,ac,out,NULL,ca)
#define sqluimpt(df,dcol,tcol,ft,ftm,mf,ac,in,out,ca)\
        sqluimpr_api(df,NULL,dcol,tcol,ft,ftm,mf,ac,in,out,NULL,NULL,ca)
#define sqluexpr(df,lp,lf,dcol,tcol,ft,ftm,mf,ac,out,r,ca)\
        sqluexpr_api(df,lp,lf,dcol,tcol,ft,ftm,mf,ac,out,r,ca)
#define sqluimpr(df,lp,dcol,tcol,ft,ftm,mf,ac,in,out,ni,r,ca)\
        sqluimpr_api(df,lp,dcol,tcol,ft,ftm,mf,ac,in,out,ni,r,ca)
#define sqlureot(tn,in,df,ca) sqlureot_api(tn,in,df,ca)
#define sqlurfwd(dbn,ac,pit,ne,fe,le,rt,us,pa,ca)\
        sqlurfwd_api(dbn,ac,pit,ne,fe,le,rt,us,pa,ca)
#define sqlurllf(dbn,ac,app,pit,ne,fe,le,rt,us,pa,ov,mo,re,ca)\
        sqlurllf_api(dbn,ac,app,pit,ne,fe,le,rt,us,pa,ov,mo,re,ca)
#define sqluload(df,lp,dc,tc,ft,fm,msg,rf,ac,in,out,wd,ct,ni,r,ca)\
        sqluload_api(df,lp,dc,tc,ft,fm,msg,rf,ac,in,out,wd,ct,ni,r,ca)
#define sqluqry(lf,rf,ca)  sqluqry_api(lf,rf,ca)
#define sqlustat(tn,idx,ilst,op,sl,ca) sqlustat_api(tn,idx,ilst,op,sl,ca)
#define sqlurlog(ac,sl,el,lb,lbs,rli,ca)\
        sqlurlog_api(ac,sl,el,lb,lbs,rli,ca)

#endif

#endif

/* General Utility Commands                                                   */

SQL_API_RC SQL_API_FN                       /* Open Recovery History File     */
                                            /* Scan                           */
  sqluhops (
   char * pDbAlias,                         /* database alias to open the     */
                                            /* scan for                       */
   char * pTimestamp,                       /* complete/partial timestamp     */
   char * pObjectName,                      /* table name or tablespace name  */
   unsigned short * pNumRows,               /* rows that match parameters     */
   unsigned short * pHandle,                /* handle used for gne/cls        */
   unsigned short CallerAction,             /* list: 0-backup; 1-history      */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Next Recovery History      */
                                            /* File Entry                     */
  sqluhgne (
   unsigned short Handle,                   /* handle returned from open      */
   void * pReserved,                        /* reserved for future use        */
   struct sqluhinfo * pHistoryInfo,         /* pointer to entry               */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Close Recovery History File    */
                                            /* Scan                           */
  sqluhcls (
   unsigned short Handle,                   /* handle returned from open      */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Prune Recovery History File    */
  sqluhprn (
   char * pTimestamp,                       /* timestamp (or partial one)     */
   unsigned short ForceOption,              /* 0 for DON'T FORCE              */
                                            /*  1 for FORCE                   */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Recovery History File   */
  sqluhupd (
   char * pObjectPart,                      /* timestamp||(001 -> 999)        */
   char * pNewLocation,                     /* the new location               */
   char * pNewDeviceType,                   /* the new device type            */
   char * pNewComment,                      /* new comment                    */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Quiesce Tablespaces for Table  */
  sqluvqdp (
   char * pTableName,                       /* fully qualified table name     */
   long QuiesceMode,                        /* 0 for share                    */
                                            /* 1 for intent to update         */
                                            /* 2 for exclusive                */
                                            /* 9 to reset                     */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Authorizations             */
  sqluadau (
   struct sql_authorizations * pAuthorizations,
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Authorizations             */
  sqluauth_api (
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Backup Database                */
  sqlubkup (
   char * pDbAlias,                         /* database alias                 */
   unsigned long BufferSize,                /* backup buffer size             */
   unsigned long BackupMode,                /* online or offline              */
   unsigned long BackupType,                /* backup type.                   */
   unsigned long CallerAction,              /* caller action                  */
   char * pApplicationId,                   /* application ID.                */
   char * pTimestamp,                       /* timestamp returned             */
   unsigned long NumBuffers,                /* num of buffers                 */
   struct sqlu_tablespace_bkrst_list * pTablespaceList, /* list of            */
                                            /* tablespace                     */
   struct sqlu_media_list * pMediaTargetList, /* list of media targ           */
   char * pUserName,                        /* user name                      */
   char * pPassword,                        /* password                       */
   void * pReserved2,                       /* reserved for future            */
   unsigned long VendorOptionsSize,         /* size of options                */
   void * pVendorOptions,                   /* reserved for vendor            */
   void * pReserved3,                       /* reserved for future            */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Restore Database               */
  sqlursto (
   char * pSourceDbAlias,                   /* source alias name              */
   char * pTargetDbAlias,                   /* target dbalias                 */
   unsigned long BufferSize,                /* restore buffer size            */
   unsigned long RollforwardMode,           /* 0 - roll forward               */
                                            /* 1 - do not roll fwd            */
   unsigned long RestoreType,               /* 0 - normal restore             */
                                            /* 3 - online restore for         */
                                            /* tablespace only                */
                                            /* 5 - history file only          */
   unsigned long CallerAction,              /* caller action                  */
   char * pApplicationId,                   /* application ID.                */
   char * pTimestamp,                       /* timestamp for backup image     */
   char * pTargetPath,                      /* target path for new database   */
   unsigned long NumBuffers,                /* num of buffers                 */
   struct sqlu_tablespace_bkrst_list * pTablespaceList, /* reserved for       */
                                            /* future use.                    */
   struct sqlu_media_list * pMediaSourceList, /* list of media controllers    */
                                            /* to use.                        */
   char * pUserName,                        /* userid                         */
   char * pPassword,                        /* password                       */
   void * pReserved2,                       /* reserved for future use        */
   unsigned long VendorOptionsSize,         /* size of options field          */
   void * pVendorOptions,                   /* reserved for vendor use        */
   void * pReserved3,                       /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Rollforward Database           */
  sqlurllf_api (
   char * pDbAlias,                         /* database alias                 */
   unsigned short CallerAction,             /* action                         */
   char * pApplicationId,                   /* application id                 */
   char * pStopTime,                        /* stop time                      */
   char * pNextArcFileName,                 /* next archive file needed       */
   char * pFirstDelArcFileName,             /* first archive file to be       */
                                            /* deleted                        */
   char * pLastDelArcFileName,              /* last archive file to be        */
                                            /* deleted                        */
   char * pLastCommitTime,                  /* last commit time               */
   char * pUserName,                        /* user name                      */
   char * pPassword,                        /* password                       */
   char * pOverflowLogPath,                 /* overflow log path              */
   unsigned short ConnectMode,              /* connect mode                   */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Old backup                     */
  sqlubckp (
   _SQLOLDCHAR *,                           /* alias name                     */
   unsigned long,                           /* backup buffer size             */
   unsigned short,                          /* online or offline              */
   unsigned short,                          /* reserved                       */
   unsigned short,                          /* ADSM or otherwise              */
   _SQLOLDCHAR *,                           /* dir or device name             */
   unsigned short,                          /* caller action                  */
   _SQLOLDCHAR *,                           /* timestamp returned             */
   _SQLOLDCHAR *,                           /* userid                         */
   _SQLOLDCHAR *,                           /* password                       */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Old Restore                    */
  sqludrst (
   _SQLOLDCHAR *,                           /* source database alias          */
   _SQLOLDCHAR *,                           /* target database alias          */
   unsigned long,                           /* restore buffer size            */
   unsigned short,                          /* media type: ADSM or otherwise  */
   _SQLOLDCHAR *,                           /* dir or device name             */
   _SQLOLDCHAR *,                           /* timestamp of backup            */
   unsigned short,                          /* roll forward flag              */
   unsigned short,                          /* caller action                  */
   _SQLOLDCHAR *,                           /* target: new dbase              */
   _SQLOLDCHAR *,                           /* userid                         */
   _SQLOLDCHAR *,                           /* password                       */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Old Rollforward Database       */
  sqlurfwd_api (
   _SQLOLDCHAR *,                           /* database name                  */
   unsigned short,                          /* action                         */
   _SQLOLDCHAR *,                           /* Stop Timestamp                 */
   _SQLOLDCHAR *,                           /* Next Archive File needed       */
   _SQLOLDCHAR *,                           /* First Archive File to be       */
                                            /* deleted                        */
   _SQLOLDCHAR *,                           /* Last Archive File to be        */
                                            /* deleted                        */
   _SQLOLDCHAR *,                           /* Returned Timestamp             */
   _SQLOLDCHAR *,                           /* userid                         */
   _SQLOLDCHAR *,                           /* password                       */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Export                         */
  sqluexpr_api (
   char * pDataFileName,                    /* data file                      */
   sqlu_media_list * pLobPathList,          /* lob paths                      */
   sqlu_media_list * pLobFileList,          /* lob files                      */
   struct sqldcol * pDataDescriptor,        /* dcoldata                       */
   struct sqlchar * pActionString,          /* tcolstrg                       */
   char * pFileType,                        /* file type                      */
   struct sqlchar * pFileTypeMod,           /* file type mod                  */
   char * pMsgFileName,                     /* msg file                       */
   short CallerAction,                      /* caller action                  */
   struct sqluexpt_out*  pOutputInfo,       /* rows exported                  */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Export                         */
  sqluexpt_api (
   _SQLOLDCHAR *,                           /* datafile                       */
   struct sqldcol *,                        /* dcoldata                       */
   struct sqlchar *,                        /* tcolstrg                       */
   _SQLOLDCHAR *,                           /* filetype                       */
   struct sqlchar *,                        /* filetmod                       */
   _SQLOLDCHAR *,                           /* msgfile                        */
   short,                                   /* caller action                  */
   struct sqluexpt_out* ,                   /* rows exported                  */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Import                         */
  sqluimpt_api (
   _SQLOLDCHAR *,                           /* datafile                       */
   struct sqldcol *,                        /* dcoldata                       */
   struct sqlchar *,                        /* tcolstrg                       */
   _SQLOLDCHAR *,                           /* filetype                       */
   struct sqlchar *,                        /* filetmod                       */
   _SQLOLDCHAR *,                           /* msgfile                        */
   short,                                   /* caller action                  */
   struct sqluimpt_in* ,                    /* input parms                    */
   struct sqluimpt_out* ,                   /* output parms                   */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Import                         */
  sqluimpr_api (
   char * pDataFileName,                    /* datafile                       */
   sqlu_media_list * pLobPathList,          /* lobpath                        */
   struct sqldcol * pDataDescriptor,        /* dcoldata                       */
   struct sqlchar * pActionString,          /* tcolstrg                       */
   char * pFileType,                        /* filetype                       */
   struct sqlchar * pFileTypeMod,           /* filetmod                       */
   char * pMsgFileName,                     /* msgfile                        */
   short CallerAction,                      /* caller action                  */
   struct sqluimpt_in*  pImportInfoIn,      /* input parms                    */
   struct sqluimpt_out*  pImportInfoOut,    /* output parms                   */
   long * pNullIndicators,                  /* nullind                        */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Load                           */
  sqluload_api (
   sqlu_media_list * pDataFileList,         /* input data files               */
   sqlu_media_list * pLobPathList,          /* input lob paths                */
   struct sqldcol * pDataDescriptor,        /* dcoldata - describes input     */
                                            /* data                           */
   struct sqlchar * pActionString,          /* tcolstrg - describes the       */
                                            /* columns of the table to load   */
   char * pFileType,                        /* file type                      */
   struct sqlchar * pFileTypeMod,           /* filetmod                       */
   char * pLocalMsgFileName,                /* message file name              */
   char * pRemoteMsgFileName,               /* remote file name               */
   short CallerAction,                      /* caller action                  */
   struct sqluload_in * pLoadInfoIn,        /* input                          */
   struct sqluload_out * pLoadInfoOut,      /* output                         */
   sqlu_media_list * pWorkDirectoryList,    /* work dirs                      */
   sqlu_media_list * pCopyTargetList,       /* copy targets                   */
   long * pNullIndicators,                  /* null ind                       */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Query                          */
  sqluqry_api (
   char * pLocalMsgFileName,                /* local msg file                 */
   char * pRemoteMsgFileName,               /* remote msg file                */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Asynchronous Read Log          */
  sqlurlog_api (
   unsigned long CallerAction,              /* caller action                  */
   SQLU_LSN * pStartLsn,                    /* read start log sequence        */
                                            /* number                         */
   SQLU_LSN * pEndLsn,                      /* read end log sequence number   */
   char * pLogBuffer,                       /* user buffer                    */
   unsigned long LogBufferSize,             /* size of user buffer            */
   SQLU_RLOG_INFO * pReadLogInfo,           /* read log information           */
                                            /* structure                      */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Reorganize Table               */
  sqlureot_api (
   _SQLOLDCHAR * pTableName,                /* table name                     */
   _SQLOLDCHAR * pIndexName,                /* fully-qualified index name     */
   _SQLOLDCHAR * pTablespace,               /* tablespace                     */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Run Statistics                 */
  sqlustat_api (
   _SQLOLDCHAR * pTableName,                /* table name                     */
   unsigned short NumIndexes,               /* number of indexes              */
   _SQLOLDCHAR ** ppIndexList,              /* indexlist                      */
   unsigned char StatsOption,               /* statsopt                       */
   unsigned char ShareLevel,                /* sharelvl                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Table Authorizations       */
  sqlutbau (
   _SQLOLDCHAR *,                           /* fully-qualified table name     */
   struct sqlca *);                         /* SQLCA                          */

/* Generic APIs                                                               */

SQL_API_RC SQL_API_FN                       /* Get Authorizations             */
  sqlgadau (
   struct sql_authorizations * pAuthorizations,
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Default Database           */
                                            /* Configuration                  */
  sqlgddb (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short NumItems,                 /* count of requested no of       */
                                            /* items                          */
   struct sqlfupd * pItemList,              /* list of items returned         */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   char * pDbAlias);                        /* database  alias                */

SQL_API_RC SQL_API_FN                       /* Reset Database Configuration   */
  sqlgrdb (
   unsigned short DbAliasLen,               /* database alias length          */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   char * pDbAlias);                        /* database alias                 */

SQL_API_RC SQL_API_FN                       /* Update Database Configuration  */
  sqlgudb (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short NumItems,                 /* count                          */
   unsigned short * pItemListLens,          /* List of item lengths           */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   char * pDbAlias);                        /* database                       */

SQL_API_RC SQL_API_FN                       /* Get Database Configuration     */
  sqlgxdb (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short NumItems,                 /* count of items being returned  */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   char * pDbAlias);                        /* database alias                 */

SQL_API_RC SQL_API_FN                       /* Get Database Manager           */
                                            /* Configuration Defaults         */
  sqlgdsys (
   unsigned short NumItems,                 /* count of items being returned  */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Backup Database                */
  sqlgbkup (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short UserNameLen,              /* user name length               */
   unsigned short PasswordLen,              /* password length                */
   unsigned short * pReserved1,             /* reserved for future use        */
   char * pDbAlias,                         /* database alias                 */
   unsigned long BufferSize,                /* buffer size in 4K units        */
   unsigned long BackupMode,                /* online or offline              */
   unsigned long BackupType,                /* 0 - full dB; 3 - tablespace    */
   unsigned long CallerAction,              /* caller action                  */
   char * pApplicationId,                   /* application ID.                */
   char * pTimestamp,                       /* timestamp returned             */
   unsigned long NumBuffers,                /* number of buffers to use       */
   struct sqlu_tablespace_bkrst_list * pTablespaceList, /* list of            */
                                            /* tablespace names               */
   struct sqlu_media_list * pMediaTargetList, /* list of media targets        */
   char * pUserName,                        /* user name                      */
   char * pPassword,                        /* password                       */
   void * pReserved2,                       /* reserved for future use        */
   unsigned long VendorOptionsSize,         /* size of options field          */
   void * pVendorOptions,                   /* reserved for vendor use        */
   void * pReserved3,                       /* reserved for future use        */
   struct sqlca * pSqlca);                  /* sqlca structure                */

SQL_API_RC SQL_API_FN                       /* Close Recovery History File    */
                                            /* Scan                           */
  sqlghcls (
   unsigned short Handle,                   /* handle returned from open      */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Next Recovery History      */
                                            /* File Entry                     */
  sqlghgne (
   unsigned short Handle,                   /* handle returned from open      */
   void * pReserved,                        /* reserved for future use        */
   struct sqluhinfo * pHistoryInfo,         /* pointer to the address of the  */
                                            /* history file entry info        */
                                            /* buffer                         */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Open Recovery History File     */
                                            /* Scan                           */
  sqlghops (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short TimestampLen,             /* timestamp length               */
   unsigned short ObjectNameLen,            /* object name length             */
   char * pDbAlias,                         /* database alias                 */
   char * pTimestamp,                       /* timestamp used to select       */
                                            /* records                        */
   char * pObjectName,                      /* object name used to select     */
                                            /* records                        */
   unsigned short * pNumRows,               /* return no. of matching         */
                                            /* history file entries           */
   unsigned short * pHandle,                /* return handle used for future  */
                                            /* access                         */
   unsigned short CallerAction,             /* '0' for backup                 */
                                            /* '1' for history                */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Prune Recovery History File    */
  sqlghprn (
   unsigned short TimestampLen,             /* timestamp id length            */
   char * pTimestamp,                       /* timestamp (whole or part)      */
   unsigned short ForceOption,              /* force option                   */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Recovery History File   */
  sqlghupd (
   unsigned short ObjectPartLen,            /* object_part length             */
   unsigned short NewLocationLen,           /* new_location length            */
   unsigned short NewDeviceTypeLen,         /* new_device_type length         */
   unsigned short NewCommentLen,            /* new_comment length             */
   char * pObjectPart,                      /* timestamp||(001 -> 999)        */
   char * pNewLocation,                     /* the new location               */
   char * pNewDeviceType,                   /* the new device type            */
   char * pNewComment,                      /* new comment                    */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Rollforward Database           */
  sqlgrllf (
   unsigned short DbAliasLen,               /* database alias length          */
   unsigned short StopTimeLen,              /* stop time length               */
   unsigned short UserNameLen,              /* user name length               */
   unsigned short PasswordLen,              /* password length                */
   unsigned short OverflowLogPathLen,       /* overflow log path length       */
   char * pDbAlias,                         /* database alias                 */
   unsigned short CallerAction,             /* caller action                  */
   char * pApplicationId,                   /* application id returned        */
   char * pStopTime,                        /* stop time                      */
   char * pNextArcFileName,                 /* next archive file              */
   char * pFirstDelArcFileName,             /* first del archive file         */
   char * pLastDelArcFileName,              /* last del archive file          */
   char * pLastCommitTime,                  /* last commit time               */
   char * pUserName,                        /* user name                      */
   char * pPassword,                        /* password                       */
   char * pOverflowLogPath,                 /* overflow log path name         */
   unsigned short ConnectMode,              /* connect mode                   */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Restore Database               */
  sqlgrsto (
   unsigned short SourceDbAliasLen,         /* source database alias length   */
   unsigned short TargetDbAliasLen,         /* target database alias length   */
   unsigned short TimestampLen,             /* timestamp length               */
   unsigned short TargetPathLen,            /* target path length             */
   unsigned short UserNameLen,              /* user name length               */
   unsigned short PasswordLen,              /* password  length               */
   unsigned short * pReserved1,             /* nodename length                */
   char * pSourceDbAlias,                   /* source database alias          */
   char * pTargetDbAlias,                   /* target database alias          */
   unsigned long BufferSize,                /* buffer size in 4K units        */
   unsigned long RollforwardMode,           /* 0 - roll forward               */
                                            /* 1 - do not roll forward        */
   unsigned long RestoreType,               /* 0 - normal restore             */
                                            /* 3 - online restore             */
                                            /*     for tablespace only        */
                                            /* 5 - history file only          */
   unsigned long CallerAction,              /* caller action                  */
   char * pApplicationId,                   /* application id returned        */
   char * pTimestamp,                       /* timestamp of backup            */
   char * pTargetPath,                      /* target: new path               */
   unsigned long NumBuffers,                /* number of buffers to use       */
   struct sqlu_tablespace_bkrst_list * pTablespaceList, /* reserved for       */
                                            /* future use                     */
   struct sqlu_media_list * pMediaSourceList, /* list of media sources        */
   char * pUserName,                        /* user name                      */
   char * pPassword,                        /* password                       */
   void * pReserved2,                       /* reserved for future use        */
   unsigned long VendorOptionsSize,         /* size of options field          */
   void * pVendorOptions,                   /* reserved for vendor use        */
   void * pReserved3,                       /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Quiesce Tablespaces for Table  */
  sqlgvqdp (
   unsigned short TableNameLen,             /* length of table_name           */
   char * pTableName,                       /* table name                     */
   long QuiesceMode,                        /* 0 for share                    */
                                            /* 1 for intent to update         */
                                            /* 2 for exclusive                */
                                            /* 9 to reset                     */
   void * pReserved,                        /* reserved for future use        */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Old Backup                     */
  sqlgbckp (
   unsigned short,                          /* password length                */
   unsigned short,                          /* userid length                  */
   unsigned short,                          /* media target length            */
   unsigned short,                          /* database name length           */
   struct sqlca *,                          /* ptr to sqlca                   */
   _SQLOLDCHAR *,                           /* ptr to password                */
   _SQLOLDCHAR *,                           /* ptr to userid                  */
   _SQLOLDCHAR *,                           /* ptr to timestamp               */
   unsigned short,                          /* caller action                  */
   _SQLOLDCHAR *,                           /* ptr to media target            */
   unsigned short,                          /* media type                     */
   unsigned short,                          /* reserved                       */
   unsigned short,                          /* backup mode                    */
   unsigned long,                           /* buffer size                    */
   _SQLOLDCHAR *);                          /* ptr to database name           */

SQL_API_RC SQL_API_FN                       /* Restore                        */
  sqlgdrst (
   unsigned short,                          /* password length                */
   unsigned short,                          /* userid length                  */
   unsigned short,                          /* target length                  */
   unsigned short,                          /* timestamp length               */
   unsigned short,                          /* media source length            */
   unsigned short,                          /* target database length         */
   unsigned short,                          /* source database length         */
   struct sqlca *,                          /* ptr to sqlca                   */
   _SQLOLDCHAR *,                           /* ptr to password                */
   _SQLOLDCHAR *,                           /* ptr to userid                  */
   _SQLOLDCHAR *,                           /* ptr to target                  */
   unsigned short,                          /* caller action                  */
   unsigned short,                          /* restore mode                   */
   _SQLOLDCHAR *,                           /* ptr to timestamp               */
   _SQLOLDCHAR *,                           /* ptr to media source            */
   unsigned short,                          /* media type                     */
   unsigned long,                           /* buffer size                    */
   _SQLOLDCHAR *,                           /* ptr to target database         */
   _SQLOLDCHAR *);                          /* ptr to source database         */

SQL_API_RC SQL_API_FN                       /* EXPORT FROM                    */
  sqlgexpr (
   unsigned short DataFileNameLen,          /* data file name length          */
   unsigned short FileTypeLen,              /* file type length               */
   unsigned short MsgFileNameLen,           /* msg file name length           */
   char * pDataFileName,                    /* data file                      */
   sqlu_media_list * pLobPathList,          /* lob paths                      */
   sqlu_media_list * pLobFileList,          /* lob file names                 */
   struct sqldcol * pDataDescriptor,        /* dcoldata                       */
   struct sqlchar * pActionString,          /* tcolstrg                       */
   char * pFileType,                        /* file type                      */
   struct sqlchar * pFileTypeMod,           /* file type mod                  */
   char * pMsgFileName,                     /* msg file name                  */
   short CallerAction,                      /* caller action                  */
   struct sqluexpt_out*  pOutputInfo,       /* rows exported                  */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Export                         */
  sqlgexpt (
   unsigned short,                          /* message file name length       */
   unsigned short,                          /* file type length               */
   unsigned short,                          /* data file name length          */
   struct sqlca *,                          /* SQLCA                          */
   struct sqluexpt_out* ,                   /* ptr to rows exported           */
   short,                                   /* caller action                  */
   _SQLOLDCHAR *,                           /* message file name              */
   struct sqlchar *,                        /* ptr to file type mod           */
   _SQLOLDCHAR *,                           /* ptr to filetype                */
   struct sqlchar *,                        /* ptr to tcolstrg                */
   struct sqldcol *,                        /* ptr to dcoldata                */
   _SQLOLDCHAR *);                          /* data file name                 */

SQL_API_RC SQL_API_FN                       /* Import                         */
  sqlgimpr (
   unsigned short DataFileNameLen,          /* datafile length                */
   unsigned short FileTypeLen,              /* file type length               */
   unsigned short MsgFileNameLen,           /* msgfile length                 */
   char * pDataFileName,                    /* data file name                 */
   sqlu_media_list * pLobPathList,          /* lobpaths                       */
   struct sqldcol * pDataDescriptor,        /* dcoldata                       */
   struct sqlchar * pActionString,          /* tcolstrg                       */
   char * pFileType,                        /* filetype                       */
   struct sqlchar * pFileTypeMod,           /* filetmod                       */
   char * pMsgFileName,                     /* message file name              */
   short CallerAction,                      /* caller action                  */
   struct sqluimpt_in*  pImportInfoIn,      /* input parms                    */
   struct sqluimpt_out*  pImportInfoOut,    /* output parms                   */
   long * NullIndicators,                   /* nullind                        */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Import                         */
  sqlgimpt (
   unsigned short,                          /* message file name length       */
   unsigned short,                          /* file type length               */
   unsigned short,                          /* data file name length          */
   struct sqlca *,                          /* SQLCA                          */
   struct sqluimpt_out *,                   /* ptr to output parms            */
   struct sqluimpt_in *,                    /* ptr to input parms             */
   short,                                   /* caller action                  */
   _SQLOLDCHAR *,                           /* message file name              */
   struct sqlchar *,                        /* file mode description          */
   _SQLOLDCHAR *,                           /* file type                      */
   struct sqlchar *,                        /* ptr to table/column            */
   struct sqldcol *,                        /* ptr to column data             */
   _SQLOLDCHAR *);                          /* data file name                 */

SQL_API_RC SQL_API_FN                       /* Load                           */
  sqlgload (
   unsigned short FileTypeLen,              /* file type length               */
   unsigned short LocalMsgFileNameLen,      /* message file length            */
   unsigned short RemoteMsgFileNameLen,     /* remote file length             */
   sqlu_media_list * pDataFileList,         /* data file name                 */
   sqlu_media_list * pLobPathList,          /* lobpaths                       */
   struct sqldcol * pDataDescriptor,        /* dcoldata                       */
   struct sqlchar * pActionString,          /* tcolstrg                       */
   char * pFileType,                        /* file type                      */
   struct sqlchar * pFileTypeMod,           /* filetmod                       */
   char * pLocalMsgFileName,                /* message file name              */
   char * pRemoteMsgFileName,               /* remote file name               */
   short CallerAction,                      /* caller action                  */
   struct sqluload_in * pLoadInfoIn,        /* input                          */
   struct sqluload_out * pLoadInfoOut,      /* output                         */
   sqlu_media_list * pWorkDirectoryList,    /* work directory                 */
   sqlu_media_list * pCopyTargetList,       /* copy target                    */
   long * pNullIndicators,                  /* null ind                       */
   void * pReserved,                        /* reserved                       */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Query                          */
  sqlgqry (
   unsigned short LocalMsgFileNameLen,      /* lf_length                      */
   unsigned short RemoteMsgFileNameLen,     /* rf_length                      */
   char * pLocalMsgFileName,                /* local file                     */
   char * pRemoteMsgFileName,               /* remote file                    */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Reorganize Table               */
  sqlgreot (
   unsigned short TablespaceLen,            /* tablespace length              */
   unsigned short IndexNameLen,             /* index name length              */
   unsigned short TableNameLen,             /* table name length              */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   _SQLOLDCHAR * pTablespace,               /* tablespace                     */
   _SQLOLDCHAR * pIndexName,                /* index name                     */
   _SQLOLDCHAR * pTableName);               /* table name                     */

SQL_API_RC SQL_API_FN                       /* Rollforward                    */
  sqlgrfwd (
   unsigned short,                          /* password length                */
   unsigned short,                          /* userid length                  */
   unsigned short,                          /* point in time length           */
   unsigned short,                          /* database name length           */
   struct sqlca *,                          /* SQLCA                          */
   _SQLOLDCHAR *,                           /* password                       */
   _SQLOLDCHAR *,                           /* userid                         */
   _SQLOLDCHAR *,                           /* last commit time               */
   _SQLOLDCHAR *,                           /* last archive del               */
   _SQLOLDCHAR *,                           /* first archive del              */
   _SQLOLDCHAR *,                           /* next archive need              */
   _SQLOLDCHAR *,                           /* point in time                  */
   unsigned short,                          /* action                         */
   _SQLOLDCHAR *);                          /* database name                  */

SQL_API_RC SQL_API_FN                       /* Run Statistics                 */
  sqlgstat (
   unsigned short TableNameLen,             /* table name length              */
   unsigned short NumIndexes,               /* number of indices              */
   unsigned char StatsOption,               /* stats option                   */
   unsigned char ShareLevel,                /* share level                    */
   unsigned short * pIndexLens,             /* index lengths                  */
   struct sqlca * pSqlca,                   /* SQLCA                          */
   _SQLOLDCHAR ** ppIndexList,              /* index list                     */
   _SQLOLDCHAR * pTableName);               /* table name                     */

SQL_API_RC SQL_API_FN                       /* Dereference Address            */
  sqlgdref (
   unsigned int NumBytes,                   /* number of bytes to transfer    */
   char * pTargetBuffer,                    /* target area for transfer       */
   char ** ppSourceBuffer);                 /* source area for transfer       */

SQL_API_RC SQL_API_FN                       /* Copy Memory                    */
  sqlgmcpy (
   void * pTargetBuffer,                    /* area into which to move the    */
                                            /* data                           */
   const void * pSource,                    /* area from which to move the    */
                                            /* data                           */
   unsigned long NumBytes);                 /* number of bytes to move        */

SQL_API_RC SQL_API_FN                       /* Return address                 */
  sqlgaddr (
   char * pVariable,                        /* variable                       */
   char ** ppOutputAddress);                /* ptr to an area containing the  */
                                            /* address                        */

/* Configuration Utility Commands                                             */

SQL_API_RC SQL_API_FN                       /* Reset Database Manager         */
                                            /* Configuration                  */
  sqlfrsys (
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Reset Database Configuration   */
  sqlfrdb (
   _SQLOLDCHAR * pDbAlias,                  /* database alias                 */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Database Manager        */
                                            /* Configuration                  */
  sqlfusys (
   unsigned short NumItems,                 /* count of entries being         */
                                            /* modified                       */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Database Configuration  */
  sqlfudb (
   _SQLOLDCHAR * pDbAlias,                  /* database alias                 */
   unsigned short NumItems,                 /* count of entries being         */
                                            /* modified                       */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Database Manager           */
                                            /* Configuration                  */
  sqlfxsys (
   unsigned short NumItems,                 /* count of entries being         */
                                            /* returned                       */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Database Configuration     */
  sqlfxdb (
   _SQLOLDCHAR * pDbAlias,                  /* database alias                 */
   unsigned short NumItems,                 /* count of entries being         */
                                            /* returned                       */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Database Manager           */
                                            /* Configuration Defaults         */
  sqlfdsys (
   unsigned short NumItems,                 /* count of items being returned  */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Database Configuration     */
                                            /* Defaults                       */
  sqlfddb (
   char * pDbAlias,                         /* database alias                 */
   unsigned short NumItems,                 /* count of entries to return     */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Reset Database Manager         */
                                            /* Configuration                  */
  sqlgrsys (
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Database Manager        */
                                            /* Configuration                  */
  sqlgusys (
   unsigned short NumItems,                 /* count of entries being         */
                                            /* modified                       */
   unsigned short * pItemListLens,          /* list of item lengths           */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Get Database Manager           */
                                            /* Configuration                  */
  sqlgxsys (
   unsigned short NumItems,                 /* count of entries being         */
                                            /* returned                       */
   struct sqlfupd * pItemList,              /* list of items                  */
   struct sqlca * pSqlca);                  /* SQLCA                          */

SQL_API_RC SQL_API_FN                            /* Single TableSpace Query   */
  sqlgstsq (
   struct sqlca * pSqlca,
   unsigned long TablespaceId,                   /* in: tableSpace id         */
   struct SQLB_TBSQRY_DATA * pTablespaceData);   /* out: tableSpace data      */

SQL_API_RC SQL_API_FN                            /* Open TableSpace Query     */
  sqlgotsq (
   struct sqlca * pSqlca,
   unsigned long TablespaceQueryOptions,         /* in: processing options:   */
                                                 /* SQLB_TBS_OPEN_xxx         */
   unsigned long * pNumTablespaces);             /* out: # tablespaces        */
                                                 /* defined in db             */

SQL_API_RC SQL_API_FN                            /* Fetch TableSpace Query    */
  sqlgftsq (
   struct sqlca * pSqlca,
   unsigned long MaxTablespaces,                 /* size of output area       */
   struct SQLB_TBSQRY_DATA * pTablespaceData,    /* out: array of length      */
                                                 /* maxTbs                    */
   unsigned long * pNumTablespaces);             /* out: #data entries        */
                                                 /* returned                  */

SQL_API_RC SQL_API_FN                            /* Close TableSpace Query    */
  sqlgctsq (
   struct sqlca * pSqlca);

SQL_API_RC SQL_API_FN                            /* TableSpace Query          */
  sqlgtsq (
   struct sqlca * pSqlca,
   unsigned long * pNumTablespaces,              /* out: total number of      */
                                                 /* table spaces              */
   struct SQLB_TBSQRY_DATA ** ppTablespaceData); /* out: mem returned to      */
                                                 /* application               */

SQL_API_RC SQL_API_FN                            /* Open Tablespace           */
                                                 /* Container Query           */
  sqlgotcq (
   struct sqlca * pSqlca,
   unsigned long TablespaceId,                   /* in: id tbs or SQLB_ALL    */
                                                 /* TABLESPACES               */
   unsigned long * pNumContainers);              /* out:  output...the        */
                                                 /* number of containers for  */
                                                 /* the table space           */

SQL_API_RC SQL_API_FN                            /* Fetch Tablespace          */
                                                 /* Container Query           */
  sqlgftcq (
   struct sqlca * pSqlca,
   unsigned long MaxContainers,                  /* in:  max # entries to     */
                                                 /* return in 'data'          */
   struct SQLB_TBSCONTQRY_DATA * pContainerData, /* out: array of 'maxCont'   */
                                                 /* entries                   */
   unsigned long * pNumContainers);              /* out: # data entries       */
                                                 /* returned on this query    */

SQL_API_RC SQL_API_FN                            /* Close Tablespace          */
                                                 /* Container Query           */
  sqlgctcq (
   struct sqlca * pSqlca);

SQL_API_RC SQL_API_FN                            /* Tablespace Container      */
                                                 /* Query                     */
  sqlgtcq (
   struct sqlca * pSqlca,
   unsigned long TablespaceId,                   /* in: id a tbs or SQLB_ALL  */
                                                 /* TABLESPACES               */
   unsigned long * pNumContainers,               /* out: # entries returned   */
   struct SQLB_TBSCONTQRY_DATA ** ppContainerData);

SQL_API_RC SQL_API_FN                            /* Set TableSpace            */
                                                 /* Containers                */
  sqlgstsc (
   struct sqlca * pSqlca,
   unsigned long SetContainerOptions,            /* in: processing options:   */
                                                 /* SQLB_SET_CONT_xxx         */
   unsigned long TablespaceId,                   /* in: table space which is  */
                                                 /* to be changed             */
   unsigned long NumContainers,                  /* in:#containers in the     */
                                                 /* list                      */
   struct SQLB_TBSCONTQRY_DATA * pContainerData); /* container                */
                                                 /* specifications            */

SQL_API_RC SQL_API_FN                            /* Get TableSpace            */
                                                 /* Statistics                */
  sqlggtss (
   struct sqlca * pSqlca,
   unsigned long TablespaceId,
   struct SQLB_TBS_STATS * pTablespaceStats);

SQL_API_RC SQL_API_FN                            /* Get Authorizations        */
  sqlgauth (
   struct sqlca * pSqlca);                       /* SQLCA                     */

SQL_API_RC SQL_API_FN                            /* Get table authorizations  */
  sqlgtbau (
   unsigned short,                               /* table name length         */
   _SQLOLDCHAR *,                                /* fully-qualified table     */
                                                 /* name                      */
   struct sqlca *);                              /* SQLCA                     */

/* SQL Return Codes in SQLCODE for UTILITY/CONFIGURATION Commands             */

#ifndef SQL_RC_OK
#define SQL_RC_OK               0   /* everything is ok                */
#endif
#ifndef SQL_RC_INVALID_SQLCA
#define SQL_RC_INVALID_SQLCA   -1   /* invalid sqlca                   */
#endif

/* ROLL FORWARD Return Codes - more in the 4900's                             */

#define SQLU_RC_NOLFH                  -1258   /* Log Control file not        */
                                               /* found.                      */
#define SQLU_RC_IOELFH                 -1259   /* I/O Error accessing LFH.    */
#define SQLU_RC_RFNOTEN                -1260   /* DB not enabled for Roll     */
                                               /* Fwd                         */
#define SQLU_RC_RFNOTP                 -1261   /* Roll Forward is not         */
                                               /* Pending                     */
#define SQLU_RC_BADPIT                 -1262   /* Bad Point in Time           */
                                               /* specified                   */
#define SQLU_RC_INVEXT                 -1263   /* Invalid Log Extent file     */
#define SQLU_RC_NOTEXT                 -1264   /* Log Extent file does not    */
                                               /* belong to DB                */
#define SQLU_RC_IVREXT                 -1265   /* Log extent file is          */
                                               /* incorrect version           */
#define SQLU_RC_PRTIME                 -1266   /* Time specified is before    */
                                               /* previous roll-forward time  */
#define SQLU_RC_UEXIT_ERR              -1268   /* User exit encountered an    */
                                               /* error (other than retry)    */
                                               /* while attempting to         */
                                               /* retrieve a log extent file  */
                                               /* for roll forward            */
#define SQLU_RC_RFINPRG                -1269   /* Rollforward by tablespace   */
                                               /* in progress.                */
#define SQLU_RC_RCVIOERR               1271    /* Roll forward complete but   */
                                               /* I/O errors encountered      */
#define SQLU_RC_RFSTOP                 -1272   /* Rollforward by tablespace   */
                                               /* has stopped.                */
#define SQLU_RC_MISSING_EXT            -1273   /* Missing log extent file.    */
#define SQLU_RC_INVTSP_STOPTIME        -1274   /* Invalid stop time for       */
                                               /* tablespace rollforward.     */
#define SQLU_INVRFR_STOPTIME           -1275   /* invalid stop time           */
                                               /* specified                   */
#define SQLU_INVRFR_STOP               -1276   /* invalid time to issue a     */
                                               /* stop                        */
#define SQLUD_INACCESSABLE_CONTAINER   1277    /* Restore found one or more   */
                                               /* containers are              */
                                               /* inaccessable                */
#define SQL_RC_RECREATE_INDEXES        1279    /* Restart complete but not    */
                                               /* all invalid  indexes were   */
                                               /* recreated                   */

#define SQLF_RC_INV_CLIENT_COMM        -1290   /* invalid client comm.        */
                                               /* protocols                   */
#define SQLF_RC_INV_DIR_FIELD          -1296   /* invalid directory services  */
                                               /* field                       */

#define SQLCC_RC_UNKNOWN_HOST          -1336   /* hostname in node dir        */
                                               /* unknown                     */
#define SQLCC_RC_UNKNOWN_SERVICE       -1337   /* service name in node        */
                                               /* directory is unknown        */
#define SQLCC_RC_UNKNOWN_SYM_DEST_NAME -1338   /* CPI-C symdestname is        */
                                               /* unknown                     */
#define SQLCC_RC_NNAME_NOTFOUND        -1341   /* wrkstn name (nname)         */

/* GENERAL UTILITY Return Codes                                               */

#define SQLU_BAD_DRIVE                 -2000   /* Invalid output drive        */
#define SQLU_USER_TERM                 -2001   /* Backup terminated by user   */
#define SQLU_NOT_LOCAL                 -2002   /* database not local          */
#define SQLU_DOS_ERROR                 -2003   /* base op system error        */
#define SQLU_SQL_ERROR                 -2004   /* SQL error occurred          */
#define SQLU_READ_ERROR                -2005   /* read wrong # of bytes       */
#define SQLU_INVALID_ACTION            -2008   /* call out of sequence        */
#define SQLU_INSUFF_MEMORY             -2009   /* insufficient memory         */
#define SQLU_STRD_ERROR                -2010   /* error in Start Using        */
#define SQLU_STPD_ERROR                -2011   /* error in Stop Using         */
#define SQLU_DIR_ERROR                 -2013   /* directory Scan error        */
#define SQLU_INVALID_DBNAME            -2015   /* invalid database name       */
#define SQLU_INVALID_PATH              -2016   /* invalid path in             */
                                               /* environment                 */
#define SQLU_START_SESSION             -2017   /* Start Session failed        */
#define SQLU_INVALID_AUTHS             -2018   /* invalid authorizations      */
#define SQLU_AUTOBIND                  -2019   /* auto-binding failed         */
#define SQLU_TIMESTAMP                 -2020   /* conflict after auto-bind    */
                                               /* control file                */
#define SQLU_IO_ERROR_LFH              -2023   /* I/O error in accessing the  */
                                               /* log                         */
#define SQLU_IO_ERROR_BRG              -2024   /* I/O error in accessing the  */
                                               /* Backup/Restore flag file    */
#define SQLU_IO_ERROR                  -2025   /* System I/O error occurred   */
#define SQLU_PAUSE_ERROR               -2026   /* error in PAUSE the started  */
                                               /* DB                          */
#define SQLU_CONT_ERROR                -2027   /* error in CONTINUE the       */
                                               /* stoped DB                   */
#define SQLU_INT_INST_ERR              -2028   /* interruption installing     */
                                               /* error                       */
#define SQLU_UEXIT_RC                  -2029   /* user exit returned non      */
                                               /* zero rc                     */

#define SQLU_FIRST_TAPE_WARNING        2031    /* warning to mount tape       */
#define SQLU_INVALID_PARM              -2032   /* parameter to utility        */
                                               /* incorrect                   */
#define SQLU_ADSM_ERROR                -2033   /* ADSM reported error         */
#define SQLU_INVALID_PARM_ADDRESS      -2034   /* address of parameter        */
                                               /* incorrect                   */
#define SQLU_NOINT_ERROR               -2035   /* error during nointerrupt    */
                                               /* action                      */
#define SQLU_PATH_ERROR                -2036   /* directory does not exist    */
#define SQLU_LOAD_ADSM_ERROR           -2037   /* unable to load ADSM         */
#define SQLU_DBSYSTEM_ERROR            -2038   /* database system error       */
#define SQLU_NO_APP_ERROR              -2039   /* application terminated      */
#define SQLU_ALIAS_ERROR               -2040   /* alias parameter error       */
#define SQLU_BUFFSIZE_ERROR            -2041   /* buff_size parameter error   */
#define SQLU_IO_WARNING                2042    /* I/O error during change     */
                                               /* tape                        */
#define SQLU_SPAWN_EDU_ERROR           -2043   /* Spawn child process error   */
#define SQLU_QUEUE_ERROR               -2044   /* Message queue error         */
#define SQLU_OBJECT_ACCESS_ERROR       -2048   /* Object access error         */
#define SQLU_CORRUPT_IMAGE_ERROR       -2054   /* Bad backup image            */
#define SQLU_MEMORY_ACCESS_ERROR       -2055   /* Unable to access memory     */
                                               /* set                         */
#define SQLU_UNKNOWN_MEDIA_TYPE        -2056   /* device path point to        */
                                               /* unknown device type         */
#define SQLU_MEDIA_CANNOT_BE_SHARED    -2057   /* device or file already      */
                                               /* opened by other process     */
#define SQLU_END_OF_MEDIA_WARNING      2058    /* End of tape or file         */
                                               /* encountered during read     */
#define SQLU_DEVICE_FULL_WARNING       2059    /* Device is full during       */
                                               /* write                       */
#define SQLU_MEDIA_EMPTY_WARNING       2060    /* Empty device or file not    */
                                               /* found during read           */
#define SQLU_MEDIA_ACCESS_DENIED       -2061   /* Access denied due to        */
                                               /* authority level             */
#define SQLU_MEDIA_ACCESS_ERROR        -2062   /* Access error                */
#define SQLU_TERM_LAST_MEDIA_WARNING   2065    /* Terminate last Media IO.    */
#define SQLU_BAD_TABLESPACE_NAME       -2066   /* Invalid tablespace name     */
#define SQLU_NO_MEDIA_HEADER           -2068   /* Could not locate media      */
                                               /* header in backup or copy    */
                                               /* image                       */
#define SQLU_INCORRECT_DBALIAS         -2069   /* Mismatch alias name from    */
                                               /* media                       */
#define SQLU_INCORRECT_TIMESTAMP       -2070   /* Mismatch timestamp read     */
                                               /* from media                  */

#define SQLU_SHR_LIB_ACCESS_ERROR      -2071   /* Shared library access       */
                                               /* error                       */
#define SQLU_BIND_SHR_LIB_ERROR        -2072   /* Bind shared library error   */

#define SQLUD_TSP_RESTORE_OUT_OF_SEQ   -2154   /* Out of sequence tablespace  */
                                               /* restore                     */

/* HISTORY TABLE Return Codes                                                 */
#define SQLUH_SCAN_UPDATED_WARNING     2155    /* Changes were made to        */
                                               /* historyfile during update.  */
#define SQLUH_MAX_SCANS_EXCEEDED       -2157   /* MAX # open scans exceeded   */
#define SQLUH_FILE_REPLACED_WARNING    2160    /* History file fixed          */
#define SQLUH_DAMAGED_FILE             -2161   /* History file is unfixable   */
#define SQLUH_SQLUHINFO_VARS_WARNING   2165    /* number of tablespaces       */
                                               /* changed                     */
#define SQLUH_ENTRY_NOT_FOUND          -2171   /* Entry not found on update   */

/* REORGANIZE TABLE Return Codes                                              */
#define SQLUR_INVALID_AUTHID           -2200   /* invalid authid on index     */
                                               /* name                        */
#define SQLUR_INVALID_TABLENAME        -2203   /* invalid tablename syntax    */
#define SQLUR_INVALID_INDEXNAME        -2204   /* invalid tablename syntax    */
#define SQLUR_INDEX_NOT_FOUND          -2205   /* index doesn't exist         */
#define SQLUR_INVALID_FILEPATH         -2207   /* invalid filepath pointer    */
#define SQLUR_INVALID_TABLESPACE       -2208   /* invalid tablespace pointer  */
#define SQLUR_TABLE_NOT_FOUND          -2211   /* table does not exist        */
#define SQLUR_VIEW_ERROR               -2212   /* cannot reorg a view         */
#define SQLUR_INCORRECT_TABLESPACE     -2213   /* Incorrect tablespace type   */
#define SQLUR_INSAUTH                  -2214   /* insuffic authority          */
#define SQLUR_SQLERR_COMPREV           -2215   /* SQL error commiting prev    */
                                               /* work                        */
#define SQLUR_SQLERR_REORG             -2216   /* SQL error during            */
                                               /* reorganization              */

/* RUN STATISTICS Return Codes                                                */
#define SQLUS_INVALID_AUTHID           -2300   /* invalid authid              */
#define SQLUS_INVALID_TABLE_NAME       -2301   /* invalid table name          */
#define SQLUS_INVALID_INDEX_LIST       -2302   /* invalid index pointer       */
#define SQLUS_INVALID_STATS_OPT        -2303   /* statsopt parameter invalid  */
#define SQLUS_INVALID_SHARE_LEV        -2304   /* sharelev parameter invalid  */
#define SQLUS_VIEWS_NOT_ALLOWED        -2305   /* table specified is a view   */
#define SQLUS_OBJ_DOES_NOT_EXIST       -2306   /* object doesn't exist        */
#define SQLUS_SYS_TABLE_NOT_ALLOWED    -2307   /* system table not allowed    */
#define SQLUS_INVALID_INDEX_AUTHID     -2308   /* index authid invalid        */
#define SQLUS_INVALID_INDEX_NAME       -2309   /* index name invalid          */
#define SQLUS_ERROR_STAT               -2310   /* error running statistics    */
#define SQLUS_INSAUTH                  -2311   /* insuffic authority for      */
                                               /* runstats                    */
#define SQLUS_STATS_HEAP_TOO_SMALL     -2312   /* statistics heap is too      */
                                               /* small                       */
#define SQLUS_PARTIAL_SUCCESS          2313    /* incomplete statistics       */
                                               /* collected                   */

#define SQLUD_RST_NOROLLFWD            3       /* Rst DB turn off roll fwd    */
                                               /* pend, old OS/2 API only     */
/* Old OS/2 Backup calling action values                                      */
#define SQLU_BACK_ALL                  0x0     /* backup entire database      */
#define SQLU_BACK_CHANGES              0x1     /* backup changes only         */
#define SQLU_BACK_QUIESCE              0x800   /* quiesce during backup       */
#define SQLU_NEW_UOW_RETURN_ERROR      0x400   /* New UOW return error immed  */

#define SQLU_DBM_ERROR                 -2014   /* pause or Continue or        */
                                               /* migration error             */
#define SQLU_WRONG_DISKETTE            -2021   /* Wrong diskette inserted     */
#define SQLU_DISK_FULL                 -2030   /* a specific fixed disk is    */
                                               /* full                        */

#define SQLUB_BAD_TYPE                 -2400   /* invalid type                */
#define SQLUB_TYPE_MUSTBE_DB           -2401   /* type must be database       */
#define SQLUB_USER_NOT_AUTH            -2403   /* insufficient auth for       */
                                               /* backup                      */
#define SQLUB_MEDIA_FULL               -2404   /* The target disk/diskette    */
                                               /* is full                     */
#define SQLUB_BR_INPROG                -2407   /* The Backup can't run        */
                                               /* because B/R flag file       */
                                               /* existed and read I/O error  */
                                               /* occurred                    */
#define SQLUB_DEL_BRG_ERR              2408    /* Backup process is           */
                                               /* successful, but unable to   */
                                               /* delete BRG file             */
#define SQLUB_WRONG_BASE_IMAGE         -2409   /* 'change-only' is only       */
                                               /* applied to the most recent  */
                                               /* base image                  */
#define SQLUB_NO_CHG_NSD               -2410   /* change only, backup not     */
                                               /* allowed to user exit        */
#define SQLUB_IO_ERROR                 -2411   /* I/O error during backup     */
#define SQLUD_BIND_WARNING             2507    /* Restore utility not bound   */
#define SQLUD_DROP_ERROR               -2511   /* error dropping database     */

/* BACKUP Return Codes                                                        */
#define SQLUB_RST_IN_PROG              -2405   /* The backup can't run        */
                                               /* because the Restore is in   */
                                               /* progress                    */
#define SQLUB_ROLLFWD_PENDING          -2406   /* The Backup can't run        */
                                               /* because roll forward is     */
                                               /* pending                     */
#define SQLUB_CORRUPT_PAGE             -2412   /* data page encountered       */
                                               /* during backup is corrupted  */
#define SQLUB_LOGRETAIN_ONLINE_ERROR   -2413   /* retain req'd for online     */
                                               /* backup                      */
#define SQLUB_INSUF_SPACE_WARNING      2414    /* no space for control info   */
#define SQLUB_NEXT_TAPE_WARNING        2416    /* tape full, mount another    */
#define SQLUB_DBASE_DOES_NOT_EXIST     -2418   /* database does not exist     */
#define SQLUB_DISK_FULL_ERROR          -2419   /* disk full during backup     */

#define SQLUB_FIRST_TAPE_ERROR         -2420   /* first tape cannot hold      */
                                               /* header                      */
#define SQLUB_LOGRETAIN_TBS_ERROR      -2421   /* retain req'd for tbs        */
                                               /* backup                      */
#define SQLUB_DB_UNSUPPORTED_BY_API    -2422   /* the backup API used does    */
                                               /* not support this format of  */
                                               /* database                    */
#define SQLUB_MISSING_INDEX            -2423   /* A required index is         */
                                               /* missing during an offline   */
                                               /* backup                      */

/* RESTORE Return Codes                                                       */
#define SQLUD_CANNOT_RESTORE           -2501   /* can't read restored         */
                                               /* database                    */
#define SQLUD_DISKETTE_ERROR           -2502   /* error reading backup        */
                                               /* diskette                    */
#define SQLUD_WRONG_DATABASE           -2503   /* wrong backup diskette       */
#define SQLUD_DISKETTE_PROMPT          2504    /* prompt for backup diskette  */
#define SQLUD_DROP_WARNING             2505    /* warn that drop will be      */
                                               /* done                        */
#define SQLUD_DATABASE_WARNING         2506    /* Restore worked, but not     */
                                               /* cleanup                     */
#define SQLUD_INVALID_TIMESTAMP        -2508   /* timestamp incorrectly       */
                                               /* specified                   */
#define SQLUD_INVALID_DBDRV            -2509   /* invalid database drive      */
#define SQLUD_SEM_ERROR                -2510   /* semaphore error             */
#define SQLUD_CREATE_ERROR             -2512   /* error creating database     */
#define SQLUD_REN_ERROR                -2513   /* error renaming database     */
#define SQLUD_BAD_VERSION              -2514   /* restored database wrong     */
                                               /* version                     */
#define SQLUD_INSAUTH                  -2515   /* insuffic authority to       */
                                               /* restore                     */
#define SQLUD_DBACT                    -2516   /* a database active           */
#define SQLUD_MIGRATED                 2517    /* database migrated           */
#define SQLUD_RST_DBCONG_ERR           -2518   /* error in restoring DB       */
                                               /* config.                     */
#define SQLUD_MIGRATE_ERROR            -2519   /* error in migrating the      */
                                               /* database                    */
#define SQLUD_DBCON_WARN               2520    /* DBCON file is restored      */
                                               /* using the backup version    */
#define SQLUD_DEL_BRG_ERR              2521    /* Restore process is          */
                                               /* successful, but unable to   */
                                               /* delete BRG file             */
#define SQLUD_TOO_MANY_BACKUP_FILES    -2522   /* more than one file match    */
#define SQLUD_MEDIA_CORRUPT            -2530   /* corrupted backup image      */
#define SQLUD_WRGIMAGE_ERROR           -2532   /* image of wrong database     */
#define SQLUD_WRGIMAGE_WARNING         2533    /* image of wrong database     */
#define SQLUD_WRONGSEQ_WARNING         2536    /* seq number of backup        */
                                               /* incorrect                   */
#define SQLUD_MUST_ROLLFWD             -2537   /* roll forward required       */
#define SQLUD_UNEXPECT_EOF_ERROR       -2538   /* end of file reached         */
                                               /* unexpectedly                */
#define SQLUD_NOINT_WARNING            2540    /* noint type restore had      */
                                               /* warning                     */
#define SQLUD_CLOSE_MEDIA_WARNING      2541    /* unable to close backup      */
                                               /* file                        */
#define SQLUD_NO_BACKUP_FILE_MATCH     -2542   /* no backup file match found  */
#define SQLUD_DB_DIR_ERROR             -2543   /* invalid directory for new   */
                                               /* dbase                       */
#define SQLUD_DISK_FULL_ERROR          -2544   /* disk full during restore    */
#define SQLUD_NOT_FIRST_IMAGE          -2546   /* restore requires first      */
                                               /* image first                 */
#define SQLUD_OLD_ONLINE_IMAGE_ERROR   -2547   /* cannot restore online       */
                                               /* backup from a previous      */
                                               /* release                     */
#define SQLUD_IMAGE_DB_CP_MISMATCH     -2548   /* backup has diff codepage    */
                                               /* from disk DB                */

/******************************************************************************
**  the meaning of the following 8 warnings :
**        A -> database alias
**        N -> database name
**        S -> database seed
**        0 -> target db value DOES NOT matches backup image value
**        1 -> target db value matches backup image value
** 
*******************************************************************************/
#define SQLUD_A0N0S0_WARNING           2529
#define SQLUD_A0N0S1_WARNING           2528
#define SQLUD_A0N1S0_WARNING           2525
#define SQLUD_A0N1S1_WARNING           2524
#define SQLUD_A1N0S0_WARNING           2527
#define SQLUD_A1N0S1_WARNING           2526
#define SQLUD_A1N1S0_WARNING           2523
#define SQLUD_A1N1S1_WARNING           2539
#define SQLUD_TBLSP_TO_OTHER_DB        -2560   /* restore tablespace to a     */
                                               /* non original database.      */
#define SQLUD_TBLSP_TO_NEW_DB          2561    /* restore tablespace to a     */
                                               /* new data base.              */
#define SQLUD_TBLSP_FR_FULL_BKUP       -2562   /* restore tablespace from     */
                                               /* full backup image.          */
#define SQLUD_NOTALL_TBS_RESTORED      2563    /* Not all tablespases were    */
                                               /* restored                    */
#define SQLUD_DB_MISMATCH              2565    /* Mismatch between restore    */
                                               /* image and database          */
                                               /* restored to                 */
#define SQLU_HEADER_WRITE_ERR          2045    /* Problem on first media      */
                                               /* write                       */

/* sqlgadau and sqluadau Return codes                                         */
#define SQLUA_BAD_INPUT_PARAMETER      -2600   /* sql_authorizations parm is  */
                                               /* bad                         */

/* Asynchronous Read Log SQLCODES                                             */
#define SQLU_RLOG_INVALID_PARM         -2650   /* invalid parameter(s)        */
                                               /* detected                    */
#define SQLU_RLOG_DB_NOT_READABLE      -2651   /* database has circular logs  */
#define SQLU_RLOG_INSUFF_MEMORY        -2652   /* insufficient memory for     */
                                               /* internal buffer             */
#define SQLU_RLOG_LSNS_REUSED           2653   /* log sequence numbers        */
                                               /* reused                      */
#define SQLU_RLOG_READ_TO_CURRENT       2654   /* read to end of database     */
                                               /* log                         */
#define SQLU_RLOG_EXTDB_INCORRECT      -2655   /* log extent not for this     */
                                               /* database                    */
#define SQLU_RLOG_INVALID_EXTENT       -2656   /* invalid extent encountered  */
#define SQLU_RLOG_EXTENT_REQUIRED      -2657   /* log reader requires an      */
                                               /* extent not in the log path  */

/* IMPORT/EXPORT Return codes                                                 */
#define SQLUE_DFO                      -3001   /* error opening output file   */
#define SQLUE_IOE                      -3002   /* i/o error writing output    */
                                               /* file                        */
#define SQLUE_CLS                      -3003   /* i/o error closing output    */
                                               /* file                        */
#define SQLUE_IFT                      -3004   /* invalid filetype parameter  */
#define SQLUE_CBI                      -3005   /* function interrupted        */
#define SQLUE_MFO                      -3006   /* i/o error opening message   */
                                               /* file                        */
#define SQLUE_MFW                      -3007   /* i/o error writing message   */
                                               /* file                        */
#define SQLUE_STA                      -3008   /* start using database        */
                                               /* failed                      */
#define SQLUE_STR                      -3009   /* invalid tcolstrg            */
#define SQLUE_COL                      -3010   /* invalid dcoldata            */

#define SQLUE_MEM                      -3011   /* memory allocation error     */
#define SQLUE_SYSERR                   -3012   /* system error                */
#define SQLUE_FTMOD                    -3013   /* invalid filetmod            */
#define SQLUE_MFC                      -3014   /* failure on closing message  */
                                               /* file                        */
#define SQLUE_SQLERR                   -3015   /* SQL error occurred          */
#define SQLUE_FMODNK                   -3016   /* no keywords found           */
#define SQLUE_FMODID                   -3017   /* invalid delimiter or        */
                                               /* duplicate                   */
#define SQLUE_FMODDEC                  -3018   /* decimal used for char       */
                                               /* delimiter                   */
#define SQLUE_NTS                      -3019   /* no tcolstrg                 */
#define SQLUE_RC_INSAUTH               -3020   /* insufficient authority for  */
                                               /* exp.                        */

#define SQLUI_RC_INSAUTH               -3021   /* insufficient authority for  */
                                               /* imp.                        */
#define SQLUE_SQL_PREP_ERR             -3022   /* SQL error on input string   */
#define SQLUE_DATABASE                 -3023   /* invalid database name       */
#define SQLUE_DATAFILE                 -3025   /* invalid datafile            */
#define SQLUE_MSGFILE                  -3026   /* invalid msgfile             */
#define SQLUE_DCOLMETH                 -3028   /* Export method indicator     */
                                               /* not n/d                     */
#define SQLUE_NUL_FTYPE                -3029   /* filetype is null            */

#define SQLUI_DFO                      -3030   /* error opening input data    */
                                               /* file                        */
#define SQLUI_IOE                      -3031   /* i/o error reading input     */
                                               /* file                        */
#define SQLUI_DCOLMETH                 -3032   /* Import method not n/d/p     */
#define SQLUI_TINSERT                  -3033   /* invalid insert in tcolstrg  */
#define SQLUI_TINTO                    -3034   /* invalid into in tcolstrg    */
#define SQLUI_TABLENAME                -3035   /* invalid tablename in        */
                                               /* tcolstrg                    */
#define SQLUI_CPAREN                   -3036   /* close paren not in          */
                                               /* tcolstrg                    */
#define SQLUE_SQL_PREP_INSERT          -3037   /* SQL error on insert string  */
#define SQLUI_TCOLJUNK                 -3038   /* tcolstrg invalid            */
#define SQLUE_LOBFILE_ERROR            -3040   /* lob file error              */

#define SQLUIC_BAD_DCOL_POS            -3045   /* invalid dcol position for   */
                                               /* CSV                         */
#define SQLUI_NONDEF_DCOL_NOCOLS       -3046   /* non-default dcol and no     */
                                               /* cols                        */
#define SQLUI_BAD_DCOL_METH            -3047   /* dcolinfo has invalid        */
                                               /* method                      */
#define SQLUI_NODCOL_FOR_NONNULL_DBCOL -3048   /* non nullable column         */
#define SQLUIC_UNSUPTYP_NONULLS        -3049   /* unsupported column type     */

#define SQLUII_CONVERSION              3050    /* conversion for cdpg         */
#define SQLUE_ROWCT_TOOBIG             -3053   /* too many rows for WSF       */
                                               /* export                      */
#define SQLUII_HEOF                    -3054   /* eof reading first rec in    */
                                               /* IXF                         */
#define SQLUII_HLEN_CONV               -3055   /* length of 'H' rec not       */
                                               /* numeric                     */
#define SQLUII_HLEN_SHORT              -3056   /* first record too short      */
#define SQLUII_HTYP                    -3057   /* first IXF rec is not 'H'    */
#define SQLUII_HID                     -3058   /* no IXF identifier in 'H'    */
#define SQLUII_HVERS                   -3059   /* invalid version field in    */
                                               /* 'H'                         */

#define SQLUII_HCNT                    -3060   /* HCNT in 'H' not numeric     */
#define SQLUII_HSBCP_BAD               -3061   /* SBCP in 'H' not numeric     */
#define SQLUII_HDBCP_BAD               -3062   /* DBCP in 'H' not numeric     */
#define SQLUII_HSBCP_CMP               -3063   /* 'H' SBCP not compat w/data  */
                                               /* SBCP                        */
#define SQLUII_HDBCP_CMP               -3064   /* 'H' DBCP not compat w/data  */
                                               /* DBCP                        */
#define SQLUII_DB_CODEPG               -3065   /* can't get codepages         */
#define SQLUII_TEOF                    -3066   /* eof reading/looking for     */
                                               /* 'T' rec                     */
#define SQLUII_TLEN_CONV               -3067   /* length of 'T' rec not       */
                                               /* numeric                     */
#define SQLUII_TLEN_SHORT              -3068   /* 'T' record is too short     */
#define SQLUII_TTYP                    -3069   /* first non-'A' rec not 'T'   */
                                               /* rec                         */

#define SQLUII_ALEN_BAD                -3070   /* invalid rec length of 'A'   */
                                               /* rec                         */
#define SQLUII_TCONV                   -3071   /* invalid data convention in  */
                                               /* 'T'                         */
#define SQLUII_TFORM                   -3072   /* invalid data format in 'T'  */
#define SQLUII_TMFRM                   -3073   /* invalid machine form in     */
                                               /* 'T'                         */
#define SQLUII_TLOC                    -3074   /* invalid data location in    */
                                               /* 'T'                         */
#define SQLUII_TCCNT                   -3075   /* 'C' rec cnt in 'T' not      */
                                               /* numeric                     */
#define SQLUII_TNAML                   -3076   /* name len fld in 'T' not     */
                                               /* numeric                     */
#define SQLUII_CCNT_HIGH               -3077   /* too many 'C' records        */
#define SQLUII_ALEN_CONV               -3078   /* length of 'A' rec not       */
                                               /* numeric                     */
#define SQLUII_CLEN_CONV               -3079   /* length of 'C' rec not       */
                                               /* numeric                     */

#define SQLUII_CLEN_SHORT              -3080   /* 'C' record is too short     */
#define SQLUII_CTYP                    -3081   /* wrong rec type / 'C'        */
                                               /* expected                    */
#define SQLUII_CEOF                    -3082   /* EOF while processing 'C'    */
                                               /* recs                        */
#define SQLUII_CDRID                   -3083   /* 'D' rec id field not        */
                                               /* numeric                     */
#define SQLUII_CPOSN                   -3084   /* 'D' rec posn field not      */
                                               /* numeric                     */
#define SQLUII_CIDPOS                  -3085   /* 'D' id/position not         */
                                               /* consistent                  */
#define SQLUII_NOCREC_FOR_NONNULL_DBCOL -3086  /* IXF column does not exist   */
#define SQLUII_INVCREC_NONNULL_DBCOL   -3087   /* IXF column not valid        */
#define SQLUII_CRECCOMP_NONNULL_DBCOL  -3088   /* IXF column not compatible   */
#define SQLUII_DTYP                    -3089   /* wrong rec type / 'D'        */
                                               /* expected                    */

#define SQLUII_DLEN_CONV               -3090   /* length of 'D' rec not       */
                                               /* numeric                     */
#define SQLUII_DLEN_RANGE              -3091   /* length of 'D' rec not       */
                                               /* valid                       */
#define SQLUII_DID                     -3092   /* invalid id field in 'D'     */
                                               /* rec                         */
#define SQLUIW_IFILE_INV               -3093   /* import file not valid WSF   */
#define SQLUIW_NNCOL_LOST              -3094   /* DOS non-nullable name not   */
                                               /* found                       */
#define SQLUIW_PCOL_INV                -3095   /* col position out of range   */
#define SQLUIW_UCOLTYP_NONUL           -3096   /* unsup col type - not        */
                                               /* nullable                    */
#define SQLUIW_RECLEN_INV              -3097   /* record length invalid       */
#define SQLUIW_INROW_INV               -3098   /* row number out of range     */
#define SQLUIW_INCOL_INV               -3099   /* col number out of range     */

#define SQLUE_COL_TOOBIG               3100    /* column longer than 254      */
                                               /* chars                       */
#define SQLUE_DATA_CHARDEL             3101    /* column has char delimiter   */
#define SQLUE_DCNUM_HIGH               3102    /* dcol column nbr > tcol      */
                                               /* number                      */
#define SQLUE_DCNUM_LOW                3103    /* dcol column nbr < tcol      */
                                               /* number                      */
#define SQLUE_WARNING                  3107    /* warning message issued      */

#define SQLUI_FEWER_DCOLS_DBCOLS_NULLED 3112   /* extra database cols         */
#define SQLUIC_UNSUPTYP_NULLABLE       3113    /* column will be nulled       */
#define SQLUIC_IGNORED_CHAR            3114    /* character ignored           */
#define SQLUIC_FIELD_TOO_LONG          3115    /* input CSV field too long    */
#define SQLUIC_CF_REQFIELD_MISSING     3116    /* field value missing         */
#define SQLUIC_CFINT2_NULLED           3117    /* smallint field nulled       */
#define SQLUIC_CFINT2_ROWREJ           3118    /* smallint field error        */
#define SQLUIC_CFINT4_NULLED           3119    /* int field nulled            */

#define SQLUIC_CFINT4_ROWREJ           3120    /* int field error             */
#define SQLUIC_CFFLOAT_NULLED          3121    /* float field nulled          */
#define SQLUIC_CFFLOAT_ROWREJ          3122    /* float field error           */
#define SQLUIC_CFDEC_NULLED            3123    /* decimal field nulled        */
#define SQLUIC_CFDEC_ROWREJ            3124    /* decimal field error         */
#define SQLUIC_CFTRUNC                 3125    /* char field truncated        */

#define SQLUIC_CFCHAR_NULLED           3126    /* char field nulled           */
#define SQLUIC_CFCHAR_ROWREJ           3127    /* char field error            */
#define SQLUIC_CFDATETRUNC             3128    /* date field truncated        */
#define SQLUIC_CFDTPAD                 3129    /* date/time/stamp field       */
                                               /* padded                      */

#define SQLUIC_CFTIMETRUNC             3130    /* time field truncated        */
#define SQLUIC_CFSTAMPTRUNC            3131    /* stamp field truncated       */
#define SQLUE_TRUNCATE                 3132    /* char field truncated        */
#define SQLUIC_ROWTOOSHORT             3137    /* not enough columns          */
#define SQLUIC_EOF_IN_CHARDELS         3138    /* end of input data file      */
#define SQLUE_SQLSTPDB_ERR             3139    /* stop using database failed  */

#define SQLUE_WSFLAB_LEN               3142    /* WSF label too big           */
#define SQLUE_CHAR_MTRUNC              3143    /* WSF char type length too    */
                                               /* long                        */
#define SQLUE_CHAR_WTRUNC              3144    /* WSF char type length too    */
                                               /* long                        */
#define SQLUE_CHAR_ITRUNC              3145    /* WSF char truncated at 240   */
#define SQLUE_ROWCT_LARGE              3147    /* row count exceeds 2048      */
#define SQLUE_3148                     3148    /* row not inserted            */

#define SQLUII_TCNTCMP                 3154    /* 'H' hcnt not equal 'T' rec  */
                                               /* ccnt                        */
#define SQLUII_CNAML                   3155    /* invalid name length in 'C'  */
                                               /* rec                         */
#define SQLUII_CNULL                   3156    /* invalid null field in 'C'   */
                                               /* rec                         */
#define SQLUII_CTYPE                   3157    /* invalid type field in 'C'   */
                                               /* rec                         */
#define SQLUII_CSBCP                   3158    /* invalid SBCP field in 'C'   */
                                               /* rec                         */
#define SQLUII_CDBCP                   3159    /* invalid DBCP field in 'C'   */
                                               /* rec                         */

#define SQLUII_CLENG                   3160    /* invalid col len fld in 'C'  */
                                               /* rec                         */
#define SQLUII_CPREC                   3161    /* invalid precision in 'C'    */
                                               /* rec                         */
#define SQLUII_CSCAL                   3162    /* invalid scale field in 'C'  */
                                               /* rec                         */
#define SQLUII_CFLOAT_BLANKLENG        3163    /* use 00008 for float col     */
                                               /* length                      */
#define SQLUII_CFLOAT_BADLENG          3164    /* invalid float col len in    */
                                               /* 'C'.                        */
#define SQLUII_CUTYPE                  3165    /* 'C' record has invalid      */
                                               /* type                        */
#define SQLUII_NOCREC_FOR_NULL_DBCOL   3166    /* IXF col does not exist      */
#define SQLUII_INVCREC_FOR_NULL_DBCOL  3167    /* IXF col is invalid          */
#define SQLUII_CRECCOMP_NULL_DBCOL     3168    /* IXF col not compatible      */

#define SQLUII_DEOF_INROW              3170    /* EOF found in row of data    */
#define SQLUIW_NONLAB_HDR              3171    /* non-label cell in hdr row   */
#define SQLUIW_NCOL_LOST               3172    /* nullable colnam not found   */
#define SQLUIW_UCOLTYP_NULL            3174    /* unsup col type - nullable   */
#define SQLUIW_INTYPE_INV              3175    /* wrong rec type for db col   */
#define SQLUIW_DATE_INV                3176    /* date value out of range     */
#define SQLUIW_TIME_INV                3177    /* time value out of range     */
#define SQLUIW_INTIME_INV              3178    /* int rec for time invalid    */
#define SQLUIW_NODATA_NNULL            3179    /* no data / non nullable col  */

#define SQLUE_INSERT_DISK              3180    /* insert diskette request     */
#define SQLUII_AE_NOTFOUND             3181    /* file ended before AE rec    */
#define SQLUII_INSERT_DISK_RETRY       3182    /* retry to insert diskette    */
#define SQLUEC_NOBLANK_B4KW            3183    /* mult del o'rides/no blanks  */
#define SQLUI_PREVMESG_ROWNO           3185    /* row of previous warning     */
#define SQLUI_LOGFULL_INSWARN          3186    /* log full inserting row      */
#define SQLUI_INDEX_WARN               3187    /* error creating index        */
#define SQLUI_TRUNCATE_TABLE           -3188   /* error truncating table      */

#define SQLUI_INDEXIXF                 -3190   /* invalid INDEXIXF option     */
#define SQLUI_VIEW_ERROR               -3193   /* cannot import to this view  */
#define SQLUI_SYSTBL_ERROR             -3194   /* cannot import system table  */
#define SQLUE_RETRY_DISK               3195    /* not enough space            */
#define SQLUI_IN_NOTFD                 -3196   /* input file not found        */
#define SQLUI_IMPBUSY                  -3197   /* import/export in use        */

#define SQLUI_REPL_PAR                 -3201   /* cant replace parent table   */
#define SQLUI_IUOPT_NOPK               -3203   /* cant update without PK's    */
#define SQLUI_IUOPT_NOVIEW             -3204   /* cant update views           */
#define SQLUI_VIEW_REF                 -3205   /* cant replace ref cons view  */
#define SQLUI_VIEW_SQUERY              -3206   /* cant replace subquery view  */

#define SQLUE_PROVIDE_FILE_PART        3220    /* AIX req next file           */
#define SQLUI_START_COMMIT             3221    /* start commit                */
#define SQLUI_FINISH_COMMIT            3222    /* finish commit               */
#define SQLUI_BAD_STRUCT_PARM          -3223   /* bad input parms             */
#define SQLUI_SKIPPED_ALL_ROWS         -3225   /* restartcnt too big          */
#define SQLUI_COMPOUND_ERR             -3250   /* compound=x error            */

#define SQLUIW_RCSEQ_INV               -3300   /* row/col sequence invalid    */
#define SQLUIW_BOF_INV                 -3301   /* BOF in middle of WSF file   */
#define SQLUIW_EARLY_EOF               -3302   /* unexpected EOF              */
#define SQLUI_IXFONLY                  -3303   /* filetype not ixf            */
#define SQLUI_DELTABLE                 -3304   /* table does not exist        */
#define SQLUI_CREATE_ERR               -3305   /* table already exists        */
#define SQLUI_EXECUTE_ERR              -3306   /* SQL error during insert     */
#define SQLUI_INC_COL                  -3307   /* incomplete col info         */
#define SQLUI_CP_MISMATCH              -3308   /* codepage mismatch           */
#define SQLUI_DBLDATA                  -3309   /* double byte data found      */

#define SQLUI_UNREC_CTYPE              -3310   /* unrec col type              */
#define SQLUI_INVCREC_FOR_CREATE       -3310   /* invalid IXF column          */

#define SQLUE_DISK_FULL_DB2OS2         -3313   /* disk full - OS/2            */
#define SQLUE_DISK_FULL_DB2NT          -3313   /* disk full - Windows NT      */
#define SQLUE_DISK_FULL_DB2DOS         -3313   /* disk full - DOS             */
#define SQLUE_DISK_FULL_DB2WIN         -3313   /* disk full - Windows         */
#define SQLUE_DISK_FULL_DB2AIX         -10018  /* disk full - AIX             */
#define SQLUE_DISK_FULL_DB2MAC         -3313   /* disk full - MacOS           */

#define SQLUE_DISK_FULL                SQLUE_DISK_FULL_DB2AIX

#define SQLUII_ASTAMP_NOMATCH          -3314   /* 'A' data/ time not as 'H'.  */
#define SQLUII_ACREC_BADVOL            -3315   /* invalid volume info         */
#define SQLUII_CLOSE_NOTLAST           -3316   /* error closing IXF file      */
#define SQLUW_FTMOD_INV                -3317   /* conflict in filetmod        */
#define SQLUEC_DUP_KEYWORD             -3318   /* keyword repeated/filetmod   */
#define SQLUI_ERR_CREATETAB            -3319   /* error creating table        */

#define SQLUEC_NOROOM_AFTERKW          -3320   /* keyword at end of filetmod  */
#define SQLUI_LOGFULL_INSERR           -3321   /* circular log full           */
#define SQLUE_SEM_ERROR                -3322   /* semaphore error             */
#define SQLUE_INVCOLTYPE               -3324   /* column type invalid         */
#define SQLUEW_IGNORED_ROW             3325    /* ignored WSF row             */
#define SQLUI_COL_LIST                 -3326   /* column list invalid         */
#define SQLUEI_SYSERROR                -3327   /* system error                */

#define SQLUII_ODD2GRAPH               3330    /* odd leng char -> graphic    */
#define SQLUE_OEACCESS                 -3331   /* permission denied           */
#define SQLUE_OEMFILE                  -3332   /* too many files open         */
#define SQLUE_OENOENT                  -3333   /* no such file or directory   */
#define SQLUE_OENOMEM                  -3334   /* not enough memory           */
#define SQLUE_OENOSPC                  -3335   /* no space left               */

#define SQLUIA_BAD_DCOL_METH           -3400   /* invalid method for ASC      */
#define SQLUI_DCOLM_ALL                -3401   /* invalid import method       */
#define SQLUIA_NULLLOC                 -3402   /* zeroes as begin/end         */
#define SQLUIA_LOCPAIR                 -3403   /* invalid pair                */
#define SQLUIA_LOCNUM                  -3404   /* invalid pair for number     */
#define SQLUIA_LOCDATE                 -3405   /* invalid pair for date       */
#define SQLUIA_LOCTIME                 -3406   /* invalid pair for time       */
#define SQLUIA_LOCSTAMP                -3407   /* invalid pair for timestamp  */
#define SQLUIA_LOCLONG                 3408    /* pair defines long field     */
#define SQLUIA_LOCSHORT                3409    /* pair defines short field    */
#define SQLUIA_LOCODD                  -3410   /* invalid pair for graphic    */
#define SQLUIA_CFGRAPH_NULLED          3411    /* value not graphic--null     */
#define SQLUIA_CFGRAPH_ROWREJ          3412    /* value not graphic--not      */
                                               /* null                        */
#define SQLUIA_SHORTFLDNULLED          3413    /* field too short--nulled     */

#define SQLU_TOO_MANY_WARNINGS         3502    /* number of warnings hit      */
                                               /* threshold                   */
#define SQLU_ROWCNT                    3503    /* number of rows hit          */
                                               /* threshold                   */
#define SQLULA_INVALID_RECLEN          -3505   /* reclen > 32767              */
#define SQLULA_NULLIND_IGNORED         3506    /* null ind value not Y or N   */
#define SQLUI_NULLIND                  -3507   /* nullind column is invalid   */
#define SQLUL_FILE_ERROR               -3508   /* file access error during    */
                                               /* load                        */
#define SQLUL_NUM_ROW_DELETED          3509    /* num of row deleted after    */
                                               /* load                        */
#define SQLU_SORT_WORK_DIR_ERROR       -3510   /* work directory is invalid   */
#define SQLU_NB_LOBFILE_MISSING        3511    /* lobfile missing but         */
                                               /* nullable col                */
#define SQLU_NNB_LOBFILE_MISSING       3512    /* lobfile missing,            */
                                               /* nonnullable col             */
#define SQLUL_UNMATCHED_CODEPAGE       -3513   /* codepage doesn't match db   */
#define SQLUL_SYSERR_WITH_REASON       -3514   /* system error with reason    */
                                               /* code                        */
#define SQLUL_UNEXPECTED_RECORD        -3517   /* unexpected rec in db2cs     */
#define SQLUL_INCOMPATIBLE_TABLE       -3518   /* coltype incompatible for    */
                                               /* db2cs                       */
#define SQLUL_FILE_NOT_FOUND           -3521   /* missing file                */
#define SQLUL_COPY_LOGRETAIN_OFF       -3522   /* copy spec, no logretain     */
                                               /* userexit                    */
#define SQLUL_NO_MESSAGES              3523    /* no messages to be           */
                                               /* retrieved                   */
#define SQLUL_FREESPACE_OPT            -3524   /* freespace option invalid    */
#define SQLU_INCOMPAT_OPT              -3525   /* incompatible options        */
#define SQLU_NEXT_TAPE_WARNING         3700    /* mount new tape              */
#define SQLU_LOBPATHS_IGNORED          3701    /* no lobs/longs but lobpath   */
                                               /* nonull                      */
#define SQLU_DEVICE_IGNORED            3702    /* device error but ignored    */
#define SQLU_NUM_BUFFERS               -3704   /* invalid number of buffers   */
#define SQLU_BUFFER_SIZE_ERROR         -3705   /* invalid load/unload buffer  */
                                               /* size                        */
#define SQLUL_DISK_FULL                -3706   /* copy target full            */
#define SQLU_SORT_BUFFSIZE_ERROR       -3707   /* invalid sort buffer size    */

/* Load / unload / load recovery SQLCODES                                     */
#define SQLU_OPEN_COPY_LOC_FILE_ERROR  -3783
#define SQLU_INV_COPY_LOC_FILE_INPUT   -3784
#define SQLU_LOAD_RECOVERY_FAILED      -3785
#define SQLU_INVALID_PARM_WARNING      3798
#define SQLU_LOAD_RECOVERY_PENDING     3799

/* load recovery - copy location input error type                             */
#define SQLU_KEYWORD_CODE              1
#define SQLU_OVERRIDE_CODE             2
#define SQLU_UNEXPECTED_EOF_CODE       3
#define SQLU_IOERROR_CODE              4

/* Loadapi SQLCODES                                                           */
#define SQLU_INVALID_QUIESCEMODE       -3802
#define SQLU_INVALID_INDEX             -3804
#define SQLU_INVALID_LOADAPI_ACTION    -3805
#define SQLU_CONSTRAINTS_NOT_OFF       -3806
#define SQLU_NO_LIFEBOAT               -3414

/* Export SQLCODES                                                            */
#define SQLUE_MSG                      -3999   /* Export message              */

/* Roll-Forward Recovery SQLCODES                                             */
#define SQLU_INVALID_PARAM             -4904   /* invalid parameter           */
#define SQLU_INVALID_RANGE             -4905   /* invalid parameter range     */

/* Configuration SQLCODES                                                     */
#define SQLF_RC_SYSAUTH                -5001   /* only SYSADM_GROUP can       */
                                               /* change db2 configuration    */
                                               /* file                        */
#define SQLF_RC_SYSERR                 -5005   /* system error                */
#define SQLF_RC_PATHNAME               -5010   /* path name error             */
#define SQLF_RC_INVNODENAME            -5020   /* invalid node name           */
#define SQLF_RC_INVSYSIDX              -5021   /* invalid system flag         */
#define SQLF_RC_INVDBIDX               -5022   /* invalid database flag       */
#define SQLF_RC_KCON                   -5025   /* not current db2             */
                                               /* configuration               */
#define SQLF_RC_INVSYSADM              -5028   /* invalid sysadm_group        */
#define SQLF_RC_REL                    -5030   /* invalid release number      */
#define SQLF_RC_NEEDMIG                -5035   /* database needs migration;   */
                                               /* release number is back      */
                                               /* level                       */

#define SQLF_RC_INSMEM                 -5047   /* insufficient memory to      */
                                               /* support stack switching     */
#define SQLF_RC_SYSCSUM                -5050   /* invalid db2 configuration   */
                                               /* file                        */
#define SQLF_RC_DBCSUM                 -5055   /* invalid db configuration    */
                                               /* file                        */
#define SQLF_RC_INVTKN                 -5060   /* invalid token parameter     */
#define SQLF_RC_INVTKN_STRUCT          -5061   /* invalid ptr to sqlfupd      */
#define SQLF_RC_INVTKN_PTR             -5062   /* invalid token ptr value     */
#define SQLF_RC_INVNT                  -5065   /* invalid node type           */
#define SQLF_RC_CNTINV                 -5070   /* invalid count parameter     */
#define SQLF_RC_CNTBRK                 -5075   /* interrupt received          */
#define SQLF_RC_INVILF                 -5083   /* invalid initial log size    */

#define SQLF_RC_INVLFE                 -5091   /* invalid logfile extention   */
#define SQLF_RC_INVNLE                 -5092   /* invalid # of log extention  */
#define SQLF_RC_INVNEWLOGP             -5099   /* invalid new log path        */

#define SQLF_RC_INVDB1                 -5101   /* incompatible logfile        */
                                               /* parameter                   */
#define SQLF_RC_INV_BIT_VALUE          -5112   /* invalid bit value - must    */
                                               /* be 0 or 1                   */

#define SQLF_RC_LF_1_3                 -5120   /* both R1 & R3 Log            */
                                               /* parameters may not be       */
                                               /* modified                    */
#define SQLF_RC_INVDETS                -5121   /* invalid DB configuration    */
                                               /* details                     */
#define SQLF_RC_PROTECT                -5122   /* database is copy protected  */
#define SQLF_RC_LOGIO                  -5123   /* I/O Error with log header   */
#define SQLF_RC_INV_DBMENT             -5126   /* invalid db2 config file     */
                                               /* entry                       */
#define SQLF_RC_INV_RANGE              -5130   /* integer out of range        */
#define SQLF_RC_INV_RANGE_2            -5131   /* integer out of range (-1)   */
#define SQLF_RC_INV_STRING             -5132   /* string null or too long     */
#define SQLF_RC_INV_SET                -5133   /* char/int not in set         */
#define SQLF_RC_INVTPNAME              -5134   /* tpname not valid            */
#define SQLF_RC_LOW_APPLS_AND_LOCKS    -5135   /* maxappls*maxlocks too low   */
#define SQLF_RC_INV_DBPATH             -5136   /* dftdbpath not valid         */
#define SQLF_RC_INV_DIAGPATH           -5137   /* diagpath not valid          */
#define SQLF_RC_MAX_ITEMS_EXCEEDED     -5139   /* To many items on update or  */
                                               /* get                         */
#define SQLF_RC_INV_AUTHENTICATION     -5140   /* invalid authentication      */
#define SQLF_RC_INV_AVG_APPLS          -5141   /* invalid AVG_APPLS           */
#define SQLF_RC_INV_AGENTPRI           -5131   /* invalid agent priority      */
#define SQLF_RC_INV_RANGE_MAX_EXPR     -5144   /* out of range - maximum      */
                                               /* limited by an expression    */
#define SQLF_RC_INV_RANGE_MAX_EXPR_2   -5145   /* out of range - maximum      */
                                               /* limited by an expression    */
                                               /* (range includes -1)         */
#define SQLF_RC_INV_RANGE_MIN_EXPR     -5146   /* out of range - minimum      */
                                               /* limited by an expression    */
#define SQLF_RC_INV_RANGE_MIN_EXPR_2   -5147   /* out of range - minimum      */
                                               /* limited by an expression    */
                                               /* (range includes -1)         */

/* Repository for obsolete Return Codes                                       */

#define SQLU_WRITE_ERROR               -2006   /* wrote wrong # of bytes      */
#define SQLU_CONNECT_ERROR             -2010   /* error in Start Using        */
#define SQLU_INT_ERROR                 -2012   /* error in ints               */
#define SQLUD_NO_MHEADER_ERROR         -2531   /* media header not present    */
#define SQLUD_NO_MHEADER_WARNING       2534    /* media header missing        */
#define SQLUD_NEXT_TAPE_WARNING        2535    /* another tape mount          */
                                               /* required                    */
#define SQLUD_ADSM_MOUNT_WAIT          2545    /* waiting for ADSM server to  */
                                               /* access data on removable    */
                                               /* media                       */

/******************************************************************************
** Configuration parameter obsolete return codes defines -  
** Some configuration parameters had specific out of range return
** codes; these have been replaced by generic out of range messages
** In these cases the old token names for the specific return codes
** are given, but the values are replaced by the new values returned 
** when out of range.
*******************************************************************************/

#define SQLF_RC_DBAUTH                 -5002   /* only SYSADM can             */
                                               /* changedatabase              */
                                               /* configuration file          */
#define SQLF_RC_INVNDB                 -5130   /* invalid # of concurrent db  */
#define SQLF_RC_INVRIO                 -5130   /* invalid req I/O blk size    */
#define SQLF_RC_INVSIO                 -5015   /* invalid serv I/O blk size   */
#define SQLF_RC_INVCHEAP               -5016   /* invalid communications      */
                                               /* heap                        */
#define SQLF_RC_INVRSHEAP              -5017   /* invalid remote services     */
                                               /* heap                        */
#define SQLF_RC_INVSHPTHR              -5130   /* invalid sort heap           */
                                               /* threshold                   */
#define SQLCC_RC_BAD_DB2COMM           -5036   /* invalid DB2COMM value       */
#define SQLCC_RC_NO_SERV_IN_DBMCFG     -5037   /* service name not definein   */
                                               /* db2 config file             */
#define SQLCC_RC_SERV_NOT_FOUND        -5038   /* service name not found in   */
                                               /* etc/services file           */
#define SQLCC_RC_INT_PORT_NOT_FOUND    -5039   /* interrupt port not found    */
                                               /* in/etc/services file        */
#define SQLCC_RC_SOCKADDR_IN_USE       -5040   /* socket address in use       */
#define SQLCC_RC_NO_TPN_IN_DBMCFG      -5041   /* trans program name not      */
                                               /* definedin db2               */
                                               /* configuration file          */
#define SQLCC_RC_COMM_SUPPORT_FAILED   -5042   /* general failure in          */
                                               /* servercommunications        */
                                               /* support                     */
#define SQLF_RC_INVNLL                 -5130   /* invalid # of locklist       */
#define SQLF_RC_INVNBP                 -5130   /* invalid # bufr pool pages   */
#define SQLF_RC_INVNDBF                -5130   /* invalid # of DB files open  */
#define SQLF_RC_INVSCP_DB2OS2          -5130   /* invalid soft check point    */
                                               /* value                       */
#define SQLF_RC_INVSCP_DB2AIX          -5130   /* invalid soft check point    */
                                               /* value                       */
#define SQLF_RC_INVSCP                 -5130   /* invalid soft check point    */
                                               /* value                       */
#define SQLF_RC_INVNAP                 -5130   /* invalid # of active appls   */
#define SQLF_RC_INVAHP                 -5130   /* invalid application heapsz  */
#define SQLF_RC_INVDHP                 -5130   /* invalid database heap size  */
#define SQLF_RC_INVDLT                 -5130   /* invalid deadlock detection  */
#define SQLF_RC_INVTAF                 -5130   /* invalid # of total files    */
                                               /* openper application         */
#define SQLF_RC_INVSHP                 -5130   /* invalid sortlist heap       */
#define SQLF_RC_INVMAL                 -5130   /* invalid maxlocks per        */
                                               /* application                 */
#define SQLF_RC_INVSTMHP               -5130   /* invalid statement heap      */
#define SQLF_RC_INVLOGPRIM             -5130   /* invalid number primary log  */
                                               /* files                       */
#define SQLF_RC_INVLOG2ND              -5130   /* invalid number of           */
                                               /* secondary log files         */
#define SQLF_RC_INVLOGFSZ              -5130   /* invalid log file size       */
#define SQLF_RC_INVDB2                 -5102   /* incompatible file open      */
                                               /* parmeter                    */
#define SQLF_RC_INVK2                  -5104   /* no DB's / requestor only    */
#define SQLF_RC_INVK3                  -5126   /* standalone nodetype does    */
                                               /* notsupport nodename         */
#define SQLF_RC_RWS_EXIST              -5106   /* remote workstation has      */
                                               /* alreadybeen configured      */
#define SQLF_RC_RWS_SYSADM             -5107   /* <authid> does not           */
                                               /* haveauthority to add or     */
                                               /* drop a remote workstation   */
#define SQLF_RC_RWS_NOT_EXIST          -5108   /* remote workstation has      */
                                               /* notbeen previously setup    */
                                               /* using sqlarws               */
#define SQLF_RC_RWS_MACHINENAME        -5109   /* machine name is missing     */
                                               /* ors too long.               */
#define SQLF_RC_RWS_INV_OPT            -5110   /* configuration option is     */
                                               /* invalid                     */
#define SQLF_RC_ENV_VAR_NOTDEF         -5111   /* environment                 */
                                               /* variableDB2WKSTPROF is not  */
                                               /* defined                     */
#define SQLF_RC_INVDB3                 -5146   /* incompatible buffer pool    */
                                               /* and maximum # of            */
                                               /* applications                */
#define SQLF_RC_INV_QUERY_HEAP_SZ      -5143   /* invalid QUERY_HEAP_SZ       */
#define SQLF_RC_INV_RANGE_3            -5144   /* out of range - limited by   */
                                               /* a parm                      */

/* obsolete database manager configuration parameter tokens                   */
#define SQLF_KTN_SVRIOBLK              3
#define SQLF_KTN_SQLENSEG              5
#define SQLF_KTN_COMHEAPSZ             8
#define SQLF_KTN_RSHEAPSZ              9
#define SQLF_KTN_NUMRC                 10
#define SQLF_KTN_CUINTERVAL            14
#define SQLF_KTN_COMHEAPSZ_P           50
#define SQLF_KTN_RSHEAPSZ_P            51
#define SQLF_KTN_IPX_FILESERVER        SQLF_KTN_FILESERVER
#define SQLF_KTN_IPX_OBJECTNAME        SQLF_KTN_OBJECTNAME

/* obsolete database configuration parameter tokens                           */
#define SQLF_DBTN_LOGFILE              4
#define SQLF_DBTN_MAXTOTFILOP          10
#define SQLF_DBTN_LOGEXT               12
#define SQLF_DBTN_LOGMAXEXT            13
#define SQLF_DBTN_AGENTHEAP            14
#define SQLF_DBTN_SEGPAGES             123
#define SQLF_DBTN_BUFFPAGE             2
#define SQLF_DBTN_SORTHEAP             91
#define SQLF_DBTN_SORTHEAPSZ_P         SQLF_DBTN_SORT_HEAP
#define SQLF_DBTN_DBHEAP_P             SQLF_DBTN_DBHEAP
#define SQLF_DBTN_APPLHEAPSZ_P         SQLF_DBTN_APPLHEAPSZ
#define SQLF_DBTN_STMTHEAPSZ_P         SQLF_DBTN_STMTHEAP


/* Repository for obsolete prototypes                                         */

SQL_API_RC SQL_API_FN
  sqlfeudb (
   _SQLOLDCHAR *,                           /* database                       */
   _SQLOLDCHAR *,                           /* password                       */
   unsigned short,                          /* count                          */
   struct sqlfupd *,                        /* list of items                  */
   struct sqlca *);                         /* SQLCA                          */

SQL_API_RC SQL_API_FN                       /* Update Database Configuration  */
  sqlgeudb (
   unsigned short,                          /* reserved                       */
   unsigned short,                          /* database alias length          */
   unsigned short,                          /* number of entries being        */
                                            /* modified                       */
   unsigned short *,                        /* list of item lengths           */
   struct sqlfupd *,                        /* list of items                  */
   struct sqlca *,                          /* SQLCA                          */
   _SQLOLDCHAR *,                           /* reserved                       */
   _SQLOLDCHAR *);                          /* database alias                 */

SQL_API_RC SQL_API_FN                       /* Reset Database Configuration   */
  sqlgrdbc (
   unsigned short,                          /* Spare1                         */
   unsigned short,                          /* Database name length           */
   struct sqlca *,                          /* SQLCA                          */
   _SQLOLDCHAR *,                           /* Spare2                         */
   _SQLOLDCHAR *);                          /* database                       */

SQL_API_RC SQL_API_FN                       /* Return Database Configuration  */
  sqlgxdbc (
   unsigned short,                          /* Spare1                         */
   unsigned short,                          /* Database name length           */
   unsigned short,                          /* count                          */
   struct sqlfupd *,                        /* list of items                  */
   struct sqlca *,                          /* SQLCA                          */
   _SQLOLDCHAR *,                           /* Spare2                         */
   _SQLOLDCHAR *);                          /* Database                       */

/******************************************************************************
** 
** The following functions and symbols are obsolete and may not be supported
** in future releases. The obsolete functions are provided for backward compatibility
** and exported from DB2API.LIB. All applications should be migrated to use new APIs.
** Note: Some of the function parameters may be NO-OP.
** 
*******************************************************************************/
SQL_API_RC SQL_API_FN
  sqlfrdbc (
        _SQLOLDCHAR *,                         /* database                    */
        _SQLOLDCHAR *,                         /* password                    */
        struct sqlca *);                       /* SQLCA                       */

SQL_API_RC SQL_API_FN
  sqlfxdbc (
        _SQLOLDCHAR *,                         /* database alias              */
        _SQLOLDCHAR *,                         /* password                    */
        unsigned short,                        /* count of entries being      */
                                               /* returned                    */
        struct sqlfupd *,                      /* list of items               */
        struct sqlca *);                       /* SQLCA                       */

#define SLQUI_TINTO                    SQLUI_TINTO /* invalid into in         */
                                               /* tcolstrg                    */
/******************************************************************************
** 
** End of obsolete functions and symbols
** 
*******************************************************************************/
#pragma options align=reset

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLUTIL */
  k   $         Q1Q1[U1         5       ./usr/lpp/db2_02_01/samples/c/db2mon.c .                    $          /*******************************************************************************
**
** Source File Name = db2mon.c  %I%
**
** Licensed Materials - Property of IBM
**
** (C) COPYRIGHT International Business Machines Corp. 1995
** All Rights Reserved.
**
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
**
**
** PURPOSE: This sample program demonstrates how to use the Database
**          System Monitor APIs, and how to process the output data
**          buffer returned from the Snapshot API.
**          It is a menu-driven program that allows the user to
**          access all the functionality of the Database System
**          Monitor APIs:
**            - Turn ON/OFF any of the monitoring groups
**            - Reset data areas for specific databases or all
**              active databases
**            - Monitor DB2 activity in a wide variety of
**              object combinations.
**
** MAKE:  To create an executable, complete the following:
**          1)  enter "bldmon" from the command line
**
** RUN:   To run this sample, just enter "db2mon" and follow the
**        on-screen menus. Ensure that DB2 has been started
**        before attempting to monitor any activity.
**
**    EXTERNAL DEPENDENCIES :
**       - Existing database for precompile purposes.
**       - Precompile with the SQL precompiler (PREP in DB2)
**       - Binding to a database (BIND in DB2)
**       - Compiling and linking with the IBM Cset++ compiler (AIX and OS/2)
**         or the Microsoft Visual C++ compiler (Windows) 
**         or the compiler supported on your platform.
**
*******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "sqlenv.h"
#include "sql.h"
#include "sqlmon.h"
#include "sqlca.h"
#include "sqlutil.h"

#if (defined(DB2AIX) || defined(DB2SUN) || defined(DB2HP) || defined(DB2SNI))
   #define CLEARSCR      "clear"
   #define min(a, b) ((a < b) ? a : b)
#else
   #define CLEARSCR      "cls"
#endif


/*****************************************************************************/
/* Constants definitions                                                     */
/*****************************************************************************/
#define SCREEN_OUTPUT   1                   /* output data to screen         */
#define FILE_OUTPUT     2                   /* output data to user file      */

/*****************************************************************************/
/* Internal Function Prototypes                                              */
/*****************************************************************************/
int dbmon_switch();
int dbmon_reset();
int dbmon_snapshot();
void pause();
void clrscrn();
void pr_sqlca(struct sqlca *);
void process_db2();
void process_dbase();
void process_appl();
void process_applinfo();
void process_dcs_applinfo();
void process_table();
void process_lock();
void process_tablespace();
void cleanup(struct sqlma *ma_ptr);

/*****************************************************************************/
/*  Global Variables                                                         */
/*****************************************************************************/

FILE                  *outstream;       /* output stream if directed to file */
unsigned int          output_opt = SCREEN_OUTPUT; /* output to screen or file*/

struct sqlm_collected collected;        /* returned sqlm_collected structure */
char                  *buffer_ptr = NULL; /* buffer returned from snapshot   */
char                  *buffer_index;    /* current position in buffer        */
unsigned long          buffer_sz;       /* Estimated buffer size             */

/*****************************************************************************/
/* MAIN routine.                                                             */
/*****************************************************************************/

void main( int argc, char *argv[], char *envp[])
{

   int                   ssout= 0;            /* exit flag                  */
   int                   ssrc= 0;             /* program return code        */
   unsigned int          numsel = 999;        /* numeric input selection    */


   /*************************************************************************/
   /* initialize outstream for screen output                                */
   /*************************************************************************/
   outstream = stdout;

   /*************************************************************************/
   /* Perform main loop until users wants to exit.                          */
   /*************************************************************************/

   while (!ssout)
   {
      clrscrn();
      printf("******************************************************************************\n");
      printf("****                                                                      ****\n");
      printf("****                 DB2 DATABASE MONITOR SAMPLE PROGRAM                  ****\n");
      printf("****                                                                      ****\n");
      printf("******************************************************************************\n");

      while (numsel < 0 || numsel > 3)
      {
         printf("\nPlease choose one of the following options:\n\n");
         printf("    1 - Turn ON/OFF monitoring switches\n");
         printf("    2 - Reset data areas\n");
         printf("    3 - Get a Snapshot\n");
         printf("    0 - Exit the Database Monitor sample program\n");

         fflush(stdin);
         scanf("%u", &numsel);
         if (numsel < 0 || numsel > 3)
            printf("\nInvalid selection. Please choose again.\n");

      }  /* while */

      /**********************************************************************/
      /* Process user selection                                             */
      /**********************************************************************/
      switch (numsel)
      {
         case 0:
              ssout = 1;
              break;

         case 1:
              ssrc = dbmon_switch();
              if (ssrc != 0)
              {
                 printf("\nreturn code from dbmon_switch : %i\n", ssrc);
                 pause();
              }
              break;

         case 2:
              ssrc = dbmon_reset();
              if (ssrc != 0)
              {
                 printf("\nreturn code from dbmon_reset : %i\n", ssrc);
                 pause();
              }
              break;

         case 3:
              ssrc = dbmon_snapshot();
              if (ssrc != 0)
              {
                 printf("\nreturn code from dbmon_snapshot : %i\n", ssrc);
                 pause();
              }
              break;

         default:
              break;

      }  /* switch numsel */

      numsel = 999;

   }  /* while !ssout */

   return;
}


/*****************************************************************************/
/* dbmon_switch.                                                             */
/* This function is called when the user wants to turn ON or OFF any of      */
/* the Database Monitor groups.                                              */
/*****************************************************************************/

int dbmon_switch()
{

   unsigned int          numsel = 999;        /* numeric input selection    */
   unsigned int          numsel2 = 999;       /* numeric input selection    */
   unsigned int          i;                   /* loop counter               */
   int                   rc = 0;              /* return code                */
   struct sqlca          sqlca;
   struct sqlm_recording_group states[SQLM_NUM_GROUPS];

   clrscrn();
   printf("******************************************************************************\n");
   printf("*                         Database Monitor Switch                            *\n");
   printf("******************************************************************************\n");

   /********************************************************/
   /* Query the current state of the switches              */
   /********************************************************/
   for (i = 0; i < SQLM_NUM_GROUPS; i++)
   {
      states[i].input_state = SQLM_HOLD;
   }
   rc = sqlmon(SQLM_DBMON_VERSION2, NULL, states, &sqlca);
   if (rc != 0)
   {
      printf("\nReturn code from SQLMON is %d \n", rc);
      return(rc);
   }

   if (sqlca.sqlcode != 0L)
   {
      printf("\nSqlcode from SQLMON is not 0. \n");
      pr_sqlca(&sqlca);
   }

   /********************************************************/
   /* Display the current state of the switches            */
   /********************************************************/
   printf("\nCurrent Switch settings:\n");

   printf("1 - UOW Switch state       : %s %24.24s\n", (states[0].output_state) ? "ON , start time :" : "OFF",
                                     (states[0].start_time.seconds) ? ctime((time_t *)&states[0].start_time.seconds) : "");
   printf("2 - STMT Switch state      : %s %24.24s\n", (states[1].output_state) ? "ON , start time :" : "OFF",
                                     (states[1].start_time.seconds) ? ctime((time_t *)&states[1].start_time.seconds) : "");
   printf("3 - TABLE Switch state     : %s %24.24s\n", (states[2].output_state) ? "ON , start time :" : "OFF",
                                     (states[2].start_time.seconds) ? ctime((time_t *)&states[2].start_time.seconds) : "");
   printf("4 - BUFF POOL Switch state : %s %24.24s\n", (states[3].output_state) ? "ON , start time :" : "OFF",
                                     (states[3].start_time.seconds) ? ctime((time_t *)&states[3].start_time.seconds) : "");
   printf("5 - LOCK Switch state      : %s %24.24s\n", (states[4].output_state) ? "ON , start time :" : "OFF",
                                     (states[4].start_time.seconds) ? ctime((time_t *)&states[4].start_time.seconds) : "");
   printf("6 - SORT Switch state      : %s %24.24s\n", (states[5].output_state) ? "ON , start time :" : "OFF",
                                     (states[5].start_time.seconds) ? ctime((time_t *)&states[5].start_time.seconds) : "");


   for (i = 0; i < SQLM_NUM_GROUPS; i++)
   {
      states[i].input_state = SQLM_HOLD;
   }

   /**************************************************************/
   /* loop to let user select switches to be turned ON or OFF    */
   /**************************************************************/
   do
   {
      printf("\nPlease enter the switch number you wish to set:\n");
      printf("This function toggles the switch state ON/OFF.\n");
      printf("   Enter 0 when you are done with your selections.\n");

      fflush(stdin);
      scanf("%u", &numsel);
      if (numsel < 0 || numsel > 6)
         printf("\nInvalid selection. Please try again.\n");
      else
         if (numsel != 0)
         {
            if (states[numsel-1].output_state == SQLM_ON)
                states[numsel-1].input_state = SQLM_OFF;
            else
                states[numsel-1].input_state = SQLM_ON;

         } /* if */

   } while (numsel != 0);

   /********************************************************/
   /* Set new switch states                                */
   /********************************************************/
   rc = sqlmon(SQLM_DBMON_VERSION2, NULL, states, &sqlca);
   if (rc != 0)
   {
      printf("\nReturn code from SQLMON is %d \n", rc);
      return(rc);
   }

   if (sqlca.sqlcode != 0L)
   {
      printf("\nSqlcode from SQLMON is not 0. \n");
      pr_sqlca(&sqlca);
      if (sqlca.sqlcode < 0L)             /* negative sqlcodes are errors    */
      {
         printf("Negative sqlcode... exiting\n");
         return((int)sqlca.sqlcode);
      }
      pause();
   }

   /********************************************************/
   /* Display new switch states                            */
   /********************************************************/
   printf("\nNew states:\n");
   printf("1 - UOW Switch state       : %s %24.24s\n", (states[0].output_state) ? "ON , start time :" : "OFF",
                                     (states[0].start_time.seconds) ? ctime((time_t *)&states[0].start_time.seconds) : "");
   printf("2 - STMT Switch state      : %s %24.24s\n", (states[1].output_state) ? "ON , start time :" : "OFF",
                                     (states[1].start_time.seconds) ? ctime((time_t *)&states[1].start_time.seconds) : "");
   printf("3 - TABLE Switch state     : %s %24.24s\n", (states[2].output_state) ? "ON , start time :" : "OFF",
                                     (states[2].start_time.seconds) ? ctime((time_t *)&states[2].start_time.seconds) : "");
   printf("4 - BUFF POOL Switch state : %s %24.24s\n", (states[3].output_state) ? "ON , start time :" : "OFF",
                                     (states[3].start_time.seconds) ? ctime((time_t *)&states[3].start_time.seconds) : "");
   printf("5 - LOCK Switch state      : %s %24.24s\n", (states[4].output_state) ? "ON , start time :" : "OFF",
                                     (states[4].start_time.seconds) ? ctime((time_t *)&states[4].start_time.seconds) : "");
   printf("6 - SORT Switch state      : %s %24.24s\n", (states[5].output_state) ? "ON , start time :" : "OFF",
                                     (states[5].start_time.seconds) ? ctime((time_t *)&states[5].start_time.seconds) : "");

   pause();

   return(0);

}  /* dbmon_switch() */

/*****************************************************************************/
/* dbmon_reset.                                                              */
/* This function is called when the user wants to reset Database Monitor     */
/* data areas.                                                               */
/*****************************************************************************/

int dbmon_reset()
{

   unsigned int          numsel = 999;                  /* numeric input selection    */
   unsigned long         reset_all;                     /* reset indicator            */
   int                   rc = 0;                        /* return code                */
   struct sqlca          sqlca;                         /* sqlca structure            */
   char                  db_alias[SQLM_IDENT_SZ];       /* input database alias       */

   clrscrn();
   printf("******************************************************************************\n");
   printf("*                         Database Monitor Reset                             *\n");
   printf("******************************************************************************\n");

   do
   {
      printf("\nDo you wish to reset data areas for :\n");
      printf("   1 - a specifc database, or\n");
      printf("   2 - all active databases ?\n");
      printf("   (Press 0 to exit to return to the previous menu)\n");

      fflush(stdin);
      scanf("%u", &numsel);
      if (numsel < 0 || numsel > 2)
         printf ("\nInvalid selection. Please try again.\n");
   } while (numsel < 0 || numsel > 2);

   switch (numsel)
   {
      case 0:
          return(0);
          break;
      case 1:
          reset_all = SQLM_OFF;
          printf("\nPlease enter the database alias of the database you wish to reset:\n");

          fflush(stdin);
          scanf("%s", db_alias);
          break;
      case 2:
          reset_all = SQLM_ON;
          break;
      default:
          printf("\nError in Reset... should not happen... exiting...\n");
          exit(99);
          break;
   }  /* switch numsel */

   /***************************************************************/
   /* Reset the Database Monitor data areas                       */
   /***************************************************************/
   rc = sqlmrset(SQLM_DBMON_VERSION2, NULL, reset_all, db_alias, &sqlca);

   if (rc != 0)
   {
      printf("\nReturn code from SQLMONRSET is %d \n", rc);
      return(rc);
   }

   if (sqlca.sqlcode != 0L)
   {
      printf("\nSqlcode from SQLMRSET is not 0. \n");
      pr_sqlca(&sqlca);
      if (sqlca.sqlcode < 0L)             /* negative sqlcodes are errors    */
      {
         printf("Negative sqlcode... exiting\n");
         return((int)sqlca.sqlcode);
      }
   }
   else
      printf("\nReset was successful. \n");

   pause();

   return(0);

}  /* dbmon_reset() */

/*****************************************************************************/
/* dbmon_snapshot                                                            */
/* This function is called when the user wishes to perform a Database        */
/* Monitor Snapshot.                                                         */
/* The user will select the types of information the snapshot will collect   */
/* and return in the buffer.                                                 */
/*****************************************************************************/

int dbmon_snapshot()
{

   long                  ltime;
   unsigned int          ma_sz;               /* size of sqlma structure    */
   unsigned int          input_opt;
   unsigned int          obj_num = 0;         /* # of objects to monitor    */
   unsigned int          numstruct = 0;       /* # of structures returned   */
   unsigned int          i;                   /* loop counter               */
   int                   rc = 0;              /* return code                */
   int                   ssrc= 0;             /* driver return code         */
   char                  outfilename[81];     /* name for data output file  */
   struct sqlca          sqlca;
   struct sqlma          *ma_ptr = NULL;      /* sqlma structure pointer    */

   struct ma_unit                             /* working sqlma element      */
   {
      unsigned long      agent_id;
      unsigned long      obj_type;
      char               object[SQLM_OBJECT_SZ];
      struct ma_unit     *next;
   };

   struct ma_unit        ma_unit_head;
   struct ma_unit        *ma_unit_ptr;
   struct ma_unit        *free_ptr;


   /**************************************************************************/
   /* Initialize various character arrays to nulls                           */
   /**************************************************************************/

   memset(&collected, '\0', sizeof(struct sqlm_collected));
   memset(outfilename, '\0', sizeof(outfilename));

   /**************************************************************************/
   /* Prompt the user for the tpyes of objects to monitor                    */
   /**************************************************************************/

   do {

      clrscrn();
      printf("******************************************************************************\n");
      printf("*                         Database Monitor Snapshot                          *\n");
      printf("******************************************************************************\n");

      printf("\nPlease choose the type of object to monitor.\n");
      printf("You can choose as many as you want, one at a time\n");
      printf("\n  Enter 0 when done with your selections\n");
      printf("   1 --- General information for DB2\n");
      printf("   2 --- Information for a specific DATABASE\n");
      printf("   3 --- Information for a specific APPLICATION (by APPL-ID)\n");
      printf("   4 --- Information for a specific APPLICATION (by AGENT-ID)\n");
      printf("   5 --- TABLE information for a specific database\n");
      printf("   6 --- APPLICATION information for a SPECIFIC DATABASE\n");
      printf("   7 --- SUMMARY APPLICATION information for a SPECIFIC DATABASE\n");
      printf("   8 --- LOCK information for a specific database\n");
      printf("   9 --- Information for ALL ACTIVE DATABASES\n");
      printf("  10 --- Information for ALL ACTIVE APPLICATIONS\n");
      printf("  11 --- SUMMARY information for ALL ACTIVE APPLICATIONS\n");
      printf("  12 --- Information for ALL ACTIVE DDCS APPLICATIONS\n");
      printf("  13 --- TABLESPACE information for a SPECIFIC DATABASE\n");
      printf("Please enter the number of your choice==> ");

      fflush(stdin);
      scanf("%u", &input_opt);

      /*******************************************************/
      /* If the user entered a vaild number, allocate        */
      /* memory for working temporary sqlma information      */
      /*******************************************************/
      if (input_opt > 0 && input_opt <= 13)
      {
         obj_num++;     /* increment # of objects to monitor */
         if (obj_num == 1)
         {
            ma_unit_ptr = &ma_unit_head;
         }
         else
         {
            ma_unit_ptr->next =
               (struct ma_unit *) malloc(sizeof(struct ma_unit));
            if (ma_unit_ptr->next != NULL)
            {
               ma_unit_ptr = ma_unit_ptr->next;
               memset(ma_unit_ptr, '\0', sizeof(struct ma_unit));
            }
            else
            {
               printf("error allocating ma_unit memory. Exiting\n");
               return(99);
            }
         } /* else */
      } /* if */

      /********************************************************/
      /* Fill in temporary sqlma info with user choice        */
      /********************************************************/
      switch (input_opt)
      {
        case 0:

          break;
        case 1:
          ma_unit_ptr->obj_type = SQLMA_DB2;
          ma_unit_ptr->agent_id = 0L;
          break;
        case 2:
          ma_unit_ptr->obj_type = SQLMA_DBASE;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 3 :
          ma_unit_ptr->obj_type = SQLMA_APPL;
          printf("\nPlease enter the application ID ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 4 :
          ma_unit_ptr->obj_type = SQLMA_AGENT_ID;
          printf("\nPlease enter the agent ID ==> ");

          fflush(stdin);
          scanf("%ul", &(ma_unit_ptr->agent_id));
          break;
        case 5:
          ma_unit_ptr->obj_type = SQLMA_DBASE_TABLES;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 6:
          ma_unit_ptr->obj_type = SQLMA_DBASE_APPLS;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 7:
          ma_unit_ptr->obj_type = SQLMA_DBASE_APPLINFO;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 8:
          ma_unit_ptr->obj_type = SQLMA_DBASE_LOCKS;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        case 9:
          ma_unit_ptr->obj_type = SQLMA_DBASE_ALL;
          ma_unit_ptr->agent_id = 0L;
          break;
        case 10:
          ma_unit_ptr->obj_type = SQLMA_APPL_ALL;
          ma_unit_ptr->agent_id = 0L;
          break;
        case 11:
          ma_unit_ptr->obj_type = SQLMA_APPLINFO_ALL;
          ma_unit_ptr->agent_id = 0L;
          break;
        case 12:
          ma_unit_ptr->obj_type = SQLMA_DCS_APPLINFO_ALL;
          ma_unit_ptr->agent_id = 0L;
          break;
        case 13:
          ma_unit_ptr->obj_type = SQLMA_DBASE_TABLESPACES;
          printf("\nPlease enter the database alias name ==> ");

          fflush(stdin);
          scanf("%s", ma_unit_ptr->object);
          ma_unit_ptr->agent_id = 0L;
          break;
        default:
          printf("\n\nThe input selection is not valid. Please try again.\n");
          pause();
          break;
      } /* end switch */

   } while ( input_opt != 0 ); /* enddo */

   /********************************************************************/
   /* transfer user selections to sqlma structure                      */
   /********************************************************************/

   if (obj_num == 0)
      return(0);

   /* Determine required size for sqlma structure */
   ma_sz = SQLMASIZE(obj_num);
   ma_ptr = (struct sqlma *) malloc(ma_sz);
   if ( ma_ptr == NULL)
   {
      printf("error allocating sqlma. Exiting.\n");
      return(99);
   }

   /* Initialize sqlma structure to nulls  */
   memset(ma_ptr, '\0', ma_sz);
   ma_ptr->obj_num = obj_num;

   ma_unit_ptr = &ma_unit_head;
   for (i = 0; i < obj_num; i++)
   {
      ma_ptr->obj_var[i].agent_id = ma_unit_ptr->agent_id;
      ma_ptr->obj_var[i].obj_type = ma_unit_ptr->obj_type;
      strncpy((char *)ma_ptr->obj_var[i].object,
              (char *)ma_unit_ptr->object,
               SQLM_OBJECT_SZ);
      free_ptr = ma_unit_ptr;        /* remember pointer before going to next */
      ma_unit_ptr = ma_unit_ptr->next;
      if (i != 0)
         free(free_ptr);                             /* free memory when done */
   }

   /***************************************************************************/
   /* Selection of output destination. The user can have the snapshot         */
   /* output sent either to the screen or to an output file of their choice.  */
   /* All output will be written out using "fprintf". This code will either   */
   /* assign stdout to outstream for screen output or open the appropriate    */
   /* file.                                                                   */
   /***************************************************************************/

   clrscrn();
   do
   {
     printf("\n\nPlease select output destination (0 to exit now):\n");
     printf("           %u : screen\n", SCREEN_OUTPUT);
     printf("           %u : file\n", FILE_OUTPUT);
     printf("           ==>");

     fflush(stdin);
     scanf("%u", &output_opt);
     switch (output_opt)
     {
       case SCREEN_OUTPUT :
               outstream = stdout;
               break;
       case FILE_OUTPUT :
               printf("\nNew results will be appended to existing file, if any.\n");
               printf("Please enter filename of the output file (80 chars max): ");

               fflush(stdin);
               scanf("%s", &outfilename);
               outstream = fopen(outfilename, "a");
               if (outstream == NULL)
               {
                 printf("\nERROR opening output file. Output defaults to SCREEN.\n");
                 output_opt = SCREEN_OUTPUT;
                 outstream = stdout;
                 pause();
               }
               break;
       case 0 :
               printf("Exiting...\n");
               return(0);
               break;
       default :
               printf("\nInvalid selection. Please try again.\n");
               break;
     } /* end switch(output_opt) */

   } while (output_opt < 1 | output_opt > 2);

   /**************************************************************************/
   /* Call the Database Monitor Estimate Buffer Size API to determine the    */
   /* size of the buffer required to store the Snapshot Monitor data.        */
   /**************************************************************************/

   rc = sqlmonsz(SQLM_DBMON_VERSION2, NULL, ma_ptr, &buffer_sz, &sqlca);

   if (rc != 0)
   {
      printf("\nReturn code from SQLMONSZ is %d \n", rc);
      return(rc);
   }
   if (sqlca.sqlcode != 0L)
   {
      printf("\nSqlcode from SQLMONSZ is not 0. \n");
      pr_sqlca(&sqlca);
      if (sqlca.sqlcode < 0L)             /* negative sqlcodes are errors    */
      {
         printf("Negative sqlcode... exiting\n");
         cleanup(ma_ptr);
         return((int)sqlca.sqlcode);
      }
      pause();
   }

   if (buffer_sz == 0)
   {
      return(0);
   }

   buffer_ptr = (char *) malloc(buffer_sz);    /* allocate buffer           */
   if (buffer_ptr == NULL)
   {
       printf("Error allocating memory for buffer area... exiting\n");
       cleanup(ma_ptr);
       return(99);
   }
   memset(buffer_ptr, '\0', buffer_sz);   /* set contents to nulls          */

   /**************************************************************************/
   /* Call Snapshot Monitor and verify the return codes.                     */
   /* If rc return code from call to the Snapshot Monitor api is non-zero,   */
   /* exit the sample program.                                               */
   /* A non-zero sqlcode is not necessarily an error. If the sqlcode is      */
   /* negative, than it is an error and db2mon exits. If the sqlcode is      */
   /* positive, than processing continues. In both cases, the contents of    */
   /* the sqlca are displayed on the screen.                                 */
   /**************************************************************************/

   rc = sqlmonss(SQLM_DBMON_VERSION2, NULL, ma_ptr, buffer_sz, buffer_ptr,
                 &collected, &sqlca);

   if (rc != 0)
   {
      printf("\nReturn code from SQLMONSS is %d \n", rc);
      cleanup(ma_ptr);
      return(rc);
   }

   if (sqlca.sqlcode != 0L)
   {
      printf("\nSqlcode from SQLMONSS is not 0. \n");
      pr_sqlca(&sqlca);
      if (sqlca.sqlcode < 0L)             /* negative sqlcodes are errors    */
      {
         printf("Negative sqlcode... exiting\n");
         cleanup(ma_ptr);
         return((int)sqlca.sqlcode);
      }
      pause();
   }


   /**************************************************************************/
   /* Print out some general information about the results.                  */
   /* This information is contained in the sqlm_collected data structure     */
   /* returned from the call to sqlmonss. It is not part of the output       */
   /* buffer.                                                                */
   /**************************************************************************/

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                         GENERAL INFORMATION                        *\n");
   fprintf(outstream, "**********************************************************************\n");


  ltime  = collected.time_stamp.seconds;
  fprintf(outstream, "Time Stamp of the Snapshot call          ===> %24.24s\n", (ltime) ? ctime(&ltime) : "");

  switch (collected.server_db2_type)
  {
     case SQLF_NT_STANDALONE:
          fprintf(outstream, "Server Type                              ===> Standalone\n");
          break;
     case SQLF_NT_SERVER:
          fprintf(outstream, "Server Type                              ===> Client/Server\n");
          break;
     case SQLF_NT_STAND_REQ:
          fprintf(outstream, "Server Type                              ===> Client with local databases\n");
          break;
     default:
          fprintf(outstream, "Server Type                              ===> UNKNOWN(%lu)\n", collected.server_db2_type);
          break;
  }  /* switch */

  fprintf(outstream, "Product Signature (prdid)                ===> %0.*s\n", SQLM_IDENT_SZ, collected.server_prdid);
  fprintf(outstream, "Server Instance Name                     ===> %0.*s\n", SQLM_IDENT_SZ, collected.server_instance_name);

  fprintf(outstream, "\nMonitor Switch settings:\n");

  fprintf(outstream, "1 - UOW Switch state       : %s %24.24s\n", (collected.group_states[0].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[0].start_time.seconds) ? ctime((time_t *)&collected.group_states[0].start_time.seconds) : "");
  fprintf(outstream, "2 - STMT Switch state      : %s %24.24s\n", (collected.group_states[1].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[1].start_time.seconds) ? ctime((time_t *)&collected.group_states[1].start_time.seconds) : "");
  fprintf(outstream, "3 - TABLE Switch state     : %s %24.24s\n", (collected.group_states[2].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[2].start_time.seconds) ? ctime((time_t *)&collected.group_states[2].start_time.seconds) : "");
  fprintf(outstream, "4 - BUFF POOL Switch state : %s %24.24s\n", (collected.group_states[3].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[3].start_time.seconds) ? ctime((time_t *)&collected.group_states[3].start_time.seconds) : "");
  fprintf(outstream, "5 - LOCK Switch state      : %s %24.24s\n", (collected.group_states[4].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[4].start_time.seconds) ? ctime((time_t *)&collected.group_states[4].start_time.seconds) : "");
  fprintf(outstream, "6 - SORT Switch state      : %s %24.24s\n", (collected.group_states[5].output_state) ? "ON , start time :" : "OFF",
                     (collected.group_states[5].start_time.seconds) ? ctime((time_t *)&collected.group_states[5].start_time.seconds) : "");

  /*************************************************************/
  /* Display the number of each information structure returned */
  /* in the output buffer.                                     */
  /*************************************************************/
  fprintf(outstream, "\nDB2 info collected                       ===> %s\n", (collected.db2) ? "YES" : "NO");
  fprintf(outstream, "# databases collected                    ===> %lu\n", collected.databases);
  fprintf(outstream, "# table_databases collected              ===> %lu\n", collected.table_databases);
  fprintf(outstream, "# lock_databases collected               ===> %lu\n", collected.lock_databases);
  fprintf(outstream, "# applications collected                 ===> %lu\n", collected.applications);
  fprintf(outstream, "# applinfos collected                    ===> %lu\n", collected.applinfos);
  fprintf(outstream, "# DCS applinfos collected                ===> %lu\n", collected.dcs_applinfos);
  fprintf(outstream, "# tablespace_databases collected         ===> %lu\n\n", collected.tablespace_databases);

  if (output_opt == SCREEN_OUTPUT)
     pause();

   /**************************************************************************/
   /* Process the buffer returned from Snapshot Monitor API.                 */
   /* The buffer will contain the data structures of the objects that were   */
   /* monitored. The first 4 bytes of each structure indicates its size and  */
   /* the next character identifies the type of information returned.        */
   /* The program goes through the whole buffer, processing each structure as*/
   /* it encounters it. It first determines what type of information it      */
   /* currently points to, then processes it accordingly. After processing   */
   /* a structure, it advances in the buffer to the next one, until it       */
   /* has processed the whole buffer.                                        */
   /* Processing is complete when all returned structures have been          */
   /* processed, as indicated by the numbers in the sqlm_collected data      */
   /* structure.                                                             */
   /**************************************************************************/

   /* add up all the structures returned in the buffer */
   numstruct = collected.db2 + collected.databases + collected.table_databases +
               collected.lock_databases + collected.applications + collected.applinfos +
               collected.dcs_applinfos + collected.tablespace_databases;

   buffer_index = buffer_ptr;

   /* loop until all data structures have been processed */
   while (numstruct > 0)
   {
     /* Determine the type of structure at current position in the buffer    */
     switch ((unsigned char)*(buffer_index + 4))
     {
       case SQLM_DB2_SS:                  /* DB2 information                 */
         process_db2();
         break;
       case SQLM_DBASE_SS:                /* Database information            */
         process_dbase();
         break;
       case SQLM_APPL_SS:                 /* Application information         */
         process_appl();
         break;
       case SQLM_TABLE_HEADER_SS:         /* Table information               */
         process_table();
         break;
       case SQLM_DBASE_LOCK_SS:           /* Lock information                */
         process_lock();
         break;
       case SQLM_APPLINFO_SS:             /* Summary application information */
         process_applinfo();
         break;
       case SQLM_DCS_APPLINFO_SS:         /* DCS application information     */
         process_dcs_applinfo();
         break;
       case SQLM_TABLESPACE_HEADER_SS:    /* Tablespace information          */
         process_tablespace();
         break;
       default:                           /* Unexpected data in buffer       */
         printf("\n\n***************************************************************\n");
         printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
         printf("*    Expecting start of new structure. First chars: %10c *\n",(unsigned char)*buffer_index);
         printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
         printf("*    Exiting db2mon.                                          *\n\n");
         printf("\n***************************************************************\n");
         cleanup(ma_ptr);
         exit(99);
         break;
     }  /* end switch (*buffer_index) */
     --numstruct;
   }  /* end while (buffer_index < ...) */

   cleanup(ma_ptr);   /* cleanup before exiting */

   return(ssrc);

}  /* snapshot */


/*****************************************************************************/
/* process_db2                                                               */
/* This function processes DB2 level information. The information is in      */
/* an sqlm_db2 data structure.                                               */
/*****************************************************************************/

void process_db2()
{

   long                  ltime;
   struct sqlm_db2      *db2_ptr;

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                       DB2 GENERAL INFORMATION                      *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast buffer contents to an sqlm_db2 structure */
   db2_ptr = (struct sqlm_db2 *)buffer_index;

   switch (db2_ptr->db2_status)
   {
      case SQLM_DB2_ACTIVE:
         fprintf(outstream, "\nDatabase manager status                   ===> %s",  "Active");
         break;
      case SQLM_DB2_QUIESCE_PEND:
         fprintf(outstream, "\nDatabase manager status                   ===> %s",  "Quiesce Pending");
         break;
      case SQLM_DB2_QUIESCED:
         fprintf(outstream, "\nDatabase manager status                   ===> %s",  "Quiesced");
         break;
   } /* end switch on database manager status */

   fprintf(outstream, "\n\nSorting Information:");
   fprintf(outstream, "\n  Sort heap currently allocated           ===> %lu", db2_ptr->sort_heap_allocated);
   fprintf(outstream, "\n  Post Threshold sorts                    ===> %lu", db2_ptr->post_threshold_sorts);
   fprintf(outstream, "\n  Piped sorts requested                   ===> %lu", db2_ptr->piped_sorts_requested);
   fprintf(outstream, "\n  Piped sorts accepted                    ===> %lu", db2_ptr->piped_sorts_accepted);

   fprintf(outstream, "\n\nConnection Information:");
   fprintf(outstream, "\n  Remote connects to the target DB2       ===> %lu", db2_ptr->rem_cons_in);
   fprintf(outstream, "\n  Remote connects to target exec in DB2   ===> %lu", db2_ptr->rem_cons_in_exec);
   fprintf(outstream, "\n  Local connections                       ===> %lu", db2_ptr->local_cons);
   fprintf(outstream, "\n  Local connections exec in DB2           ===> %lu", db2_ptr->local_cons_in_exec);
   fprintf(outstream, "\n  Local active databases                  ===> %lu", db2_ptr->con_local_dbases);
   fprintf(outstream, "\n  Number of agents registered             ===> %lu", db2_ptr->agents_registered);
   fprintf(outstream, "\n  Number of agents waiting on a token     ===> %lu", db2_ptr->agents_waiting_on_token);
   fprintf(outstream, "\n  High water mark of agents registered    ===> %lu", db2_ptr->agents_registered_top);
   fprintf(outstream, "\n  High water mark of agents waiting       ===> %lu", db2_ptr->agents_waiting_top);
   fprintf(outstream, "\n  Number of idle agents                   ===> %lu", db2_ptr->idle_agents);

   fprintf(outstream, "\n\nMemory Usage Information:");
   fprintf(outstream, "\n  Committed Private Memory (bytes)        ===> %lu", db2_ptr->comm_private_mem);

   fprintf(outstream, "\n\nTimestamps:");
   ltime = db2_ptr->db2start_time.seconds;
   fprintf(outstream, "\n  Db2start time                           ===> %24.24s",
                                                     (ltime) ? ctime(&ltime) : "");
   ltime = db2_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last Reset time                         ===> %24.24s\n",
                                                     (ltime) ? ctime(&ltime) : "");

   buffer_index += db2_ptr->size;          /* move pointer to next structure */
                                           /* in output buffer               */
   if (output_opt == SCREEN_OUTPUT)        /* pause only if output is screen */
      pause();

} /* process_db2 */


/*****************************************************************************/
/* process_dbase                                                             */
/* This function processes database information. The information is in an    */
/* sqlm_dbase data structure                                                 */
/*****************************************************************************/
void process_dbase()
{

   long                  ltime;
   unsigned int          i, j;              /* counters                      */
   int                   rc = 0;
   struct sqlm_dbase     *dbase_ptr;

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                       DATABASE INFORMATION                         *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast buffer contents to an sqlm_dbase structure */
   dbase_ptr = (struct sqlm_dbase *)(buffer_index);

   fprintf(outstream, "\nDatabase Identification:");
   fprintf(outstream, "\n  Input Database Alias                   ===> %0.*s", SQLM_IDENT_SZ, dbase_ptr->input_db_alias);
   fprintf(outstream, "\n  Database Name                          ===> %0.*s", SQLM_IDENT_SZ, dbase_ptr->db_name);
   fprintf(outstream, "\n  Database Path (truncated to 70 chars)\n    ===> %0.70s", dbase_ptr->db_path);

   switch (dbase_ptr->db_status)
   {
      case SQLM_DB_ACTIVE:
         fprintf(outstream, "\n  Database status                        ===> %s",  "Active");
         break;
      case SQLM_DB_QUIESCE_PEND:
         fprintf(outstream, "\n  Database status                        ===> %s",  "Quiesce Pending");
         break;
      case SQLM_DB_QUIESCED:
         fprintf(outstream, "\n  Database status                        ===> %s",  "Quiesced");
         break;
   } /* end switch on database manager status */

   fprintf(outstream, "\n\nLocking Identification:");
   fprintf(outstream, "\n  Locks currently held                    ===> %lu", dbase_ptr->locks_held);
   fprintf(outstream, "\n  No. of waits on lock since 1st connect  ===> %lu", dbase_ptr->lock_waits);
   fprintf(outstream, "\n  Total time waited on locks since connect===> %lu milliseconds", dbase_ptr->lock_wait_time);
   fprintf(outstream, "\n  Total Lock list memory in use           ===> %lu", dbase_ptr->lock_list_in_use);
   fprintf(outstream, "\n  Deadlocks since 1st connect             ===> %lu", dbase_ptr->deadlocks);
   fprintf(outstream, "\n  Lock escalations since 1st connect      ===> %lu", dbase_ptr->lock_escals);
   fprintf(outstream, "\n  X lock escalations since 1st connect    ===> %lu", dbase_ptr->x_lock_escals);
   fprintf(outstream, "\n  Lock timeouts since 1st connect         ===> %lu", dbase_ptr->lock_timeouts);
   fprintf(outstream, "\n  Applications waiting on locks           ===> %lu", dbase_ptr->locks_waiting);


   fprintf(outstream, "\n\nSorting Identification:");
   fprintf(outstream, "\n  Sort Heap currently allocated           ===> %lu", dbase_ptr->sort_heap_allocated);
   fprintf(outstream, "\n  Total number of sorts                   ===> %lu", dbase_ptr->total_sorts);
   fprintf(outstream, "\n  Total sort time                         ===> %lu milliseconds", dbase_ptr->total_sort_time);
   fprintf(outstream, "\n  Number of sort overflows                ===> %lu", dbase_ptr->sort_overflows);
   fprintf(outstream, "\n  Number of sorts currently active        ===> %lu", dbase_ptr->active_sorts);

   fprintf(outstream, "\n\nBuffer Pool Information:");
   fprintf(outstream, "\n  Buffer pool logical data page reads     ===> %lu", dbase_ptr->pool_data_l_reads);
   fprintf(outstream, "\n  Buffer pool physical data page reads    ===> %lu", dbase_ptr->pool_data_p_reads);
   fprintf(outstream, "\n  Buffer pool data page writes            ===> %lu", dbase_ptr->pool_data_writes);
   fprintf(outstream, "\n  Buffer pool logical index page reads    ===> %lu", dbase_ptr->pool_index_l_reads);
   fprintf(outstream, "\n  Buffer pool physical index page reads   ===> %lu", dbase_ptr->pool_index_p_reads);
   fprintf(outstream, "\n  Buffer pool index page writes           ===> %lu", dbase_ptr->pool_index_writes);
   fprintf(outstream, "\n  Buffer pool read time since 1st connect ===> %lu milliseconds", dbase_ptr->pool_read_time);
   fprintf(outstream, "\n  Buffer pool write time since 1st connect===> %lu milliseconds", dbase_ptr->pool_write_time);
   fprintf(outstream, "\n  Files closed since 1st connect          ===> %lu", dbase_ptr->files_closed);

   fprintf(outstream, "\n  Buffer pool asynch data page reads      ===> %lu", dbase_ptr->pool_async_data_reads);
   fprintf(outstream, "\n  Buffer pool asynch data page reads reqs ===> %lu", dbase_ptr->pool_async_data_read_reqs);
   fprintf(outstream, "\n  Buffer pool asynch data page writes     ===> %lu", dbase_ptr->pool_async_data_writes);
   fprintf(outstream, "\n  Buffer pool asynch index page writes    ===> %lu", dbase_ptr->pool_async_index_writes);
   fprintf(outstream, "\n  Buffer pool asynch read time            ===> %lu milliseconds", dbase_ptr->pool_async_read_time);
   fprintf(outstream, "\n  Buffer pool asynch write time           ===> %lu milliseconds", dbase_ptr->pool_async_write_time);

   fprintf(outstream, "\n  Buffer pool LSN gap cleans              ===> %lu", dbase_ptr->pool_lsn_gap_clns);
   fprintf(outstream, "\n  Buffer pool dirty page steal cleans     ===> %lu", dbase_ptr->pool_drty_pg_steal_clns);
   fprintf(outstream, "\n  Buffer pool dirty page threshold cleans ===> %lu", dbase_ptr->pool_drty_pg_thrsh_clns);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nDirect I/O Information:");
   fprintf(outstream, "\n  Sectors read directly                   ===> %lu", dbase_ptr->direct_reads);
   fprintf(outstream, "\n  Sectors written directly                ===> %lu", dbase_ptr->direct_writes);
   fprintf(outstream, "\n  Number of direct read requests          ===> %lu", dbase_ptr->direct_read_reqs);
   fprintf(outstream, "\n  Number of direct write requests         ===> %lu", dbase_ptr->direct_write_reqs);
   fprintf(outstream, "\n  Direct read time                        ===> %lu milliseconds", dbase_ptr->direct_read_time);
   fprintf(outstream, "\n  Direct write time                       ===> %lu milliseconds", dbase_ptr->direct_write_time);

   fprintf(outstream, "\n\nSQL Statement counts");
   fprintf(outstream, "\n  Number of Commit SQL statements         ===> %lu", dbase_ptr->commit_sql_stmts);
   fprintf(outstream, "\n  Number of Rollback SQL statements       ===> %lu", dbase_ptr->rollback_sql_stmts);
   fprintf(outstream, "\n  Number of Dynamic SQL statements        ===> %lu", dbase_ptr->dynamic_sql_stmts);
   fprintf(outstream, "\n  Number of Static SQL statements         ===> %lu", dbase_ptr->static_sql_stmts);
   fprintf(outstream, "\n  Number of Failed SQL statements         ===> %lu", dbase_ptr->failed_sql_stmts);
   fprintf(outstream, "\n  Number of Select SQL statements         ===> %lu", dbase_ptr->select_sql_stmts);
   fprintf(outstream, "\n  Number of Data Def. Language SQL stmts  ===> %lu", dbase_ptr->ddl_sql_stmts);
   fprintf(outstream, "\n  Number of Update/Insert/Delete SQL stmts===> %lu", dbase_ptr->uid_sql_stmts);

   fprintf(outstream, "\n\nInternal counts");
   fprintf(outstream, "\n  Number of auto rebinds                  ===> %lu", dbase_ptr->int_auto_rebinds);
   fprintf(outstream, "\n  Number of internal row deletions        ===> %lu", dbase_ptr->int_rows_deleted);
   fprintf(outstream, "\n  Number of internal row updates          ===> %lu", dbase_ptr->int_rows_updated);
   fprintf(outstream, "\n  Number of internal row inserts          ===> %lu", dbase_ptr->int_rows_inserted);
   fprintf(outstream, "\n  Number of internal commits              ===> %lu", dbase_ptr->int_commits);
   fprintf(outstream, "\n  Number of internal rollbacks            ===> %lu", dbase_ptr->int_rollbacks);
   fprintf(outstream, "\n  Number of rollbacks due to deadlocks    ===> %lu", dbase_ptr->int_deadlock_rollbacks);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nRow counts");
   fprintf(outstream, "\n  Number of row deletions                 ===> %lu", dbase_ptr->rows_deleted);
   fprintf(outstream, "\n  Number of row insertions                ===> %lu", dbase_ptr->rows_inserted);
   fprintf(outstream, "\n  Number of row updates                   ===> %lu", dbase_ptr->rows_updated);
   fprintf(outstream, "\n  Number of row selections                ===> %lu", dbase_ptr->rows_selected);

   fprintf(outstream, "\n\n  Number of binds/precompiles             ===> %lu", dbase_ptr->binds_precompiles);

   fprintf(outstream, "\n\nTimestamps");
   ltime = dbase_ptr->db_conn_time.seconds;
   fprintf(outstream, "\n  First database connect time             ===> %24.24s",
                                                   (ltime) ? ctime(&ltime) : "");
   ltime = dbase_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last Database Monitor reset time        ===> %24.24s",
                                                   (ltime) ? ctime(&ltime) : "");
   ltime = dbase_ptr->last_backup.seconds;
   fprintf(outstream, "\n  Last backup time                        ===> %24.24s",
                                                   (ltime) ? ctime(&ltime) : "");

   fprintf(outstream, "\n\nConnection information");
   fprintf(outstream, "\n  Connections since 1st connect           ===> %lu", dbase_ptr->total_cons);
   fprintf(outstream, "\n  No. of applications currently connected ===> %lu", dbase_ptr->appls_cur_cons);
   fprintf(outstream, "\n  Applications executing in DB2           ===> %lu", dbase_ptr->appls_in_db2);
   fprintf(outstream, "\n  Maximum number of connections           ===> %lu", dbase_ptr->connections_top);

   fprintf(outstream, "\n\nDatabase heap information");
   fprintf(outstream, "\n  Maximum amount of database heap used    ===> %lu", dbase_ptr->db_heap_top);

   fprintf(outstream, "\n\nLogging information");
   fprintf(outstream, "\n  Maximum Secondary Log space used        ===> %lu", dbase_ptr->sec_log_used_top);
   fprintf(outstream, "\n  Maximum Total Log space used            ===> %lu", dbase_ptr->tot_log_used_top);
   fprintf(outstream, "\n  Number of secondary Logs allocated      ===> %lu", dbase_ptr->sec_logs_allocated);
   fprintf(outstream, "\n  Log pages read                          ===> %lu", dbase_ptr->log_reads);
   fprintf(outstream, "\n  Log pages written                       ===> %lu", dbase_ptr->log_writes);

   fprintf(outstream, "\n\nPackage Cache information");
   fprintf(outstream, "\n  Package Cache Lookups                   ===> %lu", dbase_ptr->pkg_cache_lookups);
   fprintf(outstream, "\n  Package Cache Inserts                   ===> %lu", dbase_ptr->pkg_cache_inserts);

   fprintf(outstream, "\n\nCatalog Cache information");
   fprintf(outstream, "\n  Catalog Cache Lookups                   ===> %lu", dbase_ptr->cat_cache_lookups);
   fprintf(outstream, "\n  Catalog Cache Inserts                   ===> %lu", dbase_ptr->cat_cache_inserts);
   fprintf(outstream, "\n  Catalog Cache Overflows                 ===> %lu", dbase_ptr->cat_cache_overflows);
   fprintf(outstream, "\n  Catalog Cache Heap Full                 ===> %lu\n", dbase_ptr->cat_cache_heap_full);

   buffer_index += dbase_ptr->size;   /* move pointer to the next structure */

   if (output_opt == SCREEN_OUTPUT)
      pause();

}  /* process_dbase */



/*****************************************************************************/
/* process_appl                                                              */
/* This function processes application information. The information is       */
/* contained in an sqlm_appl data structure.                                 */
/*****************************************************************************/
void process_appl()
{

   long                  ltime;
   struct sqlm_appl      *appl_ptr;
   char                  *stmt_text_ptr;   /* Dynamic SQL Statement Text ptr */

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                       APPLICATION INFORMATION                      *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast the buffer contents to an sqlm_appl data structure */
   appl_ptr = (struct sqlm_appl *)(buffer_index);

   fprintf(outstream, "\nApplication Identification Information:");
   fprintf(outstream, "\n  Application agent id                   ===> %lu\n", appl_ptr->id_info.agent_id);
   switch (appl_ptr->id_info.appl_status)
   {
      case SQLM_CONNECTPEND:
         fprintf(outstream, "\n  Application Status                     ===> Connect Pending");
         break;
      case SQLM_CONNECTED:
         fprintf(outstream, "\n  Application Status                     ===> Connected");
         break;
      case SQLM_UOWEXEC:
         fprintf(outstream, "\n  Application Status                     ===> UOW Executing");
         break;
      case SQLM_UOWWAIT:
         fprintf(outstream, "\n  Application Status                     ===> UOW Waiting in the application");
         break;
      case SQLM_LOCKWAIT:
         fprintf(outstream, "\n  Application Status                     ===> Lock Waiting");
         break;
      case SQLM_COMMIT_ACT:
         fprintf(outstream, "\n  Application Status                     ===> Commit Active");
         break;
      case SQLM_ROLLBACK_ACT:
         fprintf(outstream, "\n  Application Status                     ===> Rollback Active");
         break;
      case SQLM_RECOMP:
         fprintf(outstream, "\n  Application Status                     ===> Recompiling Plan");
         break;
      case SQLM_COMP:
         fprintf(outstream, "\n  Application Status                     ===> Compiling SQL Stmt");
         break;
      case SQLM_INTR:
         fprintf(outstream, "\n  Application Status                     ===> Request Interupted");
         break;
      case SQLM_DISCONNECTPEND:
         fprintf(outstream, "\n  Application Status                     ===> Disconnect Pending");
         break;
      case SQLM_TPREP:
         fprintf(outstream, "\n  Application Status                     ===> Prepared Transaction");
         break;
      case SQLM_THCOMT:
         fprintf(outstream, "\n  Application Status                     ===> Trans. heuristically committed");
         break;
      case SQLM_THABRT:
         fprintf(outstream, "\n  Application Status                     ===> Trans. heuristically aborted");
         break;
      case SQLM_TEND:
         fprintf(outstream, "\n  Application Status                     ===> Transaction ended");
         break;
      case SQLM_CREATE_DB:
         fprintf(outstream, "\n  Application Status                     ===> Creating Database");
         break;
      case SQLM_RESTART:
         fprintf(outstream, "\n  Application Status                     ===> Restarting Database");
         break;
      case SQLM_RESTORE:
         fprintf(outstream, "\n  Application Status                     ===> Restoring Database");
         break;
      case SQLM_BACKUP:
         fprintf(outstream, "\n  Application Status                     ===> Backing Up Database");
         break;
      case SQLM_LOAD:
         fprintf(outstream, "\n  Application Status                     ===> Loading Database");
         break;
      case SQLM_UNLOAD:
         fprintf(outstream, "\n  Application Status                     ===> Unloading Database");
         break;
      case SQLM_IOERROR_WAIT:
         fprintf(outstream, "\n  Application Status                     ===> I/O Error Waiting");
         break;
      case SQLM_QUIESCE_TABLESPACE:
         fprintf(outstream, "\n  Application Status                     ===> Quiescing a Tablespace");
         break;
      default:
         fprintf(outstream, "\n  Application Status                     ===> Unknown (%lu)", appl_ptr->id_info.appl_status);
         break;
   } /* endswitch */

   fprintf(outstream, "\n  Application codepage id                ===> %lu", appl_ptr->id_info.codepage_id);
   fprintf(outstream, "\n  Application country code               ===> %lu", appl_ptr->country_code);

   ltime  = appl_ptr->id_info.status_change_time.seconds;
   fprintf(outstream, "\n  Application Status change time         ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   fprintf(outstream, "\n  Application Name                       ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.appl_name);
   fprintf(outstream, "\n  Application Id                         ===> %0.*s", SQLM_APPLID_SZ, appl_ptr->id_info.appl_id);
   fprintf(outstream, "\n  Application Id Sequence number         ===> %0.*s", SQLM_SEQ_SZ, appl_ptr->id_info.sequence_no);
   fprintf(outstream, "\n  DRDA AS Correlation Token              ===> %0.*s", SQLM_APPLID_SZ, appl_ptr->corr_token);
   fprintf(outstream, "\n  Application Authorization Id           ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.auth_id);
   fprintf(outstream, "\n  Application Execution Id               ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->execution_id);
   fprintf(outstream, "\n  Application client NNAME               ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.client_nname);
   fprintf(outstream, "\n  Application client Product name        ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.client_prdid);
   fprintf(outstream, "\n  Application client Process Id          ===> %lu", appl_ptr->client_pid);

   switch (appl_ptr->client_platform)
   {
      case SQLM_PLATFORM_OS2:
         fprintf(outstream, "\n  Application client platform            ===> OS/2");
         break;
      case SQLM_PLATFORM_DOS:
         fprintf(outstream, "\n  Application client platform            ===> DOS");
         break;
      case SQLM_PLATFORM_WINDOWS:
         fprintf(outstream, "\n  Application client platform            ===> WINDOWS");
         break;
      case SQLM_PLATFORM_AIX:
         fprintf(outstream, "\n  Application client platform            ===> AIX");
         break;
      case SQLM_PLATFORM_HP:
         fprintf(outstream, "\n  Application client platform            ===> HP");
         break;
      case SQLM_PLATFORM_SUN:
         fprintf(outstream, "\n  Application client platform            ===> SUN");
         break;
      case SQLM_PLATFORM_SNI:                                /*@db41773ygs*/
         fprintf(outstream, "\n  Application client platform            ===> SINIX");
         break;
      case SQLM_PLATFORM_MAC:
         fprintf(outstream, "\n  Application client platform            ===> MacIntosh");
         break;
      case SQLM_PLATFORM_WINDOWS95:
         fprintf(outstream, "\n  Application client platform            ===> Windows95");
         break;
      case SQLM_PLATFORM_VSE_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> VSE via DRDA");
         break;                                               /*@de41773ygs*/
      case SQLM_PLATFORM_MVS_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> MVS via DRDA");
         break;
      case SQLM_PLATFORM_AS400_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> AS400 via DRDA");
         break;
      case SQLM_PLATFORM_VM_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> VM via DRDA");
         break;
      case SQLM_PLATFORM_UNKNOWN_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> Unknown via DRDA");
         break;
      case SQLM_PLATFORM_UNKNOWN:
         fprintf(outstream, "\n  Application client platform            ===> Unknown");
         break;
      default:
         fprintf(outstream, "\n  Application client platform            ===> Unknown (%lu)", appl_ptr->client_platform);
         break;
   } /* endswitch */

   switch (appl_ptr->client_protocol)
   {
      case SQLM_PROT_APPC:
         fprintf(outstream, "\n  Application client comms protocol      ===> APPC");
         break;
      case SQLM_PROT_NETBIOS:
         fprintf(outstream, "\n  Application client comms protocol      ===> Netbios");
         break;
      case SQLM_PROT_APPN:
         fprintf(outstream, "\n  Application client comms protocol      ===> APPN");
         break;
      case SQLM_PROT_TCPIP:
         fprintf(outstream, "\n  Application client comms protocol      ===> TCPIP");
         break;
      case SQLM_PROT_CPIC:
         fprintf(outstream, "\n  Application client comms protocol      ===> CPIC");
         break;
      case SQLM_PROT_IPXSPX:
         fprintf(outstream, "\n  Application client comms protocol      ===> IPX/SPX");
         break;
      case SQLM_PROT_LOCAL:
         fprintf(outstream, "\n  Application client comms protocol      ===> Local");
         break;
      case SQLM_PROT_NPIPE:
         fprintf(outstream, "\n  Application client comms protocol      ===> Named Pipe");
         break;
      default:
         fprintf(outstream, "\n  Application client comms protocol      ===> Unknown (%lu)", appl_ptr->client_protocol);
         break;
   } /* endswitch */


   fprintf(outstream, "\n  Input Database Alias                   ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.input_db_alias);
   fprintf(outstream, "\n  Client Database Alias                  ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.client_db_alias);
   fprintf(outstream, "\n  Database Name                          ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->id_info.db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s", appl_ptr->id_info.db_path);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nLock Information:");
   fprintf(outstream, "\n  Locks currently held by the application ===> %lu", appl_ptr->locks_held);
   fprintf(outstream, "\n  Number of waits on lock since connect   ===> %lu", appl_ptr->lock_waits);
   fprintf(outstream, "\n  Total time waited on locks since connect===> %lu milliseconds", appl_ptr->lock_wait_time);
   fprintf(outstream, "\n  Lock escalations since appl connect     ===> %lu", appl_ptr->lock_escals);
   fprintf(outstream, "\n  X lock escalations since appl connect   ===> %lu", appl_ptr->x_lock_escals);
   fprintf(outstream, "\n  Deadlocks since appl connect            ===> %lu", appl_ptr->deadlocks);
   fprintf(outstream, "\n  Lock timeouts since appl connect        ===> %lu", appl_ptr->lock_timeouts);
   fprintf(outstream, "\n  Time UOW waited on locks                ===> %lu milliseconds", appl_ptr->uow_lock_wait_time);

   fprintf(outstream, "\n\n  agent Id holding lock                   ===> %lu", appl_ptr->agent_id_holding_lk);
   if (appl_ptr->table_name[0] != ' ')
   {
      /* Null terminate table schema */
      char *c;
      for (c = appl_ptr->table_schema; *c != ' '; ++c);
      *c = '\0';
      fprintf(outstream, "\n  Table Name of lock waited on            ===> %s.%-.*s", appl_ptr->table_schema, SQLM_IDENT_SZ, appl_ptr->table_name);
   }
   else
      fprintf(outstream, "\n  Table Name of lock waited on            ===>");

   fprintf(outstream, "\n  Tablespace Name of lock waited on       ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->tablespace_name);

   switch (appl_ptr->lock_object_type)
   {
      case SQLM_ROW_LOCK:
           fprintf(outstream, "\n  Type of lock                            ===> ROW");
           break;
      case SQLM_TABLE_LOCK:
           fprintf(outstream, "\n  Type of lock                            ===> TABLE");
           break;
      case SQLM_INTERNAL_LOCK:
           fprintf(outstream, "\n  Type of lock                            ===> INTERNAL");
           break;
      case SQLM_TABLESPACE_LOCK:
           fprintf(outstream, "\n  Type of lock                            ===> TABLESPACE");
           break;
      case 0L:
           fprintf(outstream, "\n  Type of lock                            ===> No Lock");
           break;
      default:
           fprintf(outstream, "\n  Type of lock                            ===> UNKNOWN (%lu)", appl_ptr->lock_object_type);
           break;
   }  /* switch */

   switch (appl_ptr->lock_mode)
   {
      case SQLM_LNON:
           fprintf(outstream, "\n  Mode of lock                            ===> No Lock");
           break;
      case SQLM_LOIS:
           fprintf(outstream, "\n  Mode of lock                            ===> Intention Share Lock");
           break;
      case SQLM_LOIX:
           fprintf(outstream, "\n  Mode of lock                            ===> Intention Exclusive Lock");
           break;
      case SQLM_LOOS:
           fprintf(outstream, "\n  Mode of lock                            ===> Share Lock");
           break;
      case SQLM_LSIX:
           fprintf(outstream, "\n  Mode of lock                            ===> Share with Intention Exclusive Lock");
           break;
      case SQLM_LOOX:
           fprintf(outstream, "\n  Mode of lock                            ===> Exclusive Lock");
            break;
      case SQLM_LOIN:
           fprintf(outstream, "\n  Mode of lock                            ===> Intent None (For Dirty Read)");
           break;
      case SQLM_LOOZ:
           fprintf(outstream, "\n  Mode of lock                            ===> Super Exclusive Lock");
           break;
      case SQLM_LOOU:
           fprintf(outstream, "\n  Mode of lock                            ===> U-Lock");
           break;
      default:
           fprintf(outstream, "\n  Mode of lock                            ===> Unknown (%lu)", appl_ptr->lock_mode);
           break;
   } /* endswitch */
   fprintf(outstream, "\n  Lock object name                        ===> %lu", appl_ptr->lock_object_name);
   ltime  = appl_ptr->lock_wait_start_time.seconds;
   fprintf(outstream, "\n  Time lock wait entered                  ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   fprintf(outstream, "\n  Application Id holding lock             ===> %0.*s", SQLM_APPLID_SZ, appl_ptr->appl_id_holding_lk);
   fprintf(outstream, "\n  Sequence number of appl holding lock    ===> %0.*s", SQLM_SEQ_SZ, appl_ptr->sequence_no_holding_lk);

   fprintf(outstream, "\n\nSorting Information:");
   fprintf(outstream, "\n  Total number of sorts                   ===> %lu", appl_ptr->total_sorts);
   fprintf(outstream, "\n  Total Sort time                         ===> %lu milliseconds", appl_ptr->total_sort_time);
   fprintf(outstream, "\n  Number of sort overflows                ===> %lu", appl_ptr->sort_overflows);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nBuffer Pool Information:");
   fprintf(outstream, "\n  Buffer pool data logical reads          ===> %lu", appl_ptr->pool_data_l_reads);
   fprintf(outstream, "\n  Buffer pool data physical reads         ===> %lu", appl_ptr->pool_data_p_reads);
   fprintf(outstream, "\n  Buffer pool data writes                 ===> %lu", appl_ptr->pool_data_writes);
   fprintf(outstream, "\n  Buffer pool index logical reads         ===> %lu", appl_ptr->pool_index_l_reads);
   fprintf(outstream, "\n  Buffer pool index physical reads        ===> %lu", appl_ptr->pool_index_p_reads);
   fprintf(outstream, "\n  Buffer pool index writes                ===> %lu", appl_ptr->pool_index_writes);
   fprintf(outstream, "\n  Buffer pool read time since 1st connect ===> %lu milliseconds", appl_ptr->pool_read_time);
   fprintf(outstream, "\n  Buffer pool write time since 1st connect===> %lu milliseconds", appl_ptr->pool_write_time);

   fprintf(outstream, "\n\nDirect I/O Information:");
   fprintf(outstream, "\n  Sectors read directly                   ===> %lu", appl_ptr->direct_reads);
   fprintf(outstream, "\n  Sectors written directly                ===> %lu", appl_ptr->direct_writes);
   fprintf(outstream, "\n  Number of direct read requests          ===> %lu", appl_ptr->direct_read_reqs);
   fprintf(outstream, "\n  Number of direct write requests         ===> %lu", appl_ptr->direct_write_reqs);
   fprintf(outstream, "\n  Direct read time                        ===> %lu milliseconds", appl_ptr->direct_read_time);
   fprintf(outstream, "\n  Direct write time                       ===> %lu milliseconds", appl_ptr->direct_write_time);

   fprintf(outstream, "\n\nSQL Statement counts");
   fprintf(outstream, "\n  Number of Commit SQL statements         ===> %lu", appl_ptr->commit_sql_stmts);
   fprintf(outstream, "\n  Number of Rollback SQL statements       ===> %lu", appl_ptr->rollback_sql_stmts);
   fprintf(outstream, "\n  Number of Dynamic SQL statements        ===> %lu", appl_ptr->dynamic_sql_stmts);
   fprintf(outstream, "\n  Number of Static SQL statements         ===> %lu", appl_ptr->static_sql_stmts);
   fprintf(outstream, "\n  Number of Failed SQL statements         ===> %lu", appl_ptr->failed_sql_stmts);
   fprintf(outstream, "\n  Number of Select SQL statements         ===> %lu", appl_ptr->select_sql_stmts);
   fprintf(outstream, "\n  Number of Data Def. Language SQL stmts  ===> %lu", appl_ptr->ddl_sql_stmts);
   fprintf(outstream, "\n  Number of Update/Insert/Delete SQL stmts===> %lu", appl_ptr->uid_sql_stmts);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nInternal counts");
   fprintf(outstream, "\n  Number of auto rebinds                  ===> %lu", appl_ptr->int_auto_rebinds);
   fprintf(outstream, "\n  Number of internal row deletions        ===> %lu", appl_ptr->int_rows_deleted);
   fprintf(outstream, "\n  Number of internal row updates          ===> %lu", appl_ptr->int_rows_updated);
   fprintf(outstream, "\n  Number of internal row inserts          ===> %lu", appl_ptr->int_rows_inserted);
   fprintf(outstream, "\n  Number of internal commits              ===> %lu", appl_ptr->int_commits);
   fprintf(outstream, "\n  Number of internal rollbacks            ===> %lu", appl_ptr->int_rollbacks);
   fprintf(outstream, "\n  Number of rollbacks due to deadlocks    ===> %lu", appl_ptr->int_deadlock_rollbacks);

   fprintf(outstream, "\n\nRow counts");
   fprintf(outstream, "\n  Number of row deletions                 ===> %lu", appl_ptr->rows_deleted);
   fprintf(outstream, "\n  Number of row insertions                ===> %lu", appl_ptr->rows_inserted);
   fprintf(outstream, "\n  Number of row updates                   ===> %lu", appl_ptr->rows_updated);
   fprintf(outstream, "\n  Number of row selections                ===> %lu", appl_ptr->rows_selected);
   fprintf(outstream, "\n  Number of rows read                     ===> %lu", appl_ptr->rows_read);
   fprintf(outstream, "\n  Number of rows written                  ===> %lu", appl_ptr->rows_written);

   fprintf(outstream, "\n\n  Number of binds/precompiles             ===> %lu", appl_ptr->binds_precompiles);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nStatement Information:");
   switch (appl_ptr->stmt_type)
   {
      case SQLM_STATIC:
           fprintf(outstream, "\n  Statement Type                          ===> STATIC");
           break;
      case SQLM_DYNAMIC:
           fprintf(outstream, "\n  Statement Type                          ===> DYNAMIC");
           break;
      case SQLM_NON_STMT:
           fprintf(outstream, "\n  Statement Type                          ===> NON-STATEMENT OPERATION");
           break;
      case 0:
           fprintf(outstream, "\n  Statement Type                          ===> ");
           break;
      default:
           fprintf(outstream, "\n  Statement Type                          ===> UNKNOWN (%lu)", appl_ptr->stmt_type);
           break;
   }

   switch (appl_ptr->stmt_operation)
   {
      case SQLM_PREPARE:
           fprintf(outstream, "\n  Statement Operation                     ===> PREPARE");
           break;
      case SQLM_EXECUTE:
           fprintf(outstream, "\n  Statement Operation                     ===> EXECUTE");
           break;
      case SQLM_EXECUTE_IMMEDIATE:
           fprintf(outstream, "\n  Statement Operation                     ===> EXECUTE IMMEDIATE");
           break;
      case SQLM_OPEN:
           fprintf(outstream, "\n  Statement Operation                     ===> OPEN");
           break;
      case SQLM_FETCH:
           fprintf(outstream, "\n  Statement Operation                     ===> FETCH");
           break;
      case SQLM_CLOSE:
           fprintf(outstream, "\n  Statement Operation                     ===> CLOSE");
           break;
      case SQLM_DESCRIBE:
           fprintf(outstream, "\n  Statement Operation                     ===> DESCRIBE");
           break;
      case SQLM_STATIC_COMMIT:
           fprintf(outstream, "\n  Statement Operation                     ===> STATIC COMMIT");
           break;
      case SQLM_STATIC_ROLLBACK:
           fprintf(outstream, "\n  Statement Operation                     ===> STATIC ROLLBACK");
           break;
      case 0:
           fprintf(outstream, "\n  Statement Operation                     ===>");
           break;
      default:
           fprintf(outstream, "\n  Statement Operation                     ===>UNKNOWN (%lu", appl_ptr->stmt_operation);
           break;
   }  /* switch (appl_ptr->stmt_operation) */

   fprintf(outstream, "\n  Section Number                          ===> %lu", appl_ptr->section_number);
   fprintf(outstream, "\n  Statement Length                        ===> %lu", appl_ptr->stmt_length);
   fprintf(outstream, "\n  No. of sorts for this statement         ===> %lu", appl_ptr->stmt_sorts);
   ltime  = appl_ptr->stmt_start.seconds;
   fprintf(outstream, "\n  Statement Operation Start Time          ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   ltime  = appl_ptr->stmt_stop.seconds;
   fprintf(outstream, "\n  Statement Operation Stop Time           ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   fprintf(outstream, "\n  Statement User CPU time                 ===> %lu.%0.6lu seconds",
           appl_ptr->stmt_usr_cpu_time.seconds,
           appl_ptr->stmt_usr_cpu_time.microsec);
   fprintf(outstream, "\n  Statement System CPU time               ===> %lu.%0.6lu seconds",
           appl_ptr->stmt_sys_cpu_time.seconds,
           appl_ptr->stmt_sys_cpu_time.microsec);
   fprintf(outstream, "\n  Cursor Name                             ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->cursor_name);
   fprintf(outstream, "\n  Application Creator                     ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->creator);
   fprintf(outstream, "\n  Package Name                            ===> %0.*s", SQLM_IDENT_SZ, appl_ptr->package_name);

   /********************************************************************/
   /* if stmt_length is greater than zero, then we have a Dynamic SQL  */
   /* statement text returned in the buffer. The statement text is     */
   /* located immediately following the sqlm_appl data structure.      */
   /* We set the stmt_text_ptr to the current position, plus the size  */
   /* of the sqlm_appl data structure we are currently processing.     */
   /********************************************************************/

   if (appl_ptr->stmt_length > 0L)
   {
      stmt_text_ptr = (char *) (buffer_index + appl_ptr->size);

      /*****************************************************************/
      /* If the statement text length is greater than 2048 characters, */
      /* we have chosen to only display the first 2048 characters.     */
      /* The actual number of characters returned in the buffer is the */
      /* lesser of the actual statement length, or the Configuration   */
      /* parameter SQLSTMTSIZE.                                        */
      /*****************************************************************/

      fprintf(outstream, "\n  Dynamic Statement text (up to 2048 chars):\n     ===> %0.*s",
                                   min(2048, appl_ptr->stmt_length), stmt_text_ptr);
   }

   fprintf(outstream, "\n\nUOW Information:");
   fprintf(outstream, "\n  Log space used in current UOW           ===> %lu", appl_ptr->uow_log_space_used);

   switch (appl_ptr->uow_comp_status)
   {
      case SQLM_UOWCOMMIT:
         fprintf(outstream, "\n  UOW Completion Status                   ===> UOW Commit");
         break;
      case SQLM_UOWROLLBACK:
         fprintf(outstream, "\n  UOW Completion Status                   ===> UOW Rolled Back");
         break;
      case SQLM_UOWDEADLOCK:
         fprintf(outstream, "\n  UOW Completion Status                   ===> UOW RB due to Deadlock");
         break;
      case SQLM_UOWABEND:
         fprintf(outstream, "\n  UOW Completion Status                   ===> UOW RB due to Abend");
         break;
      case SQLM_APPL_END:
         fprintf(outstream, "\n  UOW Completion Status                   ===> Appl Normal Termination");
         break;
      case SQLM_UOWLOCKTIMEOUT:
         fprintf(outstream, "\n  UOW Completion Status                   ===> UOW RB - Lock Timeout");
         break;
      case 0:
         fprintf(outstream, "\n  UOW Completion Status                   ===> ");
         break;
      default:
         fprintf(outstream, "\n  UOW Completion Status                   ===> Unknown (%lu)", appl_ptr->uow_comp_status);
         break;
   } /* endswitch */

   ltime  = appl_ptr->prev_uow_stop_time.seconds;
   fprintf(outstream, "\n  Previous UOW stop time                  ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   ltime  = appl_ptr->uow_start_time.seconds;
   fprintf(outstream, "\n  UOW start time                          ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   ltime  = appl_ptr->uow_stop_time.seconds;
   fprintf(outstream, "\n  UOW stop time                           ===> %24.24s", (ltime) ? ctime(&ltime) : "");

   if (output_opt == SCREEN_OUTPUT)
      pause();

   fprintf(outstream, "\n\nCursor Information:");
   fprintf(outstream, "\n  Currently open remote cursors           ===> %lu", appl_ptr->open_rem_curs);
   fprintf(outstream, "\n  Currently open remote blocked cursors   ===> %lu", appl_ptr->open_rem_curs_blk);
   fprintf(outstream, "\n  Currently open local cursors            ===> %lu", appl_ptr->open_loc_curs);
   fprintf(outstream, "\n  Currently open local blocked cursors    ===> %lu", appl_ptr->open_loc_curs_blk);
   fprintf(outstream, "\n  Rejected block cursor requests          ===> %lu", appl_ptr->rej_curs_blk);
   fprintf(outstream, "\n  Accepted block cursor requests          ===> %lu", appl_ptr->acc_curs_blk);

   fprintf(outstream, "\n\nApplication Times/Timestamps:");
   ltime = appl_ptr->appl_con_time.seconds;
   fprintf(outstream, "\n  Application connect start time          ===> %24.24s",
                                       (ltime) ? ctime(&ltime) : "");
   ltime = appl_ptr->conn_complete_time.seconds;
   fprintf(outstream, "\n  Connect completion time                 ===> %24.24s",
                                       (ltime) ? ctime(&ltime) : "");
   ltime = appl_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last reset time                         ===> %24.24s",
                                       (ltime) ? ctime(&ltime) : "");
   fprintf(outstream, "\n  Application User CPU time               ===> %lu.%0.6lu seconds",
           appl_ptr->agent_usr_cpu_time.seconds,
           appl_ptr->agent_usr_cpu_time.microsec);
   fprintf(outstream, "\n  Application System CPU time             ===> %lu.%0.6lu seconds",
           appl_ptr->agent_sys_cpu_time.seconds,
           appl_ptr->agent_sys_cpu_time.microsec);

   fprintf(outstream, "\n\nPackage Cache Information:");
   fprintf(outstream, "\n  Package Cache Lookups                   ===> %lu", appl_ptr->pkg_cache_lookups);
   fprintf(outstream, "\n  Package Cache Inserts                   ===> %lu", appl_ptr->pkg_cache_inserts);

   fprintf(outstream, "\n\nCatalog Cache Information:");
   fprintf(outstream, "\n  Catalog Cache Overflows                 ===> %lu", appl_ptr->cat_cache_overflows);
   fprintf(outstream, "\n  Catalog Cache Heap Full                 ===> %lu", appl_ptr->cat_cache_heap_full);

   /* advance buffer_index to next structure in the output buffer */
   buffer_index += (unsigned int)(appl_ptr->size + appl_ptr->stmt_length);

   if (output_opt == SCREEN_OUTPUT)
      pause();

} /* process_appl */


/*****************************************************************************/
/* process_applinfo                                                          */
/* This function processes summary application information. The information  */
/* is in an sqlm_applinfo data structure                                     */
/*****************************************************************************/

void process_applinfo()
{

   long                  ltime;
   struct sqlm_applinfo  *applinfo_ptr;

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                   SUMMARY APPLICATION INFORMATION                  *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast buffer contents to an sqlm_applinfo data structure */
   applinfo_ptr = (struct sqlm_applinfo *)(buffer_index);

   fprintf(outstream, "\n  Application agent id                   ===> %lu\n", applinfo_ptr->id_info.agent_id);
   switch (applinfo_ptr->id_info.appl_status)
   {
      case SQLM_CONNECTPEND:
         fprintf(outstream, "\n  Application Status                     ===> Connect Pending");
         break;
      case SQLM_CONNECTED:
         fprintf(outstream, "\n  Application Status                     ===> Connected");
         break;
      case SQLM_UOWEXEC:
         fprintf(outstream, "\n  Application Status                     ===> UOW Executing");
         break;
      case SQLM_UOWWAIT:
         fprintf(outstream, "\n  Application Status                     ===> UOW Waiting in the application");
         break;
      case SQLM_LOCKWAIT:
         fprintf(outstream, "\n  Application Status                     ===> Lock Waiting");
         break;
      case SQLM_COMMIT_ACT:
         fprintf(outstream, "\n  Application Status                     ===> Commit Active");
         break;
      case SQLM_ROLLBACK_ACT:
         fprintf(outstream, "\n  Application Status                     ===> Rollback Active");
         break;
      case SQLM_RECOMP:
         fprintf(outstream, "\n  Application Status                     ===> Recompiling Plan");
         break;
      case SQLM_COMP:
         fprintf(outstream, "\n  Application Status                     ===> Compiling SQL Stmt");
         break;
      case SQLM_INTR:
         fprintf(outstream, "\n  Application Status                     ===> Request Interupted");
         break;
      case SQLM_DISCONNECTPEND:
         fprintf(outstream, "\n  Application Status                     ===> Disconnect Pending");
         break;
      case SQLM_TPREP:
         fprintf(outstream, "\n  Application Status                     ===> Prepared Transaction");
         break;
      case SQLM_THCOMT:
         fprintf(outstream, "\n  Application Status                     ===> Trans. heuristically committed");
         break;
      case SQLM_THABRT:
         fprintf(outstream, "\n  Application Status                     ===> Trans. heuristically aborted");
         break;
      case SQLM_TEND:
         fprintf(outstream, "\n  Application Status                     ===> Transaction ended");
         break;
      case SQLM_CREATE_DB:
         fprintf(outstream, "\n  Application Status                     ===> Creating Database");
         break;
      case SQLM_RESTART:
         fprintf(outstream, "\n  Application Status                     ===> Restarting Database");
         break;
      case SQLM_RESTORE:
         fprintf(outstream, "\n  Application Status                     ===> Restoring Database");
         break;
      case SQLM_BACKUP:
         fprintf(outstream, "\n  Application Status                     ===> Backing Up Database");
         break;
      case SQLM_LOAD:
         fprintf(outstream, "\n  Application Status                     ===> Loading Database");
         break;
      case SQLM_UNLOAD:
         fprintf(outstream, "\n  Application Status                     ===> Unloading Database");
         break;
      case SQLM_IOERROR_WAIT:
         fprintf(outstream, "\n  Application Status                     ===> I/O Error Waiting");
         break;
      case SQLM_QUIESCE_TABLESPACE:
         fprintf(outstream, "\n  Application Status                     ===> Quiescing a Tablespace");
         break;
      default:
         fprintf(outstream, "\n  Application Status                     ===> Unknown (%lu)", applinfo_ptr->id_info.appl_status );
         break;
   } /* endswitch */

   fprintf(outstream, "\n  Application codepage id                ===> %lu", applinfo_ptr->id_info.codepage_id);
   fprintf(outstream, "\n  Application country code               ===> %lu", applinfo_ptr->country_code);

   ltime  = applinfo_ptr->id_info.status_change_time.seconds;
   fprintf(outstream, "\n  Application Status change time         ===> %24.24s", (ltime) ? ctime(&ltime) : "");
   fprintf(outstream, "\n  Application Name                       ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.appl_name);
   fprintf(outstream, "\n  Application Id                         ===> %0.*s", SQLM_APPLID_SZ, applinfo_ptr->id_info.appl_id);
   fprintf(outstream, "\n  Application Id Sequence number         ===> %0.*s", SQLM_SEQ_SZ, applinfo_ptr->id_info.sequence_no);
   fprintf(outstream, "\n  DRDA AS Correlation Token              ===> %0.*s", SQLM_APPLID_SZ, applinfo_ptr->corr_token);
   fprintf(outstream, "\n  Application Authorization Id           ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.auth_id);
   fprintf(outstream, "\n  Application Execution Id               ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->execution_id);
   fprintf(outstream, "\n  Application client NNAME               ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.client_nname);
   fprintf(outstream, "\n  Application client Product name        ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.client_prdid);
   fprintf(outstream, "\n  Application client Process Id          ===> %lu", applinfo_ptr->client_pid);

   switch (applinfo_ptr->client_platform)
   {
      case SQLM_PLATFORM_OS2:
         fprintf(outstream, "\n  Application client platform            ===> OS/2");
         break;
      case SQLM_PLATFORM_DOS:
         fprintf(outstream, "\n  Application client platform            ===> DOS");
         break;
      case SQLM_PLATFORM_WINDOWS:
         fprintf(outstream, "\n  Application client platform            ===> WINDOWS");
         break;
      case SQLM_PLATFORM_AIX:
         fprintf(outstream, "\n  Application client platform            ===> AIX");
         break;
      case SQLM_PLATFORM_HP:
         fprintf(outstream, "\n  Application client platform            ===> HP");
         break;
      case SQLM_PLATFORM_SUN:
         fprintf(outstream, "\n  Application client platform            ===> SUN");
         break;
      case SQLM_PLATFORM_MVS_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> MVS via DRDA");
         break;
      case SQLM_PLATFORM_AS400_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> AS400 via DRDA");
         break;
      case SQLM_PLATFORM_VM_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> VM via DRDA");
         break;
      case SQLM_PLATFORM_UNKNOWN_DRDA:
         fprintf(outstream, "\n  Application client platform            ===> Unknown via DRDA");
         break;
      case SQLM_PLATFORM_UNKNOWN:
         fprintf(outstream, "\n  Application client platform            ===> Unknown");
         break;
      default:
         fprintf(outstream, "\n  Application client platform            ===> Unknown (%lu)", applinfo_ptr->client_platform);
         break;
   } /* endswitch */

   switch (applinfo_ptr->client_protocol)
   {
      case SQLM_PROT_APPC:
         fprintf(outstream, "\n  Application client comms protocol      ===> APPC");
         break;
      case SQLM_PROT_NETBIOS:
         fprintf(outstream, "\n  Application client comms protocol      ===> Netbios");
         break;
      case SQLM_PROT_APPN:
         fprintf(outstream, "\n  Application client comms protocol      ===> APPN");
         break;
      case SQLM_PROT_TCPIP:
         fprintf(outstream, "\n  Application client comms protocol      ===> TCPIP");
         break;
      case SQLM_PROT_CPIC:
         fprintf(outstream, "\n  Application client comms protocol      ===> CPIC");
         break;
      case SQLM_PROT_IPXSPX:
         fprintf(outstream, "\n  Application client comms protocol      ===> IPX/SPX");
         break;
      case SQLM_PROT_LOCAL:
         fprintf(outstream, "\n  Application client comms protocol      ===> Local");
         break;
      case SQLM_PROT_NPIPE:
         fprintf(outstream, "\n  Application client comms protocol      ===> Named Pipe");
         break;
      default:
         fprintf(outstream, "\n  Application client comms protocol      ===> Unknown (%lu)", applinfo_ptr->client_protocol);
         break;
   } /* endswitch */


   fprintf(outstream, "\n  Input Database Alias                   ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.input_db_alias);
   fprintf(outstream, "\n  Client Database Alias                  ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.client_db_alias);
   fprintf(outstream, "\n  Database Name                          ===> %0.*s", SQLM_IDENT_SZ, applinfo_ptr->id_info.db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s\n", applinfo_ptr->id_info.db_path);

   buffer_index += (unsigned int) applinfo_ptr->size; /* move to next struct */

   if (output_opt == SCREEN_OUTPUT)
      pause();

}  /* process_applinfo */

/*****************************************************************************/
/* process_dcs_applinfo                                                      */
/* This function processes DDCS application information. The information     */
/* is in an sqlm_dcs_applinfo data structure .                               */
/* This information is only available from a DDCS server.                    */
/*****************************************************************************/

void process_dcs_applinfo()
{

   long                  ltime;
   struct sqlm_dcs_applinfo  *dcs_applinfo_ptr;

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                     DDCS APPLICATION INFORMATION                   *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast the buffer contents to an sqlm_dcs_applinfo data structure */
   dcs_applinfo_ptr = (struct sqlm_dcs_applinfo *)(buffer_index);

   fprintf(outstream, "\n  Application agent id                   ===> %lu\n", dcs_applinfo_ptr->agent_id);
   fprintf(outstream, "\n  Application codepage id                ===> %lu", dcs_applinfo_ptr->codepage_id);
   fprintf(outstream, "\n  Application Name                       ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->appl_name);
   fprintf(outstream, "\n  Application Id                         ===> %0.*s", SQLM_APPLID_SZ, dcs_applinfo_ptr->appl_id);
   fprintf(outstream, "\n  Application Id Sequence number         ===> %0.*s", SQLM_SEQ_SZ, dcs_applinfo_ptr->sequence_no);
   fprintf(outstream, "\n  Application Authorization Id           ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->auth_id);
   fprintf(outstream, "\n  Application client NNAME               ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->client_nname);
   fprintf(outstream, "\n  Application client Product name        ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->client_prdid);
   fprintf(outstream, "\n  Client Database Alias                  ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->client_db_alias);
   fprintf(outstream, "\n  Database Name                          ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->db_name);
   fprintf(outstream, "\n  Host Product Id                        ===> %0.*s", SQLM_IDENT_SZ, dcs_applinfo_ptr->host_prdid);
   fprintf(outstream, "\n  Outbound Application Id                ===> %0.*s", SQLM_APPLID_SZ, dcs_applinfo_ptr->outbound_appl_id);
   fprintf(outstream, "\n  Outbound Sequence number               ===> %0.*s\n", SQLM_SEQ_SZ, dcs_applinfo_ptr->outbound_sequence_no);

   buffer_index += (unsigned int) dcs_applinfo_ptr->size; /* move to next struct */

   if (output_opt == SCREEN_OUTPUT)
      pause();

}  /* process_dcs_applinfo */

/*****************************************************************************/
/* process_table                                                             */
/* This function processes table information. This information is stored in  */
/* sqlm_table_header and sqlm_table data structures. First, we find an       */
/* sqlm_table_header structure, which provides general information, and the  */
/* number of sqlm_table structures following in the buffer.                  */
/*****************************************************************************/

void process_table()
{

   long                     ltime;
   unsigned int             i;              /* counter                       */
   struct sqlm_table        *table_ptr;
   struct sqlm_table_header *table_header_ptr;
   char                     table_type[21];
   char                     *c;

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                          TABLE INFORMATION                         *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast buffer contents to an sqlm_table_header data structure */
   table_header_ptr = (struct sqlm_table_header *) (buffer_index);

   fprintf(outstream, "\nTable Header Information:");
   fprintf(outstream, "\n  Number of tables collected              ===> %lu", table_header_ptr->num_tables);
   ltime = table_header_ptr->db_conn_time.seconds;
   fprintf(outstream, "\n  First database connect time             ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");
   ltime = table_header_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last reset time                         ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");

   fprintf(outstream, "\n  Input Database Alias                    ===> %0.*s", SQLM_IDENT_SZ, table_header_ptr->input_db_alias);
   fprintf(outstream, "\n  Database Name                           ===> %0.*s", SQLM_IDENT_SZ, table_header_ptr->db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s", table_header_ptr->db_path);

   if (output_opt == SCREEN_OUTPUT)
      pause();

   /* advance pointer to first sqlm_table structure */
   buffer_index += table_header_ptr->size;

   /* process each sqlm_table structure returned */
   for (i = 0; i < table_header_ptr->num_tables; ++i)
   {

      /* cast buffer contents to an sqlm_table data structure */
      table_ptr = (struct sqlm_table *)(buffer_index);

      if (table_ptr->info_type != SQLM_TABLE_SS)
      {
         printf("\n\n***************************************************************\n");
         printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
         printf("*    Expecting sqlm_table structure. First chars: %10c   *\n",(unsigned char)*buffer_index);
         printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
         printf("*    Exiting ssdriver.                                        *\n\n");
         printf("\n***************************************************************\n");
         cleanup(NULL);
         exit(99);
      }

      /***************************************************************/
      /* Print the headers before the first table's info             */
      /***************************************************************/

      if (i == 0)
      {
         fprintf(outstream, "Individual Table Information:\n");
         fprintf(outstream, "Table Name                   Table Type    Rows Written  Rows Read   Overflows\n");
         fprintf(outstream, "---------------------------  ------------  ------------  ----------  ----------\n");
      }

      switch(table_ptr->table_type)
      {
         case SQLM_USER_TABLE:
              strcpy(table_type, "User");
              break;
         case SQLM_DROPPED_TABLE:
              strcpy(table_type, "Dropped User");
              break;
         case SQLM_TEMP_TABLE:
              strcpy(table_type, "Temporary");
              break;
         case SQLM_CATALOG_TABLE:
              strcpy(table_type, "Catalog");
              break;
         case SQLM_REORG_TABLE:
              strcpy(table_type, "Reorg");
              break;
         default:
              strcpy(table_type, "Unknown");
              break;
      }

      /***********************************************************************/
      /* Null terminate the table_schema                                     */
      /***********************************************************************/
      for (c = table_ptr->table_schema; *c != ' '; ++c);
      *c = '\0';

      /***********************************************************************/
      /* Display information about each table in a tabular format similar    */
      /* to the one provided by the CLP command.                             */
      /***********************************************************************/
      fprintf(outstream, "%s.%-.*s  %-*s    %*lu  %*lu  %*lu\n",
                             table_ptr->table_schema,
                         18 + 8 - strlen(table_ptr->table_schema),
                             table_ptr->table_name,
                         12, table_type,
                         10, table_ptr->rows_written,
                         10, table_ptr->rows_read,
                         10, table_ptr->overflow_accesses);

      /* move pointer to next structure */
      buffer_index += table_ptr->size;

   } /* end of for loop */

   if ((output_opt == SCREEN_OUTPUT) && (table_header_ptr->num_tables > 0))
      pause();

} /* process_table */


/*****************************************************************************/
/* process_lock                                                              */
/* This function processes lock information. This information is contained   */
/* in sqlm_dbase_lock, sqlm_appl_lock, and sqlm_lock data structures.        */
/* First, an sqlm_dbase_lock structure with information on the database, and */
/* the number of sqlm_appl_lock structures returned. Each sqlm_appl_lock     */
/* structure contains application info, and the number of sqlm_lock          */
/* structures following in the buffer.                                       */
/*****************************************************************************/

void process_lock()
{

   long                   ltime;
   unsigned int           i, j;              /* counters                      */
   struct sqlm_dbase_lock *dbase_lock_ptr;   /* local ptr to sqlm_dbase_lock  */
   struct sqlm_appl_lock  *appl_lock_ptr;    /* local ptr to sqlm_appl_lock   */
   struct sqlm_lock       *lock_ptr;         /* local ptr to sqlm_lock        */
   char                   lock_type[15];     /* string for lock object type   */
   char                   lock_mode[5];      /* string for lock mode          */
   char                   lock_status[11];   /* string for lock status        */
   char                   lock_obj_name[41]; /* string for lock object name   */
   char                   *c;


   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                          LOCK INFORMATION                          *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast the buffer contents to an sqlm_dbase_lock data structure */
   dbase_lock_ptr = (struct sqlm_dbase_lock *)(buffer_index);

   fprintf(outstream, "\nDatabase Lock Information:");
   fprintf(outstream, "\n  Locks currently held                    ===> %lu", dbase_lock_ptr->locks_held);
   fprintf(outstream, "\n  No. of applications currently connected ===> %lu", dbase_lock_ptr->appls_cur_cons);
   fprintf(outstream, "\n  Applications waiting on locks           ===> %lu", dbase_lock_ptr->locks_waiting);
   fprintf(outstream, "\n  Input Database Alias                    ===> %0.*s", SQLM_IDENT_SZ, dbase_lock_ptr->input_db_alias);
   fprintf(outstream, "\n  Database Name                           ===> %0.*s", SQLM_IDENT_SZ, dbase_lock_ptr->db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s", dbase_lock_ptr->db_path);

   fprintf(outstream, "\n  Number of sqlm_appl_lock returned       ===> %lu\n", dbase_lock_ptr->num_appls);

   /* advance buffer_index to the next structure in the buffer */
   buffer_index += dbase_lock_ptr->size;

   if (output_opt == SCREEN_OUTPUT)
      pause();

   /*******************************************************************************/
   /* Loop until all sqlm_appl_lock structures are processed                      */
   /*******************************************************************************/

   for (i = 0; i < dbase_lock_ptr->num_appls; i++)
   {
      /* cast the buffer contents to an sqlm_appl_lock data structure */
      appl_lock_ptr = (struct sqlm_appl_lock *)(buffer_index);

      if (appl_lock_ptr->info_type != SQLM_APPL_LOCK_SS)
      {
         printf("\n\n***************************************************************\n");
         printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
         printf("*    Expecting sqlm_appl_lock structure. First chars: %10c *\n",(unsigned char)*buffer_index);
         printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
         printf("*    Exiting ssdriver.                                        *\n\n");
         printf("\n***************************************************************\n");
         cleanup(NULL);
         exit(99);
      }

      fprintf(outstream, "\n\nApplication Lock Information:");
      fprintf(outstream, "\n      Agent ID                            ===> %lu", appl_lock_ptr->agent_id);
      switch (appl_lock_ptr->appl_status)
      {
         case SQLM_CONNECTPEND:
            fprintf(outstream, "\n      Application Status                  ===> Connect Pending");
            break;
         case SQLM_CONNECTED:
            fprintf(outstream, "\n      Application Status                  ===> Connected");
            break;
         case SQLM_UOWEXEC:
            fprintf(outstream, "\n      Application Status                  ===> UOW Executing");
            break;
         case SQLM_UOWWAIT:
            fprintf(outstream, "\n      Application Status                  ===> UOW Waiting in the application");
            break;
         case SQLM_LOCKWAIT:
            fprintf(outstream, "\n      Application Status                  ===> Lock Waiting");
            break;
         case SQLM_COMMIT_ACT:
            fprintf(outstream, "\n      Application Status                  ===> Commit Active");
            break;
         case SQLM_ROLLBACK_ACT:
            fprintf(outstream, "\n      Application Status                  ===> Rollback Active");
            break;
         case SQLM_RECOMP:
            fprintf(outstream, "\n      Application Status                  ===> Recompiling Plan");
            break;
         case SQLM_COMP:
            fprintf(outstream, "\n      Application Status                  ===> Compiling SQL Stmt");
            break;
         case SQLM_INTR:
            fprintf(outstream, "\n      Application Status                  ===> Request Interupted");
            break;
         case SQLM_DISCONNECTPEND:
            fprintf(outstream, "\n      Application Status                  ===> Disconnect Pending");
            break;
         case SQLM_TPREP:
            fprintf(outstream, "\n      Application Status                  ===> Prepared Transaction");
            break;
         case SQLM_THCOMT:
            fprintf(outstream, "\n      Application Status                  ===> Trans. heuristically committed");
            break;
         case SQLM_THABRT:
            fprintf(outstream, "\n      Application Status                  ===> Trans. heuristically aborted");
            break;
         case SQLM_TEND:
            fprintf(outstream, "\n      Application Status                  ===> Transaction ended");
            break;
         case SQLM_CREATE_DB:
            fprintf(outstream, "\n      Application Status                  ===> Creating Database");
            break;
         case SQLM_RESTART:
            fprintf(outstream, "\n      Application Status                  ===> Restarting Database");
            break;
         case SQLM_RESTORE:
            fprintf(outstream, "\n      Application Status                  ===> Restoring Database");
            break;
         case SQLM_BACKUP:
            fprintf(outstream, "\n      Application Status                  ===> Backing Up Database");
            break;
         case SQLM_LOAD:
            fprintf(outstream, "\n      Application Status                  ===> Loading Database");
            break;
         case SQLM_UNLOAD:
            fprintf(outstream, "\n      Application Status                  ===> Unloading Database");
            break;
         case SQLM_IOERROR_WAIT:
            fprintf(outstream, "\n      Application Status                  ===> I/O Error Waiting");
            break;
         case SQLM_QUIESCE_TABLESPACE:
            fprintf(outstream, "\n      Application Status                  ===> Quiescing a Tablespace");
            break;
         default:
            fprintf(outstream, "\n      Application Status                  ===> Unknown (%lu)", appl_lock_ptr->appl_status);
            break;
      } /* endswitch */
      fprintf(outstream, "\n      Application Codepage Id             ===> %lu", appl_lock_ptr->codepage_id);
      fprintf(outstream, "\n      Locks currently held by application ===> %lu", appl_lock_ptr->locks_held);
      ltime = appl_lock_ptr->status_change_time.seconds;
      fprintf(outstream, "\n      Application status change time      ===> %24.24s",
                                  (ltime) ? ctime(&ltime) : "");

      fprintf(outstream, "\n      Application Id                      ===> %0.*s", SQLM_APPLID_SZ, appl_lock_ptr->appl_id);
      fprintf(outstream, "\n      Application Id sequence number      ===> %0.*s", SQLM_SEQ_SZ, appl_lock_ptr->sequence_no);
      fprintf(outstream, "\n      Application name                    ===> %0.*s", SQLM_IDENT_SZ, appl_lock_ptr->appl_name);
      fprintf(outstream, "\n      Authorization ID                    ===> %0.*s", SQLM_IDENT_SZ, appl_lock_ptr->auth_id);
      fprintf(outstream, "\n      Client database alias               ===> %0.*s", SQLM_IDENT_SZ, appl_lock_ptr->client_db_alias);

      fprintf(outstream, "\n    Lock waited on information:");
      fprintf(outstream, "\n      Agent Id holding lock               ===> %lu", appl_lock_ptr->agent_id_holding_lk);
      fprintf(outstream, "\n      Lock object name appl waiting on    ===> %lu", appl_lock_ptr->lock_object_name);
      switch (appl_lock_ptr->lock_object_type)
      {
         case SQLM_ROW_LOCK:
              fprintf(outstream, "\n      Type of lock                        ===> ROW");
              break;
         case SQLM_TABLE_LOCK:
              fprintf(outstream, "\n      Type of lock                        ===> TABLE");
              break;
         case SQLM_INTERNAL_LOCK:
              fprintf(outstream, "\n      Type of lock                        ===> INTERNAL");
              break;
         case SQLM_TABLESPACE_LOCK:
              fprintf(outstream, "\n      Type of lock                        ===> TABLESPACE");
              break;
         case 0L:
              fprintf(outstream, "\n      Type of lock                        ===> No Lock");
              break;
         default:
              fprintf(outstream, "\n      Type of lock                        ===> UNKNOWN (%lu)", appl_lock_ptr->lock_object_type);
              break;
      }  /* switch */
      if (appl_lock_ptr->table_name[0] != ' ')
      {
         /* Null terminate table schema */
         char *c;
         for (c = appl_lock_ptr->table_schema; *c != ' '; ++c);
         *c = '\0';
         fprintf(outstream, "\n      Table Name of lock waited on        ===> %s.%-.*s", appl_lock_ptr->table_schema, SQLM_IDENT_SZ, appl_lock_ptr->table_name);
      }
      else
         fprintf(outstream, "\n      Table Name of lock waited on        ===>");
      fprintf(outstream, "\n      Tablespace Name of lock waited on   ===> %0.*s", SQLM_IDENT_SZ, appl_lock_ptr->tablespace_name);
      fprintf(outstream, "\n      Application Id holding lock         ===> %0.*s", SQLM_APPLID_SZ, appl_lock_ptr->appl_id_holding_lk);
      fprintf(outstream, "\n      Sequence no holding lock            ===> %0.*s", SQLM_SEQ_SZ, appl_lock_ptr->sequence_no_holding_lk);

      fprintf(outstream, "\n      number of locks returned            ===> %lu\n", appl_lock_ptr->num_locks);

      /* advance to next structure in the buffer */
      buffer_index += appl_lock_ptr->size;

      if (output_opt == SCREEN_OUTPUT)
         pause();


      /*********************************************************************/
      /* Display information for each of the locks held by the application */
      /*********************************************************************/

      for (j = 0; j < appl_lock_ptr->num_locks; j++)
      {
         /* cast the buffer contents to an sqlm_lock data structure */
         lock_ptr = (struct sqlm_lock *)(buffer_index);

         if (lock_ptr->info_type != SQLM_LOCK_SS)
         {
            printf("\n\n***************************************************************\n");
            printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
            printf("*    Expecting sqlm_lock structure. First chars: %10c   *\n",(unsigned char)*buffer_index);
            printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
            printf("*    Exiting ssdriver.                                        *\n\n");
            printf("\n***************************************************************\n");
            cleanup(NULL);
            exit(99);
         }


         /*****************************************************************/
         /* Print headers before first lock information                   */
         /*****************************************************************/

         if (j == 0)
         {
            fprintf(outstream, "\nIndividual Lock Information:");
            fprintf(outstream, "\nObject Name                                Object Type        Mode   Status\n");
            fprintf(outstream, "----------------------------------------   ---------------    ----   ----------\n");
         }

         /* Null terminate table schema */
         for (c = lock_ptr->table_schema; *c != ' '; ++c);
         *c = '\0';
         switch (lock_ptr->lock_object_type)
         {
            case SQLM_ROW_LOCK:
                 strcpy(lock_type, "Row");
                 sprintf(lock_obj_name, "%s.%-.*s (%ld)",
                         lock_ptr->table_schema,
                         18 + 8 - strlen(lock_ptr->table_schema),
                         lock_ptr->table_name, lock_ptr->lock_object_name);
                 break;
            case SQLM_TABLE_LOCK:
                 strcpy(lock_type, "Table");
                 sprintf(lock_obj_name, "%s.%-.*s",
                         lock_ptr->table_schema,
                         18 + 8 - strlen(lock_ptr->table_schema),
                         lock_ptr->table_name);
                 break;
            case SQLM_INTERNAL_LOCK:
                 strcpy(lock_type, "Internal");
                 lock_obj_name[0] = '\0';
                 break;
            case SQLM_TABLESPACE_LOCK:
                 strcpy(lock_type, "Tablespace");
                 sprintf(lock_obj_name, "%.*s", 18, lock_ptr->tablespace_name);
                 break;
            default:
                 strcpy(lock_type, "Unknown");
                 break;
         }  /* switch */

         switch (lock_ptr->lock_mode)
         {
            case SQLM_LNON:
                 strcpy(lock_mode, "NO");
                 break;
            case SQLM_LOIS:
                 strcpy(lock_mode, "IS");
                 break;
            case SQLM_LOIX:
                 strcpy(lock_mode, "IX");
                 break;
            case SQLM_LOOS:
                 strcpy(lock_mode, "S");
                 break;
            case SQLM_LSIX:
                 strcpy(lock_mode, "SIX");
                 break;
            case SQLM_LOOX:
                 strcpy(lock_mode, "X");
                 break;
            case SQLM_LOIN:
                 strcpy(lock_mode, "IN");
                 break;
            case SQLM_LOOZ:
                 strcpy(lock_mode, "Z");
                 break;
            case SQLM_LOOU:
                 strcpy(lock_mode, "U");
                 break;
            default:
                 strcpy(lock_mode, "????");
                 break;
         } /* endswitch */

         switch (lock_ptr->lock_status)
         {
            case SQLM_LRBGRNT:
                 strcpy(lock_status, "Granted");
                 break;
            case SQLM_LRBCONV:
                 strcpy(lock_status, "Converting");
                 break;
            default:
                 strcpy(lock_status, "Unknown");
                 break;
         }  /* switch */

         /*******************************************************************/
         /* Display information about each lock in a tabular format similar */
         /* to the one returned by the CLP Get Snapshot command.            */
         /*******************************************************************/
         fprintf(outstream, " %-*s  %-*s     %-*s  %-*s\n",
                            40, lock_obj_name,
                            15, lock_type,
                            4,  lock_mode,
                            10, lock_status);

         /* advance to next structure in the buffer */
         buffer_index += lock_ptr->size;
         } /* endfor */

      if (output_opt == SCREEN_OUTPUT)
         pause();

      } /* end of for loop */

} /* process_lock */

/*****************************************************************************/
/* process_lock                                                              */
/* This function processes tablespace information. This information is       */
/* contained in sqlm_tablespace_header and sqlm_tablespace data structures.  */
/* First, an sqlm_tablespace_header structure with information on the        */
/* database, and the number of sqlm_tablespace structures returned.          */
/*****************************************************************************/

void process_tablespace()
{

   long                   ltime;
   unsigned int           i, j;              /* counters                      */
   sqlm_tablespace_header   *ts_header_ptr;  /* local ptr to tablespace header*/
   sqlm_tablespace          *ts_ptr;         /* local ptr to tablespace info  */

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                        TABLESPACE INFORMATION                      *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast the buffer contents to an sqlm_tablespace_header data structure */
   ts_header_ptr = (sqlm_tablespace_header *)(buffer_index);

   fprintf(outstream, "\nDatabase Information:");
   fprintf(outstream, "\n  Number of tablespaces collected         ===> %lu", ts_header_ptr->num_tablespaces);
   ltime = ts_header_ptr->db_conn_time.seconds;
   fprintf(outstream, "\n  First database connect time             ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");
   ltime = ts_header_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last reset time                         ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");

   fprintf(outstream, "\n  Input Database Alias                    ===> %0.*s", SQLM_IDENT_SZ, ts_header_ptr->input_db_alias);
   fprintf(outstream, "\n  Database Name                           ===> %0.*s", SQLM_IDENT_SZ, ts_header_ptr->db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s", ts_header_ptr->db_path);

   /* advance buffer_index to the next structure in the buffer */
   buffer_index += ts_header_ptr->size;

   if (output_opt == SCREEN_OUTPUT)
      pause();

   /*******************************************************************************/
   /* Loop until all sqlm_tablespace structures are processed                     */
   /*******************************************************************************/

   for (i = 0; i < ts_header_ptr->num_tablespaces; i++)
   {
      /* cast the buffer contents to an sqlm_tablespace data structure */
      ts_ptr = (struct sqlm_tablespace *)(buffer_index);

      if (ts_ptr->info_type != SQLM_TABLESPACE_SS)
      {
         printf("\n\n***************************************************************\n");
         printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
         printf("*    Expecting sqlm_tablespace structure. First chars: %10c*\n",(unsigned char)*buffer_index);
         printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
         printf("*    Exiting ssdriver.                                        *\n\n");
         printf("\n***************************************************************\n");
         cleanup(NULL);
         exit(99);
      }

      fprintf(outstream, "\n\nTablespace Information:");
      fprintf(outstream, "\n  Tablespace Name                         ===> %0.*s", SQLM_IDENT_SZ, ts_ptr->tablespace_name);

      fprintf(outstream, "\n\nBuffer Pool Information:");
      fprintf(outstream, "\n  Buffer pool logical data page reads     ===> %lu", ts_ptr->pool_data_l_reads);
      fprintf(outstream, "\n  Buffer pool physical data page reads    ===> %lu", ts_ptr->pool_data_p_reads);
      fprintf(outstream, "\n  Buffer pool data page writes            ===> %lu", ts_ptr->pool_data_writes);
      fprintf(outstream, "\n  Buffer pool logical index page reads    ===> %lu", ts_ptr->pool_index_l_reads);
      fprintf(outstream, "\n  Buffer pool physical index page reads   ===> %lu", ts_ptr->pool_index_p_reads);
      fprintf(outstream, "\n  Buffer pool index page writes           ===> %lu", ts_ptr->pool_index_writes);
      fprintf(outstream, "\n  Buffer pool read time since 1st connect ===> %lu milliseconds", ts_ptr->pool_read_time);
      fprintf(outstream, "\n  Buffer pool write time since 1st connect===> %lu milliseconds", ts_ptr->pool_write_time);
      fprintf(outstream, "\n  Files closed since 1st connect          ===> %lu", ts_ptr->files_closed);

      fprintf(outstream, "\n  Buffer pool asynch data page reads      ===> %lu", ts_ptr->pool_async_data_reads);
      fprintf(outstream, "\n  Buffer pool asynch data page reads reqs ===> %lu", ts_ptr->pool_async_data_read_reqs);
      fprintf(outstream, "\n  Buffer pool asynch data page writes     ===> %lu", ts_ptr->pool_async_data_writes);
      fprintf(outstream, "\n  Buffer pool asynch index page writes    ===> %lu", ts_ptr->pool_async_index_writes);
      fprintf(outstream, "\n  Buffer pool asynch read time            ===> %lu milliseconds", ts_ptr->pool_async_read_time);
      fprintf(outstream, "\n  Buffer pool asynch write time           ===> %lu milliseconds", ts_ptr->pool_async_write_time);

      if (output_opt == SCREEN_OUTPUT)
         pause();

      fprintf(outstream, "\n\nDirect I/O Information:");
      fprintf(outstream, "\n  Sectors read directly                   ===> %lu", ts_ptr->direct_reads);
      fprintf(outstream, "\n  Sectors written directly                ===> %lu", ts_ptr->direct_writes);
      fprintf(outstream, "\n  Number of direct read requests          ===> %lu", ts_ptr->direct_read_reqs);
      fprintf(outstream, "\n  Number of direct write requests         ===> %lu", ts_ptr->direct_write_reqs);
      fprintf(outstream, "\n  Direct read time                        ===> %lu milliseconds", ts_ptr->direct_read_time);
      fprintf(outstream, "\n  Direct write time                       ===> %lu milliseconds", ts_ptr->direct_write_time);


      if (output_opt == SCREEN_OUTPUT)
         pause();

      buffer_index += ts_ptr->size;

   } /* end of for loop */

} /* process_tablespace */


/*****************************************************************************/
/* pr_sqlca                                                                  */
/* This function prints the contents of the sqlca error information          */
/* structure.                                                                */
/*****************************************************************************/
void pr_sqlca(struct sqlca *ca)
{

  char           buffer[200];
  unsigned short i;

  /*Print out header for DUMP*/
  fprintf(outstream, "*************************************\n");
  fprintf(outstream, "*         CONTENTS OF SQLCA         *\n");
  fprintf(outstream, "*************************************\n\n");

  /*Print out contents of SQLCA variables*/
  fprintf(outstream, "SQLCABC  = %ld\n", ca->sqlcabc);
  fprintf(outstream, "SQLCODE  = %ld\n", ca->sqlcode);
  fprintf(outstream, "SQLERRMC = %0.70s\n", ca->sqlerrmc);
  fprintf(outstream, "SQLERRP  =  %0.8s\n", ca->sqlerrp);

  sqlaintp(buffer, sizeof(buffer), 80, ca);
  fprintf(outstream, "%0.200s\n", buffer);

  for (i = 0; i < 6; i++)
  {
    fprintf(outstream, "sqlerrd[%d] = %lu \n", i, ca->sqlerrd[i]);
  }

  fprintf(outstream, "SQLWARN  = %0.11s\n", ca->sqlwarn);
  fprintf(outstream, "SQLSTATE = %0.5s\n", ca->sqlstate);
}  /* pr_sqlca */

/*****************************************************************************/
/* cleanup                                                                   */
/* General cleanup routine to close open files and release memory buffers.   */
/*****************************************************************************/
void cleanup(struct sqlma *ma_ptr)

{

   int                   rc = 0;

  if (output_opt == FILE_OUTPUT)
  {                                                     /* close output file */
    rc = fclose(outstream);
    if (rc != 0)
    {
      fprintf(outstream, "error closing output file at cleanup. rc= %d\n", rc);
    }
  }
  if (buffer_ptr != NULL)
     free(buffer_ptr);                                 /* free output buffer */

  if (ma_ptr != NULL)                                  /* free sqlma         */
     free(ma_ptr);


}  /* cleanup */

/*****************************************************************************/
/* pause.                                                                    */
/* Waits for user input before proceeding                                    */
/*****************************************************************************/
void pause()
{
   printf("\nEnter any key to continue!\n");
   fflush(stdin);
   getchar();
}  /* pause */

/*****************************************************************************/
/* clrscrn.                                                                  */
/* Clears the user's screen                                                  */
/*****************************************************************************/
void clrscrn()
{
   system(CLEARSCR);
}  /* clrscrn */
isecondk;   $        2  Q1Q1[U1         P5  2      ./usr/lpp/db2_02_01/samples/c/evmprint.c .3000/l                    $          //-----------------------------------------------------------------------------
//
// Source File Name = evmprint.c   %I%
//
// Licensed Materials - Property of IBM
//
// (C) COPYRIGHT International Business Machines Corp. 1995
// All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//
//------------------------------------------------------------------------------
// Event Monitor code sample - This file is included by 'evm.c'.
//
// evmprint.c - Prints all events generated by an Event Monitor
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>  /* To use cprint() function */
#include <time.h>

#include "sqlmon.h"
#include "sqlca.h"

//------------------------------------------------------------------------------
// Convert GMT time into local time, and format it into a printable string.
//------------------------------------------------------------------------------
char* time_STRING(const sqlm_timestamp timestamp, char *timeString) {

   // Event Monitor returns GMT time, adjust it to local time
   struct tm *pstTm;
   pstTm = localtime((signed long*) &timestamp.seconds);
   if (timestamp.seconds == 0)
      strcpy(timeString, "");
   else {
      if (timestamp.microsec < 0) {
         sprintf(timeString, "%02d-%02d-%04d %02d:%02d:%02d",
              pstTm->tm_mon + 1, pstTm->tm_mday, pstTm->tm_year + 1900,
              pstTm->tm_hour, pstTm->tm_min, pstTm->tm_sec);
      } else {
         sprintf(timeString, "%02d-%02d-%04d %02d:%02d:%02d.%06.6ld",
              pstTm->tm_mon + 1, pstTm->tm_mday, pstTm->tm_year + 1900,
              pstTm->tm_hour, pstTm->tm_min, pstTm->tm_sec, timestamp.microsec);
     } /* end else micro seconds are not null */
  } /* end if the timestamp is non-zero */
  return timeString;
} // end of time_STRING

//------------------------------------------------------------------------------
// Print a Blank Padded String of maximum length SZ
//------------------------------------------------------------------------------
// note: strings returned by DB2 are NOT NULL-TERMINATED, they are all
//       blank padded up to some maximum length.
//------------------------------------------------------------------------------
// For example, given:
//                   char   str[20] = "Contents of 1       ";
// the following invocation:
//                   fpBPSTR(stdout, " String 1", str, sizeof(str));
// will print:
//                   " String 1: Contents of 1"
//------------------------------------------------------------------------------
#define fpBPSTR(fp, txt, str, SZ) \
{ \
    char newstr[SZ]; \
    int k=0; \
    while (str[k]!=' '&&k<SZ) { newstr[k]=str[k]; k++;} \
    if (k<SZ) newstr[k]='\0'; \
    fprintf(fp, txt ": %0.*s\n", SZ, newstr); \
}
//------------------------------------------------------------------------------
char* byte_order_STRING(int val) {
   switch (val) {
   case SQLM_LITTLE_ENDIAN:      return "SQLM_LITTLE_ENDIAN";
   case SQLM_BIG_ENDIAN:         return "SQLM_BIG_ENDIAN";
   }
   return "";
} // end of byte_order_STRING
//------------------------------------------------------------------------------
char* table_type_STRING(int val) {
   switch(val) {
   case SQLM_USER_TABLE:         return "User";
   case SQLM_DROPPED_TABLE:      return "Dropped";
   case SQLM_TEMP_TABLE:         return "Temporary";
   case SQLM_CATALOG_TABLE:      return "Catalog";
   case SQLM_REORG_TABLE:        return "Reorg";
   }
   return "Unknown";
} // end of table_type_STRING
//------------------------------------------------------------------------------
char* lock_object_type_STRING(int val) {
   switch (val) {
   case SQLM_ROW_LOCK:        return "Row";
   case SQLM_TABLE_LOCK:      return "Table";
   case SQLM_INTERNAL_LOCK:   return "Internal";
   case SQLM_TABLESPACE_LOCK: return "Tablespace";
   }
   return "Unknown";
} // end of lock_object_type_STRING

//------------------------------------------------------------------------------
char* lock_mode_STRING(int val) {
   switch (val) {
   case SQLM_LNON: return "NO";
   case SQLM_LOIS: return "IS";
   case SQLM_LOIX: return "IX";
   case SQLM_LOOS: return "S";
   case SQLM_LSIX: return "SIX";
   case SQLM_LOOX: return "X";
   case SQLM_LOIN: return "IN";
   case SQLM_LOOZ: return "Z";
   case SQLM_LOOU: return "U";
   }
   return "Unknown";
} // end of lock_mode_STRING

//------------------------------------------------------------------------------
char* stmt_type_STRING(int val) {
   switch (val) {
   case SQLM_STATIC:            return "Static";
   case SQLM_DYNAMIC:           return "Dynamic";
   case SQLM_NON_STMT:          return "Non-SQL";
   case SQLM_STMT_TYPE_UNKNOWN: return "Unknown";
   }
   return "";
} // end of stmt_type_STRING
//------------------------------------------------------------------------------
char* operation_STRING(int val) {
   switch (val) {
   case SQLM_PREPARE:           return "Prepare";
   case SQLM_EXECUTE:           return "Execute";
   case SQLM_EXECUTE_IMMEDIATE: return "Execute Immediate";
   case SQLM_OPEN:              return "Open";
   case SQLM_FETCH:             return "Fetch";
   case SQLM_CLOSE:             return "Close";
   case SQLM_DESCRIBE:          return "Describe";
   case SQLM_STATIC_COMMIT:     return "Static Commit";
   case SQLM_STATIC_ROLLBACK:   return "Static Rollback";
   }
   return "Unknown";
} /* end of operation_STRING */

//------------------------------------------------------------------------------
// Printing routines
//------------------------------------------------------------------------------
void print_sqlm_event_log_header(FILE* fp,
                                 const sqlm_event_log_header *event_header){
   fprintf(fp, 
"--------------------------------------------------------------------------\n"
"                            EVENT LOG HEADER\n");
   fpBPSTR(fp, "  Event Monitor name",
                  event_header->event_monitor_name, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Server Product ID",
                  event_header->server_prdid, SQLM_IDENT_SZ);
   fprintf(fp, "  Version of event monitor data: %ld\n", event_header->version);
   fprintf(fp, "  Byte order: %s\n",
                  byte_order_STRING(event_header->byte_order));
   fprintf(fp, "  Size of record: %ld\n", event_header->size);
   fprintf(fp, "  Codepage of database: %d\n", event_header->codepage_id);
   fprintf(fp, "  Country code of database: %d\n", event_header->country_code);
   fpBPSTR(fp, "  Server instance name",
                  event_header->server_instance_name, SQLM_IDENT_SZ);
   fprintf(fp, 
"--------------------------------------------------------------------------\n");
   fflush(fp);
} /* end of print_sqlm_event_log_header */
//------------------------------------------------------------------------------
void print_sqlm_db_event(FILE* fp,
                         const sqlm_db_event* event_rec,
                         int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp,"\n\n%u) Database Event\n", record_no);

   fprintf(fp,"\n Lock Statistics:\n");
   fprintf(fp,"  Lock Waits:  %lu\n", event_rec->lock_waits);
   fprintf(fp,"  Total time waited on locks: %lu milliseconds\n",
                 event_rec->lock_wait_time);
   fprintf(fp,"  Deadlocks: %lu\n", event_rec->deadlocks);
   fprintf(fp,"  Lock escalations:  %lu\n", event_rec->lock_escals);
   fprintf(fp,"  X lock escalations:  %lu\n", event_rec->x_lock_escals);
   fprintf(fp,"  Lock timeouts:  %lu\n", event_rec->lock_timeouts);

   fprintf(fp,"\n Sort Statistics:\n");
   fprintf(fp,"  Sorts: %lu\n", event_rec->total_sorts);
   fprintf(fp,"  Total sort time: %lu milliseconds\n",
                 event_rec->total_sort_time);
   fprintf(fp,"  Sort overflows: %lu\n", event_rec->sort_overflows);

   fprintf(fp,"\n Buffer Pool Statistics:\n");
   fprintf(fp,"  Buffer pool logical data page reads: %lu\n",
                 event_rec->pool_data_l_reads);
   fprintf(fp,"  Buffer pool physical data page reads: %lu\n",
                 event_rec->pool_data_p_reads);
   fprintf(fp,"  Buffer pool data page writes: %lu\n",
                 event_rec->pool_data_writes);
   fprintf(fp,"  Buffer pool logical index page reads: %lu\n",
                 event_rec->pool_index_l_reads);
   fprintf(fp,"  Buffer pool physical index page reads: %lu\n",
                 event_rec->pool_index_p_reads);
   fprintf(fp,"  Buffer pool index page writes: %lu\n",
                 event_rec->pool_index_writes);
   fprintf(fp,"  Buffer pool read time: %lu milliseconds\n",
                 event_rec->pool_read_time);
   fprintf(fp,"  Buffer pool write time: %lu milliseconds\n",
                 event_rec->pool_write_time);
   fprintf(fp,"  Files closed: %lu\n",
                 event_rec->files_closed);
   fprintf(fp,"  Buffer pool asynch data page reads: %lu\n",
                 event_rec->pool_async_data_reads);
   fprintf(fp,"  Buffer pool asynch data page reads reqs: %lu\n",
                 event_rec->pool_async_data_read_reqs);
   fprintf(fp,"  Buffer pool asynch data page writes: %lu\n",
                 event_rec->pool_async_data_writes);
   fprintf(fp,"  Buffer pool asynch index page writes: %lu\n",
                 event_rec->pool_async_index_writes);
   fprintf(fp,"  Buffer pool asynch read time: %lu milliseconds\n",
                 event_rec->pool_async_read_time);
   fprintf(fp,"  Buffer pool asynch write time: %lu milliseconds\n",
                 event_rec->pool_async_write_time);
   fprintf(fp,"  Buffer pool LSN gap cleans: %lu\n",
                 event_rec->pool_lsn_gap_clns);
   fprintf(fp,"  Buffer pool dirty page steal cleans: %lu\n",
                 event_rec->pool_drty_pg_steal_clns);
   fprintf(fp,"  Buffer pool dirty page threshold cleans: %lu\n",
                 event_rec->pool_drty_pg_thrsh_clns);

   fprintf(fp,"\n Direct I/O Statistics:\n");
   fprintf(fp,"  Sectors read directly: %lu\n",
                 event_rec->direct_reads);
   fprintf(fp,"  Sectors written directly: %lu\n",
                 event_rec->direct_writes);
   fprintf(fp,"  Direct read requests: %lu\n",
                 event_rec->direct_read_reqs);
   fprintf(fp,"  Direct write requests: %lu\n",
                 event_rec->direct_write_reqs);
   fprintf(fp,"  Direct read time: %lu milliseconds\n",
                 event_rec->direct_read_time);
   fprintf(fp,"  Direct write time: %lu milliseconds\n",
                 event_rec->direct_write_time);

   fprintf(fp,"\n SQL Statement counts\n");
   fprintf(fp,"  Commit SQL statements: %lu\n", event_rec->commit_sql_stmts);
   fprintf(fp,"  Rollback SQL statements: %lu\n",
                 event_rec->rollback_sql_stmts);
   fprintf(fp,"  Dynamic SQL statements: %lu\n", event_rec->dynamic_sql_stmts);
   fprintf(fp,"  Static SQL statements: %lu\n", event_rec->static_sql_stmts);
   fprintf(fp,"  Failed SQL statements: %lu\n", event_rec->failed_sql_stmts);
   fprintf(fp,"  Select SQL statements: %lu\n", event_rec->select_sql_stmts);
   fprintf(fp,"  Data Definition Language SQL statements: %lu\n",
                 event_rec->ddl_sql_stmts);
   fprintf(fp,"  Update/Insert/Delete SQL statements  : %lu\n",
                 event_rec->uid_sql_stmts);

   fprintf(fp,"\n Internal counts\n");
   fprintf(fp,"  auto rebinds: %lu\n", event_rec->int_auto_rebinds);
   fprintf(fp,"  Internal rows deleted: %lu\n", event_rec->int_rows_deleted);
   fprintf(fp,"  Internal rows updated: %lu\n", event_rec->int_rows_updated);
   fprintf(fp,"  Internal rows inserted: %lu\n", event_rec->int_rows_inserted);
   fprintf(fp,"  Internal commits: %lu\n", event_rec->int_commits);
   fprintf(fp,"  Internal rollbacks: %lu\n", event_rec->int_rollbacks);

   fprintf(fp,"\n Row counts\n");
   fprintf(fp,"  Rows deleted: %lu\n", event_rec->rows_deleted);
   fprintf(fp,"  Rows inserted: %lu\n", event_rec->rows_inserted);
   fprintf(fp,"  Rows updated: %lu\n", event_rec->rows_updated);
   fprintf(fp,"  Rows selected: %lu\n", event_rec->rows_selected);

   fprintf(fp,"\n  Binds/Precompiles: %lu\n", event_rec->binds_precompiles);

   fprintf(fp,"\n Connection Statistics\n");
   fprintf(fp,"  Connections since 1st connect: %lu\n",
                 event_rec->total_cons);
   fprintf(fp,"  Maximum number of connections: %lu\n",
                 event_rec->connections_top);

   fprintf(fp,"\n Heap Statistics\n");
   fprintf(fp,"  Maximum amount of database heap used: %lu\n",
                 event_rec->db_heap_top);

   fprintf(fp,"\n Logging Statistics\n");
   fprintf(fp,"  Maximum Secondary Log space used: %lu\n",
          event_rec->sec_log_used_top);
   fprintf(fp,"  Maximum Total Log space used: %lu\n",
          event_rec->tot_log_used_top);
   fprintf(fp,"  Log pages read: %lu\n", event_rec->log_reads);
   fprintf(fp,"  Log pages written: %lu\n", event_rec->log_writes);

   fprintf(fp,"\n Package Cache Statistics\n");
   fprintf(fp,"  Package Cache Lookups: %lu\n", event_rec->pkg_cache_lookups);
   fprintf(fp,"  Package Cache Inserts: %lu\n", event_rec->pkg_cache_inserts);

   fprintf(fp,"\n Catalog Cache Statistics\n");
   fprintf(fp,"  Catalog Cache Lookups: %lu\n", event_rec->cat_cache_lookups);
   fprintf(fp,"  Catalog Cache Inserts: %lu\n", event_rec->cat_cache_inserts);
   fprintf(fp,"  Catalog Cache Overflows: %lu\n",
                 event_rec->cat_cache_overflows);
   fprintf(fp,"  Catalog Cache Heap Full: %lu\n",
                 event_rec->cat_cache_heap_full);

   fprintf(fp,"\n Last Disconnection Time: %s\n",
           time_STRING(event_rec->disconn_time, timestamp));
} /* end of print_sqlm_db_event */

//------------------------------------------------------------------------------
void print_sqlm_conn_event(FILE* fp,
                           const sqlm_conn_event *event_rec,
                           int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp, "\n\n%u) Connection Event\n", record_no);
   fpBPSTR(fp, "  Application Id: ", event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number",  event_rec->sequence_no, SQLM_SEQ_SZ);

   fprintf(fp, "\n Lock Statistics:\n");
   fprintf(fp, "  Lock Waits: %lu\n", event_rec->lock_waits);
   fprintf(fp, "  Total time waited on locks: %lu milliseconds\n",
          event_rec->lock_wait_time);
   fprintf(fp, "  Deadlocks: %lu\n", event_rec->deadlocks);
   fprintf(fp, "  Lock escalations: %lu\n", event_rec->lock_escals);
   fprintf(fp, "  X lock escalations: %lu\n", event_rec->x_lock_escals);
   fprintf(fp, "  Lock timeouts: %lu\n", event_rec->lock_timeouts);

   fprintf(fp, "\n Sort Statistics:\n");
   fprintf(fp, "  Sorts: %lu\n", event_rec->total_sorts);
   fprintf(fp, "  Total sort time: %lu milliseconds\n",
          event_rec->total_sort_time);
   fprintf(fp, "  Sort overflows: %lu\n", event_rec->sort_overflows);

   fprintf(fp, "\n Buffer Pool Statistics:\n");
   fprintf(fp, "  Buffer pool logical data page reads: %lu\n",
          event_rec->pool_data_l_reads);
   fprintf(fp, "  Buffer pool physical data page reads: %lu\n",
          event_rec->pool_data_p_reads);
   fprintf(fp, "  Buffer pool data page writes: %lu\n",
          event_rec->pool_data_writes);
   fprintf(fp, "  Buffer pool logical index page reads: %lu\n",
          event_rec->pool_index_l_reads);
   fprintf(fp, "  Buffer pool physical index page reads: %lu\n",
          event_rec->pool_index_p_reads);
   fprintf(fp, "  Buffer pool index page writes: %lu\n",
          event_rec->pool_index_writes);
   fprintf(fp, "  Buffer pool read time: %lu milliseconds\n",
          event_rec->pool_read_time);
   fprintf(fp, "  Buffer pool write time: %lu milliseconds\n",
          event_rec->pool_write_time);

   fprintf(fp, "\n Direct I/O Statistics:\n");
   fprintf(fp, "  Sectors read directly: %lu\n", event_rec->direct_reads);
   fprintf(fp, "  Sectors written directly: %lu\n", event_rec->direct_writes);
   fprintf(fp, "  Direct read requests: %lu\n", event_rec->direct_read_reqs);
   fprintf(fp, "  Direct write requests: %lu\n", event_rec->direct_write_reqs);
   fprintf(fp, "  Direct read time: %lu milliseconds\n",
          event_rec->direct_read_time);
   fprintf(fp, "  Direct write time: %lu milliseconds\n",
          event_rec->direct_write_time);

   fprintf(fp, "\n SQL Statement counts\n");
   fprintf(fp, "  Commit SQL statements: %lu\n", event_rec->commit_sql_stmts);
   fprintf(fp, "  Rollback SQL statements: %lu\n",
          event_rec->rollback_sql_stmts);
   fprintf(fp, "  Dynamic SQL statements: %lu\n", event_rec->dynamic_sql_stmts);
   fprintf(fp, "  Static SQL statements: %lu\n", event_rec->static_sql_stmts);
   fprintf(fp, "  Failed SQL statements: %lu\n", event_rec->failed_sql_stmts);
   fprintf(fp, "  Select SQL statements: %lu\n", event_rec->select_sql_stmts);
   fprintf(fp, "  Data Definition Language SQL statements: %lu\n",
          event_rec->ddl_sql_stmts);
   fprintf(fp, "  Update/Insert/Delete SQL statements: %lu\n",
          event_rec->uid_sql_stmts);

   fprintf(fp, "\n Internal counts\n");
   fprintf(fp, "  auto rebinds: %lu\n", event_rec->int_auto_rebinds);
   fprintf(fp, "  Internal rows deleted: %lu\n", event_rec->int_rows_deleted);
   fprintf(fp, "  Internal rows updated: %lu\n", event_rec->int_rows_updated);
   fprintf(fp, "  Internal rows inserted: %lu\n", event_rec->int_rows_inserted);
   fprintf(fp, "  Internal commits: %lu\n", event_rec->int_commits);
   fprintf(fp, "  Internal rollbacks: %lu\n", event_rec->int_rollbacks);
   fprintf(fp, "  Internal rollbacks du to deadlock: %lu\n",
          event_rec->int_deadlock_rollbacks);

   fprintf(fp, "\n Row counts\n");
   fprintf(fp, "  Rows deleted: %lu\n", event_rec->rows_deleted);
   fprintf(fp, "  Rows inserted: %lu\n", event_rec->rows_inserted);
   fprintf(fp, "  Rows updated: %lu\n", event_rec->rows_updated);
   fprintf(fp, "  Rows selected: %lu\n", event_rec->rows_selected);
   fprintf(fp, "  Rows read: %lu\n", event_rec->rows_read);
   fprintf(fp, "  Rows written: %lu\n", event_rec->rows_written);

   fprintf(fp, "\n  Binds/Precompiles: %lu\n", event_rec->binds_precompiles);

   fprintf(fp, "\n Cursor Information:\n");
   fprintf(fp, "  Rejected block cursor requests: %lu\n",
          event_rec->rej_curs_blk);
   fprintf(fp, "  Accepted block cursor requests: %lu\n",
          event_rec->acc_curs_blk);

   fprintf(fp, "\n Package Cache Statistics\n");
   fprintf(fp, "  Package Cache Lookups: %lu\n", event_rec->pkg_cache_lookups);
   fprintf(fp, "  Package Cache Inserts: %lu\n", event_rec->pkg_cache_inserts);

   fprintf(fp, "\n Catalog Cache Statistics\n");
   fprintf(fp, "  Catalog Cache Overflows: %lu\n",
          event_rec->cat_cache_overflows);
   fprintf(fp, "  Catalog Cache Heap Full: %lu\n",
          event_rec->cat_cache_heap_full);

   fprintf(fp, "\n CPU times\n");
   fprintf(fp, "  User CPU time used: %lu.%0.6lu seconds\n",
          event_rec->user_cpu_time.seconds,
          event_rec->user_cpu_time.microsec);
   fprintf(fp, "  System CPU time used: %lu.%0.6lu seconds\n",
          event_rec->system_cpu_time.seconds,
          event_rec->system_cpu_time.microsec);

   fprintf(fp, "\n Disconnection Time: %s\n",
           time_STRING(event_rec->disconn_time, timestamp));
} /* end of print_sqlm_conn_event */

//------------------------------------------------------------------------------
void print_sqlm_table_event(FILE* fp,
                            const sqlm_table_event *event_rec,
                            int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp, "\n\n%u) Table Event ...\n", record_no);
   fpBPSTR(fp, "  Table schema", event_rec->table_schema, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Table name", event_rec->table_name, SQLM_IDENT_SZ);
   fprintf(fp, "  Table type: %s\n", table_type_STRING(event_rec->table_type));
   fprintf(fp, "  Rows read: %lu\n", event_rec->rows_read);
   fprintf(fp, "  Rows written: %lu\n", event_rec->rows_written);
   fprintf(fp, "  Overflow records accessed: %lu\n",
          event_rec->overflow_accesses);
   fprintf(fp, "  Table event timestamp: %s\n",
           time_STRING(event_rec->table_event_time, timestamp));
} /* end of print_sqlm_table_event */

//------------------------------------------------------------------------------
void print_sqlm_stmt_event(FILE* fp,
                           const sqlm_stmt_event *event_rec,
                           int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */

   fprintf(fp, "\n\n%u) Statement Event ...\n", record_no);
   fpBPSTR(fp, "  Application Id", event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number", event_rec->sequence_no, SQLM_SEQ_SZ);
   fprintf(fp, "\n Statement Identification:\n");
   fprintf(fp, "  Statement Type: %s\n",stmt_type_STRING(event_rec->stmt_type));
   fprintf(fp, "  Operation: %s\n", operation_STRING(event_rec->operation));
   fprintf(fp, "  Section number: %lu\n", event_rec->section_number);
   fpBPSTR(fp, "  Application creator",event_rec->creator, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Package name", event_rec->package_name, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Cursor Name", event_rec->cursor_name, SQLM_IDENT_SZ);

   fprintf(fp, "\n Timestamps\n");
   fprintf(fp, "  Start Time: %s\n",
           time_STRING(event_rec->start_time, timestamp));
   fprintf(fp, "  Stop Time: %s\n",
           time_STRING(event_rec->stop_time, timestamp));

   fprintf(fp, "\n CPU times\n");
   fprintf(fp, "  User CPU time: %lu.%0.6lu seconds\n",
          event_rec->user_cpu_time.seconds,
          event_rec->user_cpu_time.microsec);
   fprintf(fp, "  System CPU time: %lu.%0.6lu seconds\n",
          event_rec->system_cpu_time.seconds,
          event_rec->system_cpu_time.microsec);

   fprintf(fp, "\n Statement Activity\n");
   fprintf(fp, "  Fetch Count: %lu\n", event_rec->fetch_count);
   fprintf(fp, "  Sorts: %lu\n", event_rec->total_sorts);
   fprintf(fp, "  Total sort time: %lu\n", event_rec->total_sort_time);
   fprintf(fp, "  Sort overflows: %lu\n", event_rec->sort_overflows);
   fprintf(fp, "  Rows read: %lu\n", event_rec->rows_read);
   fprintf(fp, "  Rows written: %lu\n", event_rec->rows_written);
   fprintf(fp, "  Internal rows deleted: %lu\n", event_rec->int_rows_deleted);
   fprintf(fp, "  Internal rows updated: %lu\n", event_rec->int_rows_updated);
   fprintf(fp, "  Internal rows inserted: %lu\n", event_rec->int_rows_inserted);

   fprintf(fp, " \n SQLCA ...\n");
   fprintf(fp, "  sqlcode: %ld\n", event_rec->sqlca.sqlcode);
   fprintf(fp, "  sqlstate: %5.5s\n", event_rec->sqlca.sqlstate);
   if (event_rec->sqlca.sqlcode != 0) {
      // get and display a printable error message
      char msg[1024];
      struct sqlca sqlca = event_rec->sqlca; // Make a copy because rec is const
      sqlaintp (msg, sizeof(msg), 60, &sqlca);
      printf("%s", msg);
   }
} /* end of print_sqlm_stmt_event */

//------------------------------------------------------------------------------
void print_sqlm_stmttext_event(FILE* fp,
                               const sqlm_stmttext_event *event_rec,
                               int record_no) {
   fprintf(fp, "\n\n%u) Dynamic Statement Text ...\n", record_no);

   fpBPSTR(fp, "  Application Id",  event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number", event_rec->sequence_no, SQLM_SEQ_SZ);
   fprintf(fp, "  Section number: %lu\n", event_rec->section_number);
   fpBPSTR(fp, "  Application creator", event_rec->creator, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Package name", event_rec->package_name, SQLM_IDENT_SZ);

   fprintf(fp, "\n  Statement Text: %.*s\n",
          event_rec->stmt_length, event_rec->stmt_text);
} /* end of print_sqlm_stmttext_event */

//------------------------------------------------------------------------------
void print_sqlm_xaction_event(FILE* fp,
                     const sqlm_xaction_event *event_rec,
                     int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp, "\n\n%u) Transaction Event ...\n", record_no++);

   fpBPSTR(fp, "  Application Id", event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number",  event_rec->sequence_no, SQLM_SEQ_SZ);

   switch (event_rec->status)
   {
      case SQLM_UOWCOMMIT:
         fprintf(fp, "  Completion Status: Committed\n");
         break;
      case SQLM_UOWROLLBACK:
         fprintf(fp, "  Completion Status: "
                "Rolled back\n");
         break;
      case SQLM_UOWDEADLOCK:
         fprintf(fp, "  Completion Status: "
                "Rolled back from deadlock\n");
         break;
      case SQLM_UOWABEND:
         fprintf(fp, "  Completion Status: "
                "Rolled back due to abend\n");
         break;
      case SQLM_APPL_END:
         fprintf(fp, "  Completion Status: "
                "Committed at application end\n");
         break;
      case SQLM_UOWLOCKTIMEOUT:
         fprintf(fp, "  Completion Status: "
                "Rolled back from lock timeout\n");
         break;
      default:
         fprintf(fp, "  Completion Status: "
                "Unknown (%lu)\n", event_rec->status);
         break;
   } /* end switch on status */

   fprintf(fp, "\n Transaction Activity\n");
   fprintf(fp, "  Lock wait time: %lu milliseconds\n",
          event_rec->lock_wait_time);
   fprintf(fp, "  Maximum number of locks held: %lu\n",
          event_rec->locks_held_top);
   fprintf(fp, "  Lock escalations: %lu\n",
          event_rec->lock_escals);
   fprintf(fp, "  X lock escalations: %lu\n",
          event_rec->x_lock_escals);
   fprintf(fp, "  Rows read: %lu\n",
          event_rec->rows_read);
   fprintf(fp, "  Rows written: %lu\n",
          event_rec->rows_written);
   fprintf(fp, "  Log space used: %lu\n",
          event_rec->log_space_used);

   fprintf(fp, "\n Timestamps\n");
   fprintf(fp, "  Previous transaction stop time: %s\n",
           time_STRING(event_rec->prev_stop_time, timestamp));
   fprintf(fp, "  Start time: %s\n",
           time_STRING(event_rec->start_time, timestamp));
   fprintf(fp, "  Stop time: %s\n",
           time_STRING(event_rec->stop_time, timestamp));

   fprintf(fp, "\n CPU times\n");
   fprintf(fp, "  User CPU time: %lu.%0.6lu seconds\n",
          event_rec->user_cpu_time.seconds,
          event_rec->user_cpu_time.microsec);
   fprintf(fp, "  System CPU time: %lu.%0.6lu seconds\n",
          event_rec->system_cpu_time.seconds,
          event_rec->system_cpu_time.microsec);
} /* end of print_sqlm_xaction_event */

//------------------------------------------------------------------------------
void print_sqlm_deadlock_event(FILE* fp,
                      const sqlm_deadlock_event *event_rec,
                      int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp, "\n\n%u) Deadlock Event ...\n", record_no);
   fprintf(fp, "  Number of applications deadlocked: %lu\n",
          event_rec->dl_conns);
   fprintf(fp, "  Deadlock detection time: %s\n",
           time_STRING(event_rec->start_time, timestamp));
} /* end of print_sqlm_deadlock_event */

//------------------------------------------------------------------------------
void print_sqlm_dlconn_event(FILE* fp, const sqlm_dlconn_event *event_rec,
                    int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */
   fprintf(fp, "\n\n%u) Deadlocked Connection Event ...\n", record_no);
   fpBPSTR(fp, "  Application Id",  event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number",  event_rec->sequence_no, SQLM_SEQ_SZ);
   fpBPSTR(fp, "  Appl_id of connection holding the lock",
                  event_rec->appl_id_holding_lk, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Seq. no. of connection holding the lock",
                  event_rec->sequence_no_holding_lk, SQLM_SEQ_SZ);

   fprintf(fp, "\n Waited on Lock\n");
   fpBPSTR(fp, "  Table Name of lock waited on",
                  event_rec->table_name, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Table Schema of lock waited on",
                  event_rec->table_schema, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Tablespace Name of lock waited on",
                  event_rec->tablespace_name, SQLM_IDENT_SZ);

   fprintf(fp, "  Type of lock: %s\n",
           lock_object_type_STRING(event_rec->lock_object_type));
   fprintf(fp, "  Mode of lock: %s\n", lock_mode_STRING(event_rec->lock_mode));

   fprintf(fp, "  Lock object name: %lu", event_rec->lock_object_name);

   fprintf(fp, "\n Timestamps\n");

   fprintf(fp, "  Lock wait start time: %s\n",
           time_STRING(event_rec->lock_wait_start_time, timestamp));

   fprintf(fp, "  Deadlock detection time: %s\n",
           time_STRING(event_rec->start_time, timestamp));
} /* end of print_sqlm_dlconn_event */

//------------------------------------------------------------------------------
void print_sqlm_tablespace_event(FILE* fp,
                const sqlm_tablespace_event *event_rec,
                int record_no) {
   char timestamp[30];                   /* buffer to hold timestamp string */

   fprintf(fp, "\n\n%u) Tablespace Event ...\n", record_no);
   fpBPSTR(fp, "  Tablespace Name",  event_rec->tablespace_name, SQLM_IDENT_SZ);

   fprintf(fp, "\n Buffer Pool Statistics:\n");
   fprintf(fp, "  Buffer pool logical data page reads: %lu\n",
          event_rec->pool_data_l_reads);
   fprintf(fp, "  Buffer pool physical data page reads: %lu\n",
          event_rec->pool_data_p_reads);
   fprintf(fp, "  Buffer pool data page writes: %lu\n",
          event_rec->pool_data_writes);
   fprintf(fp, "  Buffer pool logical index page reads: %lu\n",
          event_rec->pool_index_l_reads);
   fprintf(fp, "  Buffer pool physical index page reads: %lu\n",
          event_rec->pool_index_p_reads);
   fprintf(fp, "  Buffer pool index page writes: %lu\n",
          event_rec->pool_index_writes);
   fprintf(fp, "  Buffer pool read time: %lu milliseconds\n",
          event_rec->pool_read_time);
   fprintf(fp, "  Buffer pool write time: %lu milliseconds\n",
          event_rec->pool_write_time);
   fprintf(fp, "  Files closed: %lu\n",
          event_rec->files_closed);
   fprintf(fp, "  Buffer pool asynch data page reads: %lu\n",
          event_rec->pool_async_data_reads);
   fprintf(fp, "  Buffer pool asynch data page reads reqs: %lu\n",
          event_rec->pool_async_data_read_reqs);
   fprintf(fp, "  Buffer pool asynch data page writes: %lu\n",
          event_rec->pool_async_data_writes);
   fprintf(fp, "  Buffer pool asynch index page writes: %lu\n",
          event_rec->pool_async_index_writes);
   fprintf(fp, "  Buffer pool asynch read time: %lu milliseconds\n",
          event_rec->pool_async_read_time);
   fprintf(fp, "  Buffer pool asynch write time: %lu milliseconds\n",
          event_rec->pool_async_write_time);

   fprintf(fp, "\n Direct I/O Statistics:\n");
   fprintf(fp, "  Sectors read directly: %lu\n",
          event_rec->direct_reads);
   fprintf(fp, "  Sectors written directly: %lu\n",
          event_rec->direct_writes);
   fprintf(fp, "  Direct read requests: %lu\n",
          event_rec->direct_read_reqs);
   fprintf(fp, "  Direct write requests: %lu\n",
          event_rec->direct_write_reqs);
   fprintf(fp, "  Direct read time: %lu milliseconds\n",
          event_rec->direct_read_time);
   fprintf(fp, "  Direct write time: %lu milliseconds\n",
          event_rec->direct_write_time);


   fprintf(fp, "\n  Tablespace event timestamp: %s\n",
           time_STRING(event_rec->ts_event_time, timestamp));
} /* end of print_sqlm_tablespace_event */

//------------------------------------------------------------------------------
void print_sqlm_dbheader_event(FILE* fp,
                               const sqlm_dbheader_event *event_rec,
                               int record_no) {
   char     timestamp[30];        /* buffer to format timestamp strings */

   fprintf(fp, "\n\n%u) Database Header Event ...\n", record_no);
   fpBPSTR(fp, "  Database Name", event_rec->db_name, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Database Path", event_rec->db_path, SQLM_DBPATH_SZ);
   fprintf(fp, "  First connection timestamp: %s\n",
           time_STRING(event_rec->conn_time, timestamp));
} /* end of print_sqlm_dbheader_event */

//------------------------------------------------------------------------------
void print_sqlm_connheader_event(FILE* fp,
                                 const sqlm_connheader_event *event_rec,
                                 int record_no) {

   char     timestamp[30];        /* buffer to format timestamp strings */

   fprintf(fp, "\n\n%u) Connection Header Event ...\n", record_no);

   fpBPSTR(fp, "  Application Id",  event_rec->appl_id, SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Sequence number",  event_rec->sequence_no, SQLM_SEQ_SZ);
   fpBPSTR(fp, "  DRDA AS Correlation Token",  event_rec->corr_token,
                  SQLM_APPLID_SZ);
   fpBPSTR(fp, "  Authorization Id",  event_rec->auth_id, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Execution Id",  event_rec->execution_id, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Application Program Name",  event_rec->appl_name,
                  SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Client NNAME",  event_rec->client_nname, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Client product Id",  event_rec->client_prdid, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Client Database Alias",  event_rec->client_db_alias,
                  SQLM_IDENT_SZ);
   fprintf(fp, "  Client Process Id: %lu\n",
          event_rec->client_pid);
   fprintf(fp, "  Agent Id: %lu\n",
          event_rec->agent_id);

   fprintf(fp, "  Application codepage id: %u\n",
          event_rec->codepage_id);
   fprintf(fp, "  Application country code: %u\n",
          event_rec->country_code);

   switch (event_rec->client_platform)
   {
      case SQLM_PLATFORM_OS2:
         fprintf(fp, "  Application client platform: OS/2\n");
         break;
      case SQLM_PLATFORM_DOS:
         fprintf(fp, "  Application client platform: DOS\n");
         break;
      case SQLM_PLATFORM_WINDOWS:
         fprintf(fp, "  Application client platform: WINDOWS\n");
         break;
      case SQLM_PLATFORM_AIX:
         fprintf(fp, "  Application client platform: AIX\n");
         break;
      case SQLM_PLATFORM_HP:
         fprintf(fp, "  Application client platform: HP\n");
         break;
      case SQLM_PLATFORM_SUN:
         fprintf(fp, "  Application client platform: SUN\n");
         break;
      case SQLM_PLATFORM_SNI:                                    /*@db41773ygs*/
         fprintf(fp, "  Application client platform: SINIX\n");
         break;
      case SQLM_PLATFORM_MAC:
         fprintf(fp, "  Application client platform: MacIntosh");
         break;
      case SQLM_PLATFORM_WINDOWS95:
         fprintf(fp, "  Application client platform: Windows95");
         break;
      case SQLM_PLATFORM_VSE_DRDA:
         fprintf(fp, "  Application client platform: VSE via DRDA");
         break;                                                  /*@de41773ygs*/
      case SQLM_PLATFORM_MVS_DRDA:
         fprintf(fp, "  Application client platform: MVS via DRDA\n");
         break;
      case SQLM_PLATFORM_AS400_DRDA:
         fprintf(fp, "  Application client platform: AS400 via DRDA\n");
         break;
      case SQLM_PLATFORM_VM_DRDA:
         fprintf(fp, "  Application client platform: VM via DRDA\n");
         break;
      case SQLM_PLATFORM_UNKNOWN_DRDA:
         fprintf(fp, "  Application client platform: Unknown via DRDA\n");
         break;
      case SQLM_PLATFORM_UNKNOWN:
         fprintf(fp, "  Application client platform: Unknown\n");
         break;
      default:
         fprintf(fp, "  Application client platform: Unknown (%lu)\n", event_rec->client_platform);
         break;
   } /* endswitch */

   switch (event_rec->client_protocol)
   {
      case SQLM_PROT_APPC:
         fprintf(fp, "  Application client comms protocol: APPC\n");
         break;
      case SQLM_PROT_NETBIOS:
         fprintf(fp, "  Application client comms protocol: Netbios\n");
         break;
      case SQLM_PROT_APPN:
         fprintf(fp, "  Application client comms protocol: APPN\n");
         break;
      case SQLM_PROT_TCPIP:
         fprintf(fp, "  Application client comms protocol: TCPIP\n");
         break;
      case SQLM_PROT_CPIC:
         fprintf(fp, "  Application client comms protocol: CPIC\n");
         break;
      case SQLM_PROT_IPXSPX:
         fprintf(fp, "  Application client comms protocol: IPX/SPX\n");
         break;
      case SQLM_PROT_LOCAL:
         fprintf(fp, "  Application client comms protocol: Local\n");
         break;
      case SQLM_PROT_NPIPE:
         fprintf(fp, "  Application client comms protocol: Named Pipe\n");
         break;
      default:
         fprintf(fp, "  Application client comms protocol: Unknown (%lu)\n", event_rec->client_protocol);
         break;
   } /* endswitch */

   fprintf(fp, "  Connection timestamp: %s\n",
           time_STRING(event_rec->conn_time, timestamp));
} /* end of print_sqlm_connheader_event */

//------------------------------------------------------------------------------
void print_sqlm_overflow_event(FILE* fp,
                               const sqlm_overflow_event *event_rec,
                               int record_no) {

   char     timestamp[30];        /* buffer to format timestamp strings */

   fprintf(fp, "\n\n%u) Overflow Event ...\n", record_no);
   fprintf(fp, "  First Overflow time: %s\n",
           time_STRING(event_rec->first_overflow_time, timestamp));

   fprintf(fp, "  Last Overflow time: %s\n",
           time_STRING(event_rec->last_overflow_time, timestamp));

   fprintf(fp, "  Number of overflows: %lu\n",
          event_rec->count);
} /* end of print_sqlm_overflow_event */

//------------------------------------------------------------------------------
void print_sqlm_evmon_start_event(FILE* fp,
                                  const sqlm_evmon_start_event *event_rec,
                                  int record_no) {

   char     timestamp[30];        /* buffer to format timestamp strings */

   fprintf(fp, "\n\n%u) Event Monitor Start Event ...\n", record_no);
   fprintf(fp, "  Start time: %s\n",
           time_STRING(event_rec->start_time, timestamp));
} /* end of print_sqlm_evmon_start_event */

//------------------------------------------------------------------------------
void print_unknown_event(FILE* fp, const char *event_rec, int record_no) {
   unsigned long size;
   int           j;

   sqlm_event_rec_header* header = (sqlm_event_rec_header*) event_rec;
   fprintf(fp, "\n\n%u) Unknown Event ...\n", record_no);

   fprintf(fp, " Size of record (dec)  =  %u bytes\n", header->size);
   fprintf(fp, " Type of record (dec)  =  %u\n", header->type);

   /* The remaining bytes in the structure are the event data */
   size = header->size - sizeof(sqlm_event_rec_header);
   event_rec += sizeof(sqlm_event_rec_header);

   fprintf(fp, " Event data dump (hex and ascii) follows: \n");
   for (j = 0; j < size; j += 16)
   {
      int i;
      for (i = 0; i < 16 && i + j < size; ++i)
         fprintf(fp, "%02X ", *(event_rec + j + i));

      while (i < 16)    /* If all 16 bytes were not printed, pad with blanks */
      {
         fprintf(fp, "   ");
         ++i;
      }

      for (i = 0; i < 16 && i + j < size; ++i)
      {
         if (isprint(*(event_rec + j + i)))
           fprintf(fp, "%c ", *(event_rec + j + i));
         else
           fprintf(fp, ". ");
      }

      fprintf(fp, "\n");
   }
} /* end of print_unknown_event */

//------------------------------------------------------------------------------
// Print an event record
//------------------------------------------------------------------------------
void print_event_record(FILE* fp, int event_type, char* rec, int rec_no) {
   switch (event_type) {
   case SQLM_EVENT_DB:
      print_sqlm_db_event(fp, (const sqlm_db_event*) rec, rec_no);
      break;
   case SQLM_EVENT_CONN:
      print_sqlm_conn_event(fp, (sqlm_conn_event*) rec, rec_no);
      break;
   case SQLM_EVENT_TABLE:
      print_sqlm_table_event(fp, (sqlm_table_event*) rec, rec_no);
      break;
   case SQLM_EVENT_STMT:
      print_sqlm_stmt_event(fp, (sqlm_stmt_event*) rec, rec_no);
      break;
   case SQLM_EVENT_STMTTEXT:
      print_sqlm_stmttext_event(fp, (sqlm_stmttext_event*) rec, rec_no);
      break;
   case SQLM_EVENT_XACT:
      print_sqlm_xaction_event(fp, (sqlm_xaction_event*) rec, rec_no);
      break;
   case SQLM_EVENT_DEADLOCK:
      print_sqlm_deadlock_event(fp, (sqlm_deadlock_event*) rec, rec_no);
      break;
   case SQLM_EVENT_DLCONN:
      print_sqlm_dlconn_event(fp, (sqlm_dlconn_event*) rec, rec_no);
      break;
   case SQLM_EVENT_TABLESPACE:
      print_sqlm_tablespace_event(fp, (sqlm_tablespace_event*) rec, rec_no);
      break;
   case SQLM_EVENT_DBHEADER:
      print_sqlm_dbheader_event(fp, (sqlm_dbheader_event*) rec, rec_no);
      break;
   case SQLM_EVENT_CONNHEADER:
      print_sqlm_connheader_event(fp, (sqlm_connheader_event*) rec, rec_no);
      break;
   case SQLM_EVENT_OVERFLOW:
      print_sqlm_overflow_event(fp, (sqlm_overflow_event*) rec, rec_no);
      break;
   case SQLM_EVENT_START:
      print_sqlm_evmon_start_event(fp,(sqlm_evmon_start_event*) rec, rec_no);
      break;
   default:
      print_unknown_event(fp, rec, rec_no);
      break;
   } /* end switch on event type */
   fflush (fp);
} /* end of print_event_record */

rintf(k
 ion. This information is       */
/* contained in sqlm_tablespace_header and sqlm_tablespace data structures.  */
/* First, an sqlm_tablespace_header structure with information on the        */
/* database, and the number of sqlm_tablespace structures returned.          */
/*****************************************************************************/

void process_tablespace()
{

   long                   ltime;
   unsigned int           i, j;              /* counters                      */
   sqlm_tablespace_header   *ts_header_ptr;  /* local ptr to tablespace header*/
   sqlm_tablespace          *ts_ptr;         /* local ptr to tablespace info  */

   if (output_opt == SCREEN_OUTPUT)
      clrscrn();

   fprintf(outstream, "**********************************************************************\n");
   fprintf(outstream, "*                        TABLESPACE INFORMATION                      *\n");
   fprintf(outstream, "**********************************************************************\n");

   /* cast the buffer contents to an sqlm_tablespace_header data structure */
   ts_header_ptr = (sqlm_tablespace_header *)(buffer_index);

   fprintf(outstream, "\nDatabase Information:");
   fprintf(outstream, "\n  Number of tablespaces collected         ===> %lu", ts_header_ptr->num_tablespaces);
   ltime = ts_header_ptr->db_conn_time.seconds;
   fprintf(outstream, "\n  First database connect time             ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");
   ltime = ts_header_ptr->last_reset.seconds;
   fprintf(outstream, "\n  Last reset time                         ===> %24.24s",
                                    (ltime) ? ctime(&ltime) : "");

   fprintf(outstream, "\n  Input Database Alias                    ===> %0.*s", SQLM_IDENT_SZ, ts_header_ptr->input_db_alias);
   fprintf(outstream, "\n  Database Name                           ===> %0.*s", SQLM_IDENT_SZ, ts_header_ptr->db_name);
   fprintf(outstream, "\n  Database path (truncated to 70 chars)\n     ===> %0.70s", ts_header_ptr->db_path);

   /* advance buffer_index to the next structure in the buffer */
   buffer_index += ts_header_ptr->size;

   if (output_opt == SCREEN_OUTPUT)
      pause();

   /*******************************************************************************/
   /* Loop until all sqlm_tablespace structures are processed                     */
   /*******************************************************************************/

   for (i = 0; i < ts_header_ptr->num_tablespaces; i++)
   {
      /* cast the buffer contents to an sqlm_tablespace data structure */
      ts_ptr = (struct sqlm_tablespace *)(buffer_index);

      if (ts_ptr->info_type != SQLM_TABLESPACE_SS)
      {
         printf("\n\n***************************************************************\n");
         printf("*    ERROR processing output buffer from snapshot monitor.    *\n");
         printf("*    Expecting sqlm_tablespace structure. First chars: %10c*\n",(unsigned char)*buffer_index);
         printf("*    buffer offset where error occured: %10u             *\n",(unsigned long)(buffer_index - buffer_ptr));
         printf("*    Exiting ssdriver.                                        *\n\n");
         printf("\n***************************************************************\n");
         cleanup(NULL);
         exit(99);
      }

      fprintf(outstream, "\n\nTablespace Information:");
      fprintf(outstream, "\n  Tablespace Name                         ===> %0.*s", SQLM_IDENT_SZ, ts_ptr->tablespace_name);

      fprintf(outstream, "\n\nBuffer Pool Information:");
      fprintf(outstream, "\n  Buffer pool logical data page reads     ===> %lu", ts_ptr->pool_data_l_reads);
      fprintf(outstream, "\n  Buffer pool physical data page reads    ===> %lu", ts_ptr->pool_data_p_reads);
      fprintf(outstream, "\n  Buffer pool data page writes            ===> %lu", ts_ptr->pool_data_writes);
      fprintf(outstream, "\n  Buffer pool logical index page reads    ===> %lu", ts_ptr->pool_index_l_reads);
      fprintf(outstream, "\n  Buffer pool physical index page reads   ===> %lu", ts_ptr->pool_index_p_reads);
      fprintf(outstream, "\n  Buffer pool index page writes           ===> %lu", ts_ptr->pool_index_writes);
      fprintf(outstream, "\n  Buffer pool read time since 1st connect ===> %lu milliseconds", ts_ptr->pool_read_time);
      fprintf(outstream, "\n  Buffer pool write time since 1st connect===> %lu milliseconds", ts_ptr->pool_write_time);
      fprintf(outstream, "\n  Files closed since 1st connect          ===> %lu", ts_ptr->files_closed);

      fprintf(outstream, "\n  Buffer pool asynch data page reads      ===> %lu", ts_ptr->pool_async_data_reads);
      fprintf(outstream, "\n  Buffer pool asynch data page reads reqs ===> %lu", ts_ptr->pool_async_data_read_reqs);
      fprintf(outstream, "\n  Buffer pool asynch data page writes     ===> %lu", ts_ptr->pool_async_data_writes);
      fprintf(outstream, "\n  Buffer pool asynch index page writes    ===> %lu", ts_ptr->pool_async_index_writes);
      fprintf(outstream, "\n  Buffer pool asynch read time            ===> %lu milliseconds", ts_ptr->pool_async_read_time);
      fprintf(outstream, "\n  Buffer pool asynch write time           ===> %lu milliseconds", ts_ptr->pool_async_write_time);

      if (output_opt == SCREEN_OUTPUT)
         pause();

      fprintf(outstream, "\n\nDirect I/O Information:");
      fprintf(outstream, "\n  Sectors read directly                   ===> %lu", ts_ptr->direct_reads);
      fprintf(outstream, "\n  Sectors written directly                ===> %lu", ts_ptr->direct_writes);
      fprintf(outstream, "\n  Number of direct read requests          ===> %lu", ts_ptr->direct_read_reqs);
      fprintf(outstream, "\n  Number of direct write requests         ===> %lu", ts_ptr->direct_write_reqs);
      fprintf(outstream, "\n  Direct read time                        ===> %lu milliseconds", ts_ptr->direct_read_time);
      fprintf(outstream, "\n  Direct write time                       ===> %lu milliseconds", ts_ptr->direct_write_time);


      if (output_opt == SCREEN_OUTPUT)
         pause();

      buffer_index += ts_ptr->size;

   } /* end of for loop */

} /* process_tablespace */


/*****************************************************************************/
/* pr_sqlca                                                                  */
/* This function prints the contents of the sqlca error information          */
/* structure.                                                                */
/*****************************************************************************/
void pr_sqlca(struct sqlca *ca)
{

  char           buffer[200];
  unsigned short i;

  /*Print out header for DUMP*/
  fprintf(outstream, "*************************************\n");
  fprintf(outstream, "*         CONTENTS OF SQLCA         *\n");
  fprintf(outstream, "*************************************\n\n");

  /*Print out contents of SQLCA variables*/
  fprintf(outstream, "SQLCABC  = %ld\n", ca->sqlcabc);
  fprintf(outstream, "SQLCODE  = %ld\n", ca->sqlcode);
  fprintf(outstream, "SQLERRMC = %0.70s\n", ca->sqlerrmc);
  fprintf(outstream, "SQLERRP  =  %0.8s\n", ca->sqlerrp);

  sqlaintp(buffer, sizeof(buffer), 80, ca);
  fprintf(outstream, "%0.200s\n", buffer);

  for (i = 0; i < 6; i++)
  {
    fprintf(outstream, "sqlerrd[%d] = %lu \n", i, ca->sqlerrd[i]);
  }

  fprintf(outstream, "SQLWARN  = %0.11s\n", ca->sqlwarn);
  fprintf(outstream, "SQLSTATE = %0.5s\n", ca->sqlstate);
}  /* pr_sqlca */

/*****************************************************************************/
/* cleanup                                                                   */
/* General cleanup routine to close open files and release memory buffers.   */
/*****************************************************************************/
void cleanup(struct sqlma *ma_ptr)

{

   int                   rc = 0;

  if (output_opt == FILE_OUTPUT)
  {                                                     /* close output file */
    rc = fclose(outstream);
    if (rc != 0)
    {
      fprintf(outstream, "error closing output file at cleanup. rc= %d\n", rc);
    }
  }
  if (buffer_ptr != NULL)
     free(buffer_ptr);                                 /* free output buffer */

  if (ma_ptr != NULL)                                  /* free sqlma         */
     free(ma_ptr);


}  /* cleanup */

/*****************************************************************************/
/* pause.                                                                    */
/* Waits for user input before proceeding                                    */
/*****************************************************************************/
void pause()
{
   printf("\nEnter any key to continue!\n");
   fflush(stdin);
   getchar();
}  /* pause */

/*****************************************************************************/
/* clrscrn.                                                                  */
/* Clears the user's screen                                                  */
/*****************************************************************************/
void clrscrn()
{
   system(CLEARSCR);
}  /* clrscrn */
isecondk;   $        2  Q1Q1[U1         P5  2      ./usr/lpp/db2_02_01/samples/c/evmprint.c .3000/l                    $          //-----------------------------------------------------------------------------
//
// Source File Name = evmprint.c   %I%
//
// Licensed Materials - Property of IBM
//
// (C) COPYRIGHT International Business Machines Corp. 1995
// All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//
//------------------------------------------------------------------------------
// Event Monitor code sample - This file is included by 'evm.c'.
//
// evmprint.c - Prints all events generated by an Event Monitor
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>  /* To use cprint() function */
#include <time.h>

#include "sqlmon.h"
#include "sqlca.h"

//------------------------------------------------------------------------------
// Convert GMT time into local time, and format it into a printable string.
//------------------------------------------------------------------------------
char* time_STRING(const sqlm_timestamp timestamp, char *timeString) {

   // Event Monitor returns GMT time, adjust it to local time
   struct tm *pstTm;
   pstTm = localtime((signed long*) &timestamp.seconds);
   if (timestamp.seconds == 0)
      strcpy(timeString, "");
   else {
      if (timestamp.microsec < 0) {
         sprintf(timeString, "%02d-%02d-%04d %02d:%02d:%02d",
              pstTm->tm_mon + 1, pstTm->tm_mday, pstTm->tm_year + 1900,
              pstTm->tm_hour, pstTm->tm_min, pstTm->tm_sec);
      } else {
         sprintf(timeString, "%02d-%02d-%04d %02d:%02d:%02d.%06.6ld",
              pstTm->tm_mon + 1, pstTm->tm_mday, pstTm->tm_year + 1900,
              pstTm->tm_hour, pstTm->tm_min, pstTm->tm_sec, timestamp.microsec);
     } /* end else micro seconds are not null */
  } /* end if the timestamp is non-zero */
  return timeString;
} // end of time_STRING

//------------------------------------------------------------------------------
// Print a Blank Padded String of maximum length SZ
//------------------------------------------------------------------------------
// note: strings returned by DB2 are NOT NULL-TERMINATED, they are all
//       blank padded up to some maximum length.
//------------------------------------------------------------------------------
// For example, given:
//                   char   str[20] = "Contents of 1       ";
// the following invocation:
//                   fpBPSTR(stdout, " String 1", str, sizeof(str));
// will print:
//                   " String 1: Contents of 1"
//------------------------------------------------------------------------------
#define fpBPSTR(fp, txt, str, SZ) \
{ \
    char newstr[SZ]; \
    int k=0; \
    while (str[k]!=' '&&k<SZ) { newstr[k]=str[k]; k++;} \
    if (k<SZ) newstr[k]='\0'; \
    fprintf(fp, txt ": %0.*s\n", SZ, newstr); \
}
//------------------------------------------------------------------------------
char* byte_order_STRING(int val) {
   switch (val) {
   case SQLM_LITTLE_ENDIAN:      return "SQLM_LITTLE_ENDIAN";
   case SQLM_BIG_ENDIAN:         return "SQLM_BIG_ENDIAN";
   }
   return "";
} // end of byte_order_STRING
//------------------------------------------------------------------------------
char* table_type_STRING(int val) {
   switch(val) {
   case SQLM_USER_TABLE:         return "User";
   case SQLM_DROPPED_TABLE:      return "Dropped";
   case SQLM_TEMP_TABLE:         return "Temporary";
   case SQLM_CATALOG_TABLE:      return "Catalog";
   case SQLM_REORG_TABLE:        return "Reorg";
   }
   return "Unknown";
} // end of table_type_STRING
//------------------------------------------------------------------------------
char* lock_object_type_STRING(int val) {
   switch (val) {
   case SQLM_ROW_LOCK:        return "Row";
   case SQLM_TABLE_LOCK:      return "Table";
   case SQLM_INTERNAL_LOCK:   return "Internal";
   case SQLM_TABLESPACE_LOCK: return "Tablespace";
   }
   return "Unknown";
} // end of lock_object_type_STRING

//------------------------------------------------------------------------------
char* lock_mode_STRING(int val) {
   switch (val) {
   case SQLM_LNON: return "NO";
   case SQLM_LOIS: return "IS";
   case SQLM_LOIX: return "IX";
   case SQLM_LOOS: return "S";
   case SQLM_LSIX: return "SIX";
   case SQLM_LOOX: return "X";
   case SQLM_LOIN: return "IN";
   case SQLM_LOOZ: return "Z";
   case SQLM_LOOU: return "U";
   }
   return "Unknown";
} // end of lock_mode_STRING

//------------------------------------------------------------------------------
char* stmt_type_STRING(int val) {
   switch (val) {
   case SQLM_STATIC:            return "Static";
   case SQLM_DYNAMIC:           return "Dynamic";
   case SQLM_NON_STMT:          return "Non-SQL";
   case SQLM_STMT_TYPE_UNKNOWN: return "Unknown";
   }
   return "";
} // end of stmt_type_STRING
//------------------------------------------------------------------------------
char* operation_STRING(int val) {
   switch (val) {
   case SQLM_PREPARE:           return "Prepare";
   case SQLM_EXECUTE:           return "Execute";
   case SQLM_EXECUTE_IMMEDIATE: return "Execute Immediate";
   case SQLM_OPEN:              return "Open";
   case SQLM_FETCH:             return "Fetch";
   case SQLM_CLOSE:             return "Close";
   case SQLM_DESCRIBE:          return "Describe";
   case SQLM_STATIC_COMMIT:     return "Static Commit";
   case SQLM_STATIC_ROLLBACK:   return "Static Rollback";
   }
   return "Unknown";
} /* end of operation_STRING */

//------------------------------------------------------------------------------
// Printing routines
//------------------------------------------------------------------------------
void print_sqlm_event_log_header(FILE* fp,
                                 const sqlm_event_log_header *event_header){
   fprintf(fp, 
"--------------------------------------------------------------------------\n"
"                            EVENT LOG HEADER\n");
   fpBPSTR(fp, "  Event Monitor name",
                  event_header->event_monitor_name, SQLM_IDENT_SZ);
   fpBPSTR(fp, "  Server Product ID",
                  event_header->server_prdid, SQLM_IDENT_SZ