	 k 22by name         by name         service         d   
kԐ !*           I  222         Q  I      ./lpp_name                                    4 R S db2_02_01 {
db2_02_01.sdk.c 04.01.0002.4120 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.0002.4120
%
/usr/lpp/db2_02_01/include/sql.h 144
/usr/lpp/db2_02_01/include/sqlaprep.h 144
/usr/lpp/db2_02_01/include/sqlca.h 8
/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/sqlmon.h 216
/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/backrest.c 24
/usr/lpp/db2_02_01/samples/c/db2mon.c 256
/usr/lpp/db2_02_01/samples/c/evmprint.c 88
/usr/lpp/db2_02_01/samples/c/expsamp.sqc 24
/usr/lpp/db2_02_01/samples/c/makeapi.sqc 24
/usr/lpp/db2_02_01/samples/c/rechist.c 16
]
}
       kd A          8 222        T  8     ./usr/lpp/db2_02_01/db2_02_01.sdk.c/4.1.2.4120/liblpp.a                               <aiaff>
102864      0           68          4532        0           509         678         0           852739020   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.
 619         1406        68          852747975   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/sqlca.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/sqlmon.h
./usr/lpp/db2_02_01/include/sqlstate.h
./usr/lpp/db2_02_01/include/sqlutil.h
./usr/lpp/db2_02_01/samples/c/backrest.c
./usr/lpp/db2_02_01/samples/c/db2mon.c
./usr/lpp/db2_02_01/samples/c/evmprint.c
./usr/lpp/db2_02_01/samples/c/expsamp.sqc
./usr/lpp/db2_02_01/samples/c/makeapi.sqc
./usr/lpp/db2_02_01/samples/c/rechist.c
 656         2172        678         852747977   0           200         444         20  db2_02_01.sdk.c.size`
/usr/lpp/db2_02_01/include/sql.h 144
/usr/lpp/db2_02_01/include/sqlaprep.h 144
/usr/lpp/db2_02_01/include/sqlca.h 8
/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/sqlmon.h 216
/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/backrest.c 24
/usr/lpp/db2_02_01/samples/c/db2mon.c 256
/usr/lpp/db2_02_01/samples/c/evmprint.c 88
/usr/lpp/db2_02_01/samples/c/expsamp.sqc 24
/usr/lpp/db2_02_01/samples/c/makeapi.sqc 24
/usr/lpp/db2_02_01/samples/c/rechist.c 16
73          2358        1406        852747975   2379        200         644         22  db2_02_01.sdk.c.prereq`
*prereq db2_02_01.sdk.c 4.1.1.2

*ifreq db2_02_01.client 04.01.0002.4120
 77          2552        2172        852741035   2379        200         644         26  db2_02_01.sdk.cobol.prereq`
*prereq db2_02_01.sdk.cobol 4.1.1.2

*ifreq db2_02_01.client 04.01.0002.4120
 75          2742        2358        852741043   2379        200         644         24  db2_02_01.sdk.cli.prereq`
*prereq db2_02_01.sdk.cli 4.1.1.2

*ifreq db2_02_01.client 04.01.0002.4120
 1673        4532        2552        852747977   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 = 72629

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

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

/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 = 39645

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

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

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

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

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

/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

/usr/lpp/db2_02_01/samples/c/expsamp.sqc:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 8319

/usr/lpp/db2_02_01/samples/c/makeapi.sqc:
	owner = bin
	group = bin
	mode = 444
	type = FILE
	size = 9777

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

 98232       102864      2742        852747512   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.01


+--- 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.2)
 IBM DB2 World Wide Web Connection

For last minute information on IBM Distributed Database Connection
Services Multi-User Gateway for Windows NT see the DDCSREAD.TXT readme file.

For information, see also

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

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


1.0  Contents

2.  INSTALLATION NOTES
2.1  New Commands to Facilitate Applying Service to DB2
2.2  Modifications to db2imigr, db2imigrev and db2idrop
2.3  Installing DDCS and Database Server on the Same Workstation
  2.3.1  Considerations When DDCS Is Already Installed
  2.3.2  Installing DDCS and Database Server
  2.3.3  Applying Fixes or Installing Additional Database Server Products

3.  ENVIRONMENT CONSIDERATIONS
3.1  Copying a Shared Library

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)

5.  COMMUNICATIONS ISSUES
5.1  TCP/IP
5.2  TZ Environment Variable
5.3  LAN Support Program and NetBIOS rc=0x18

6.  PROGRAMMING NOTES
6.1  Sample Applications
6.2  Considerations when Using Micro Focus COBOL
  6.2.1  Updating the Micro Focus COBOL Runtime System
  6.2.2  Configuring CICS for Use With DB2 2.1.2 and Micro Focus COBOL
         on UNIX Platforms
6.3  BINARY/COMP-4 COBOL Data Types in the DB2 Precompiler
6.4  Using REDEFINES in COBOL Group Data Items
6.5  Running DB2 for AIX COBOL Stored Procedures
6.6  Building Micro Focus COBOL Stored Procedures on AIX
6.7  Precompiler Customization
6.8  Considerations When Using REXX Stored Procedures
6.9  CLI/ODBC Multi-Thread Support

7.  DB2 WORLD WIDE WEB CONNECTION-SPECIFIC INFORMATION
7.1  Installation Notes
7.2  DB2 WWW Connection Configuration
7.3  Usage Notes
  7.3.1  Authentication
7.4  Using the Sample Application
  7.4.1  Installation Notes
  7.4.2  DBCS Considerations When Using the Sample Application

8.  NEW FUNCTION ADDED TO THE V2.1.2 RELEASE
8.1  RENAME TABLE
8.2  Threaded Applications with Concurrent Access
  8.2.1  sqleSetTypeCtx()
    8.2.1.1  Return codes
  8.2.2  sqleBeginCtx()
    8.2.2.1  Return codes
  8.2.3  sqleEndCtx()
    8.2.3.1  Return codes
  8.2.4  sqleAttachToCtx()
    8.2.4.1  Return codes
  8.2.5  sqleDetachFromCtx()
    8.2.5.1  Return codes
  8.2.6  sqleGetCurrentCtx()
    8.2.6.1  Return codes
  8.2.7  sqleInterruptCtx()
    8.2.7.1  Return codes
8.3  Quick Guide to Using the SOCKS Enabled DB2 Client
  8.3.1  Requirements
  8.3.2  Environment Variables
  8.3.3  Using SOCKS via the command line processor:
  8.3.4  Using SOCKS via the CATALOG NODE API (sqlectnd):
  8.3.5  Troubleshooting
  8.3.6  Restrictions
  8.3.7  The IBM NetSP Secured Network Gateway V1.2 (SOCKS) Server
8.4  CREATE IN DATABASE
  8.4.1  Deferred Prepare Support for ODBC/CLI Applications
8.5  Support for Redirected Restore
  8.5.1  The SET TABLESPACE CONTAINERS Command
  8.5.2  The Changes to the RESTORE DATABASE Command
8.6  NLS Additions
8.7  DB2 Support for Java Code Development

9.  MISCELLANEOUS
9.1  DB2 Family Newsletter


2.  Installation Notes

2.1  New Commands to Facilitate Applying Service to DB2

Two new instance management scripts db2maint and db2mtoff are provided
to simplify the task of applying future service to Version 2.1.2
installations.  These new functions automate the tasks of shutting
down the database manager and preventing new applications from
starting during the application of maintenance to DB2.

The two new commands can be invoked as follows:

DB2MAINT [-F]
          The db2maint command places Version 2 in maintenance mode by
          stopping the database manager and preventing new database
          applications from starting.  The optional -f parameter is
          the force applications flag.  If this flag is specified then
          all active databases for all Version 2 instances on the
          current machine will be stopped.  If the -f parameter is not
          specified then an error will be returned if any active
          databases are detected.

DB2MTOFF
          Removes the product from maintenance mode, enabling new
          database applications to run.

The following tasks, which previously had to be performed manually
when applying service to DB2, are now performed automatically by
running the db2maint command with the "-f" option:

o   All active databases for all DB2 instances on the current system
    are automatically stopped.

o   The database managers for all DB2 instances on the current system
    are automatically stopped.

o   All Command Line Processor back-end processes are automatically
    terminated (previously this could only be accomplished by issuing
    the db2 terminate command in all sessions that were using the
    Command Line Processor).

o   The DB2 license daemon is automatically terminated.

o   The DB2 shared libraries are removed from memory.

o   New DB2 applications are prevented from starting.

The methodology for applying future service to DB2 is now simplified
to the following 4 steps:

1.  Run db2maint to put DB2 Version 2.1.2 into maintenance mode.

2.  Apply the DB2 maintenance (or install and remove required product
    options).

3.  For each Version 2.1.2 instance, run the db2iupdt command to
    update the instance.

4.  Run db2mtoff to turn maintenance mode OFF. This enables DB2
    applications to run at the new maintenance level.


2.2  Modifications to db2imigr, db2imigrev and db2idrop

The db2imigr script has also been modified so that it places the
Version 1 installation in maintenance mode.  This prevents new Version
1 database applications from starting on all Version 1 instances while
the db2imigr command is running.

The optional "-f" parameter has also been added to the db2imigr, the
db2idrop and the db2imigrev commands.  If this parameter is specified
then running these commands will automatically stop all active
databases and the database manager for the specified instance.  If the
"-f" parameter is not specified then these commands will return an
error if there are any active databases using the specified instance.

The following tasks, which previously had to be performed manually
when running the db2imigr, db2imigrev or db2idrop commands, are now
performed automatically by running these commands with the new "-f"
option:

o   All active databases for the specified DB2 instance are
    automatically stopped.

o   The database manager for the specified DB2 instance is
    automatically stopped.

o   All Command Line Processor back-end processes for the specified
    DB2 instance are automatically terminated (previously this could
    only be accomplished by issuing the db2 terminate command in all
    sessions that were using the Command Line Processor).

o   The DB2 license daemon is automatically terminated.

o   An attempt is made to remove the DB2 Version 1 shared libraries
    from memory (the DB2 Version 1 shared libraries will not be
    removed if there are other DB2 Version 1 instances that are
    currently using the shared libraries).

o   New DB2 applications are prevented from starting.

A new executable "db2ilistv1" is also provided which will list all
Version 1 instances on a machine. db2ilist_v1 does not have any input
parameters.


2.3  Installing DDCS and Database Server on the Same Workstation


2.3.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.3.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.3.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.


3.  Environment Considerations

3.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.


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:

Logon as root and do the following:

1.  Place DB2 into maintenance mode For example,

            /usr/lpp/db2_02_01/instance/db2maint -f

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)

5.  Turn DB2 maintenance mode off For example,

            /usr/lpp/db2_02_01/instance/db2mtoff

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.2 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


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


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



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



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.  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


5.  Communications Issues

5.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)


5.2  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.


5.3  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.


6.  Programming Notes

6.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.

    samples/java/README

        README file for the DB2Java examples.


6.2  Considerations when Using Micro Focus COBOL

DB2 v2.1.2 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.2 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.


6.2.1  Updating the Micro Focus COBOL Runtime System

DB2 v2.1.2 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.


6.2.2  Configuring CICS for Use With DB2 2.1.2 and Micro Focus COBOL
on UNIX Platforms

DB2 v2.1.2 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.2 COBOL precompiler to
function correctly with CICS.


6.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)


6.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.


6.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
   [1]> ln -sf /usr/lpp/cobdir/coblib/*.a .


6.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


6.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().


6.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).


6.9  CLI/ODBC Multi-Thread Support

With release 2.1.2, both CLI and the ODBC driver are capable of
supporting multiple concurrent threads.

The multi-thread support can be enabled or disabled through the
"DisableMultiThread" db2cli.ini file setting ( 1 True, 0 False).
The default is True, Multi Thread support is disabled,
and CLI/ODBC will serialize all calls.

If DisableMultiThread is set =1 in the "COMMON] section of the
db2cli.ini file, CLI/ODBC calls will be serialized at the connection
level.

Only enable the multi-thread support if the application makes use
of multiple threads, and:
 - does not call any other DB2 APIs prior to calling SQLAllocEnv.
 - does not call sqleisig() or sqleintr() DB2 APIs.


7.  DB2 World Wide Web Connection-Specific Information

7.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.


7.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


7.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.


7.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.


7.4  Using the Sample Application


7.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.


7.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


8.  New Function added to the V2.1.2 Release

8.1  RENAME TABLE


The RENAME TABLE statement renames an existing table.


8.1.1  Invocation

This statement can be embedded in an application program or issued
through the use of dynamic SQL statements.  It is an executable
statement that can be dynamically prepared.


8.1.2  Authorization

The privileges held by the authorization ID of the statement must
include either SYSADM or DBADM authority.


8.1.3  Syntax

+--------------------------------------------------------------------+
|                                                                    |
|             .-TABLE-.                                              |
| >>--RENAME--'-------'--source-table-name--TO---------------------> |
|                                                                    |
| >--target-identifier-------------------------------------------->< |
|                                                                    |
+--------------------------------------------------------------------+


8.1.4  Description

source-table-name
    Names the existing table that is to be renamed.  The name,
    including the schema name, must identify a table that already
    exists in the database (SQLSTATE 42704). It can be an alias
    identifying the table.  It must not be the name of a catalog table
    (SQLSTATE 42832) or an object of any type other than table or
    alias (SQLSTATE 42809).

target-identifier
    Specifies the new name for the table without a schema name.  The
    schema name of the source-table-name is used to qualify the new
    name for the table.  The qualified name must not identify a table,
    view, or alias that already exists in the database (SQLSTATE
    42710).


8.1.5  Rules

o   The source table must not:

    -   be referenced in any existing view definitions
    -   be referenced in any triggered SQL statements in existing
        triggers or be the subject table of an existing trigger
    -   have any check constraints
    -   be a parent or dependent table in any referential integrity
        constraints.

    An error (SQLSTATE 42986) is returned if the source table violates
    one or more of these conditions.


8.1.6  Notes

o   Catalog entries are updated to reflect the new table name.

o   All authorizations associated with the source table name are
    transferred to the new table name (the authorization catalog
    tables are updated appropriately).

o   Indexes defined over the source table are transferred to the new
    table (the index catalog tables are updated appropriately).

o   Any packages that are dependent on the source table are
    invalidated.

o   If an alias is used for the source-table-name, it must resolve to
    a table name.  The table is renamed within the schema of this
    table.  The alias is not changed by the RENAME statement and
    continues to refer to the old table name.

o   A table with primary key or unique constraints may be renamed if
    none of the primary key or unique constraints are referenced by
    any foreign key.


8.1.7  Example

Change the name of the EMP table to EMPLOYEE.

    RENAME TABLE EMP TO EMPLOYEE


8.2  Threaded Applications with Concurrent Access

Seven new APIs are available which allow separate environments
(contexts) to be allocated for each thread, and allow these contexts
to be passed among threads.

There are seven new APIs.

o   int sqleSetTypeCtx(lOptions)
o   int sqleBeginCtx(**pContext, lOptions, *reserved, *pSqlca)
o   int sqleEndCtx(**pContext, lOptions, *reserved, *pSqlca)
o   int sqleAttachToCtx(*pContext, *reserved, *pSqlca)
o   int sqleDetachFromCtx(*pContext, *reserved, *pSqlca)
o   int sqleGetCurrentCtx(**pContext, *reserved, *pSqlca)
o   int sqleInterruptCtx(*pContext, *reserved, *pSqlca)

where:

LOPTIONS            API specific:

                    o   sqleSetTypeCtx() - Options to handle thread
                        context (that is, use current style or use
                        true concurrent access).
                    o   sqleBeginCtx() - Indicates if context should
                        be created only or an attach done as well.
                    o   sqleEndCtx() - Indicates if context should be
                        destroyed only or detached as well.  (In
                        destroy only mode, destroy will fail if it is
                        not detached.)

PCONTEXT            A structure defining the context.  sqleBeginCtx()
                    allocates a data area out of private memory for
                    storage of context information.  This area will be
                    freed on a call to sqleEndCtx().

RESERVED            Reserved for future.

PSQLCA              Information on success or failure

These APIs may be used with embedded SQL or the XA APIs.

NOTES:

1.  If the new APIs are not used, the old behavior is in effect and
    existing applications need not change.

2.  Also note that CLI automatically uses the new scheme (CLI will
    create a new context for each incoming connection), and it is up
    to the user to disable this explicitly.

3.  The behavior of the prep, bind, import, export APIs remains
    unchanged at this time.

When using the new APIs, all work associated with a CONNECT has
effectively been disassociated with a process or thread, and now
resides with a context.  This context may be shuffled around between
threads in a process (but not between processes).


8.2.1  sqleSetTypeCtx()

    int sqleSetTypeCtx(long lOptions)

This is used to set the application context type, and should be the
first database API called inside the application. Option values
include:

o   SQL_CTX_ORIGINAL - All threads use the same context and therefore
    concurrent access will be blocked.  This is the current behavior
    and is the default if none of these APIs are called.

o   SQL_CTX_MULTI_MANUAL - All threads will use separate contexts and
    it is up to the application to manage the context for each thread
    (sqleBeginCtx(), sqleAttachToCtx(), sqleDetachFromCtx(),
    sqleEndCtx()).

This API must be called before any other type of database call
(utility APIs, embedded SQL, XA APIs, the other Ctx APIs, etc.) to
have any effect and only the first call will have any effect.  All
subsequent calls have no effect.

This API has no effect on platforms where application threading is not
supported.

The following is a list of restrictions/changes when
SQL_CTX_MULTI_MANUAL is used:

o   Automatic COMMIT at process termination (when termination is
    normal) is disabled.  All outstanding transactions will be rolled
    back, whether termination is normal or not.  (Note that this is
    the way DB2 for Windows NT has always worked).  This means that
    all COMMITs must be done explicitly within the program.

o   sqleintr() will interrupt all contexts.  Interrupt support on a
    per context basis is supplied by sqleInterruptCtx().


8.2.1.1  Return codes

o    0 - success
o   -1 - bad option


8.2.2  sqleBeginCtx()

    int sqleBeginCtx(void ** ppCtx,
                     long    lOptions,
                     void * reserved,
                     struct sqlca * pstSqlca)

This is used to create or create and attach to an application context.
More than one application context may be created.  Each has its own
commit scope.  Different threads can 'attach' (see below) to different
contexts.  Any database API calls made by such threads will not be
serialized with one another.

The options are as follows:

o   SQL_CTX_CREATE_ONLY - The context memory will be created only - no
    attach will be done.

o   SQL_CTX_BEGIN_ALL - The context will be allocated, then a call to
    sqleAttachToCtx will be made for the current thread.  If this
    option is used, the ppCtx parameter may be NULL.  If the thread is
    already attached to a context, the call will fail.

This API has no effect on platforms where application threading is not
supported.


8.2.2.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1219 - private memory could not be allocated
    -   -1441 - invalid parameter


8.2.3  sqleEndCtx()

    int sqleEndCtx(void ** pCtx,
                   long    lOptions,
                   void * reserved,
                   struct sqlca * pstSqlca)

This frees all memory associated with a given pCtx.

The options are as follows:

o   SQL_CTX_FREE_ONLY - The context memory will be freed only if a
    prior detach has been done.

    pCtx is expected to be a valid context previously allocated by
    sqleBeginCtx().

o   SQL_CTX_END_ALL - A call to sqleDetachFromCtx will be made if
    necessary, then the memory will be freed.  If this option is used,
    the ppCtx parameter may be NULL, but if it is passed, it is
    expected to be a valid context previously allocated by
    sqleBeginCtx().  A call to sqleGetCurrentCtx will be made and the
    current context freed.

If a database connection exists, or the context has been attached to
by another thread, this call will fail.  Note that if END_ALL was
requested, a detach will be done even if the context is still in use.

This API has no effect on platforms where application threading is not
supported.


8.2.3.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1219 - private memory could not be allocated
    -   -1444 - context in use
    -   -1441 - invalid parameter
    -   -1442 - context not in use


8.2.4  sqleAttachToCtx()

    int sqleAttachToCtx(void * pCtx,
                        void * reserved,
                        struct sqlca * pstSqlca)

This call is used to make the current thread use the context pointed
to by pCtx.  All subsequent database calls made on this thread will
use this context.  If more than one thread is attached to a given
context, access will be serialized for these threads and they will
share a commit scope.

pCtx is expected to be a valid context previously allocated by
sqleBeginCtx().

This API has no effect on platforms where application threading is not
supported.


8.2.4.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1219 - private memory could not be allocated
    -   -1441 - invalid parameter
    -   -1443 - thread already using context


8.2.5  sqleDetachFromCtx()

    int sqleDetachFromCtx(void * pCtx,
                          void * reserved,
                          struct sqlca * pstSqlca)

This call detaches the context in use by the current thread.  A
previous call to sqleAttachToCtx() for that context must have been
made.

pCtx is expected to be a valid context previously allocated by
sqleBeginCtx().

This API has no effect on platforms where application threading is not
supported.


8.2.5.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1441 - invalid parameter
    -   -1442 - context not in use


8.2.6  sqleGetCurrentCtx()

    int sqleGetCurrentCtx(void ** ppCtx,
                          void * reserved,
                          struct sqlca * pstSqlca)

This returns the current context associated with a thread.

This API has no effect on platforms where application threading is not
supported.


8.2.6.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1219 - private memory could not be allocated
    -   -1441 - invalid parameter
    -   -1442 - context not in use


8.2.7  sqleInterruptCtx()

    int sqleInterruptCtx(void * pCtx,
                         void * reserved,
                         struct sqlca * pstSqlca)

This call interrupts the specified context.

pCtx is expected to be a valid context previously allocated by
sqleBeginCtx().

During processing, this call switches contexts to the one passed in,
sends the interrupt, then switches back to its original context before
exiting.

This API has no effect on platforms where application threading is not
supported.


8.2.7.1  Return codes

o   -1 - bad sqlca
o    0 - check the sqlca for the sqlcode.  The most common ones
    returned for this API are:
    -   0 - success
    -   -1219 - private memory could not be allocated
    -   -1360 - thread cannot be interrupted
    -   -1441 - invalid parameter
    -   -1442 - context not in use


8.3  Quick Guide to Using the SOCKS Enabled DB2 Client


8.3.1  Requirements

This interface is designed for use with the IBM NetSP Secured Network
Gateway V1.2 firewall server product.


8.3.2  Environment Variables

The following environment variables are mandatory and MUST be set to
enable SOCKS:

SOCKS_NS       This is your Domain Name Server for resolving the host
               address of your SOCKS server.  This should be an IP
               address.

SOCKS_SERVER   This is either the fully qualified hostname or the IP
               address of your SOCKS server.  Note that if the SOCKS
               enabled DB2 client is unable to resolve your fully
               qualified hostname it will assume that an IP address
               has been entered.

               Your SOCKS_SERVER should be reachable via the SOCKS_NS
               domain server OR it should be in your /etc/hosts file
               OR it should be in an IP address format.

If you are using the command line processor and you have set these
environment variables after issuing a 'db2start', issue a DB2
TERMINATE at the command-line.


8.3.3  Using SOCKS via the command line processor:

1.  To catalog a SOCKS node, catalog your node as a TCP/IP node, but
    add a new SECURITY option to specify whether you will be using
    SOCKS for that node.

   +-----------------------------------------------------------------+
   |                                                                 |
   |  >>--CATALOG TCPIP NODE--nodename--REMOTE--hostname-----------> |
   |                                                                 |
   |  >--SERVER--service-name--.----------------.------------------> |
   |                           '-SECURITY SOCKS-'                    |
   |                                                                 |
   |  >--.------------------------.------------------------------->< |
   |     '-WITH--"comment-string"-'                                  |
   |                                                                 |
   +-----------------------------------------------------------------+

    Example:

    a.  To catalog a TCP/IP node that will NOT be SOCKS-enabled, with
        the nodename of NOSOCKS, hostname of DB2SERV, and service-name
        of TCP_DB2SERV, enter the following:

            CATALOG TCPIP NODE NOSOCKS REMOTE DB2SERV SERVER TCP_DB2SERV

    b.  To catalog a TCP/IP node that will be SOCKS-enabled, with the
        nodename of YESSOCKS, hostname of DB2SERV, and service-name of
        TCP_DB2SERV, enter the following:

            CATALOG TCPIP NODE YESSOCKS REMOTE DB2SERV SERVER TCP_DB2SERV
            SECURITY SOCKS

        NOTE:  Note that you have to enter security socks to enable
               this support!

2.  To check which of your nodes are enabled for SOCKS, enter the
    following command:

             LIST NODE DIRECTORY

    Note that this command has not changed.  However when listing node
    information, for TCP/IP nodes that have SECURITY SOCKS enabled,
    the node information will have an extra line with the information
    SECURITY = SOCKS.  For non-SOCKS-enabled nodes, no line will be
    displayed for SECURITY.

3.  Once your node is cataloged, catalog your database as you normally
    would.  No changes have been made to this command.

4.  Connect to your database using the standard CONNECT statement.
    Once you have connected successfully to your database, it should
    be business as usual.


8.3.4  Using SOCKS via the CATALOG NODE API (sqlectnd):

Check your DB2 API Reference for the usage of this API.

1.  API Syntax

    The overall syntax of the sqlectnd API remains as follows:

    C API Syntax

             ____________________________________________________
            |                                                    |
            |  /* File: sqlenv.h */                              |
            |  /* ... */                                         |
            |  SQL_API_RC SQL_API_FN                             |
            |    sqlectnd (                                      |
            |          struct sqle_node_struct * pNodeInfo,      |
            |          void * pProtocolInfo,                     |
            |          struct sqlca * pSqlca);                   |
            |  /* ... */                                         |
            |____________________________________________________|

    Generic API Syntax

             ____________________________________________________
            |                                                    |
            |   /* File: sqlenv.h */                             |
            |   /* ... */                                        |
            |   SQL_API_RC SQL_API_FN                            |
            |     sqlgctnd (                                     |
            |           struct sqlca * pSqlca,                   |
            |           struct sqle_node_struct * pNodeInfo,     |
            |           void * pProtocolInfo);                   |
            |   /* ... */                                        |
            |____________________________________________________|

    API Parameters

    PSQLCA         Output.  A pointer to the sqlca structure.

    PNODEINFO      Input.   A pointer to a node directory structure.
                   For more information about this structure, see
                   "SQLE-NODE-STRUCT" below.


    PPROTOCOLINFO  Input.   A pointer to the protocol structure.  See
                   "SQLE_NODE_TCPIP" below.

2.  SQLE_NODE_STRUCT

    A new communications PROTOCOL type has been created for use in
    cataloging a TCP/IP SOCKS node as follows:

         SQL_PROTOCOL_SOCKS
            TCPIP using SOCKS

    To catalog a SOCKS node, simply set the PROTOCOL type in the node
    directory structure to SQL_PROTOCOL_SOCKS before invoking the API.

         _____________________________________________________________________
        | Fields in the SQLE-NODE-STRUCT Structure                            |
        |_____________________________________________________________________|
        | Field     | Data     | Description                                  |
        | Name      | Type     |                                              |
        |___________|__________|______________________________________________|
        | STRUCT_ID | SMALLINT | Structure identifier.                        |
        |           |          |                                              |
        |___________|__________|______________________________________________|
        | CODEPAGE  | SMALLINT | Code page for comment.                       |
        |           |          |                                              |
        |___________|__________|______________________________________________|
        | COMMENT   | CHAR(30) | Optional description of the database.        |
        |           |          |                                              |
        |___________|__________|______________________________________________|
        | NODENAME  | CHAR(8)  | The name of the node where the database is   |
        |           |          | located.                                     |
        |___________|__________|______________________________________________|
        | PROTOCOL  | CHAR(1)  | Communications protocol type.                |
        |           |          |                                              |
        |___________|__________|______________________________________________|
        | Note:  The character fields passed in this structure must be null   |
        | terminated or blank filled up to the length of the field.           |
        |_____________________________________________________________________|

       C Structure

             ___________________________________________________________
            |                                                           |
            |   /* File: sqlenv.h */                                    |
            |   /* ... */                                               |
            |   SQL_STRUCTURE sqle_node_struct                          |
            |   {                                                       |
            |           unsigned short struct_id;                       |
            |           unsigned short codepage;                        |
            |           char           comment"SQL_CMT_SZ + 1];         |
            |           char           nodename"SQL_NNAME_SZ + 1];      |
            |           unsigned char  protocol;                        |
            |   };                                                      |
            |   /* ... */                                               |
            |___________________________________________________________|

     COBOL Structure

             ___________________________________________________________
            |                                                           |
            |     * File: sqlenv.cbl                                    |
            |     ** ....                                               |
            |      01 SQL-NODE-STRUCT.                                  |
            |          05 STRUCT-ID              PIC 9(4) COMP-5.       |
            |          05 CODEPAGE               PIC 9(4) COMP-5.       |
            |          05 COMMENT                PIC X(30).             |
            |          05 FILLER                 PIC X.                 |
            |          05 NODENAME               PIC X(8).              |
            |          05 FILLER                 PIC X.                 |
            |          05 PROTOCOL               PIC X.                 |
            |          05 FILLER                 PIC X(1).              |
            |     ** ....                                               |
            |___________________________________________________________|

3.  SQLE_NODE_TCPIP

       SOCKS nodes use the same protocol structure as regular TCP/IP
    nodes.
       All data requirements are the same for both types of nodes.

         _____________________________________________________________________
        | Fields in the SQLE-NODE-TCPIP Structure                             |
        |_____________________________________________________________________|
        | Field Name   | Data Type | Description                              |
        |______________|___________|__________________________________________|
        | HOSTNAME     | CHAR(255) | The name of the TCP/IP host on which the |
        |              |           | DB2 server resides.                      |
        |______________|___________|__________________________________________|
        | SERVICE_NAME | CHAR(14)  | TCP/IP service name of the DB2 server.   |
        |______________|___________|__________________________________________|

       C Structure

             ___________________________________________________________
            |                                                           |
            |   /* File: sqlenv.h */                                    |
            |   /* ... */                                               |
            |     SQL_STRUCTURE sqle_node_tcpip                         |
            |     {                                                     |
            |              char     hostname"SQL_HOSTNAME_SZ+1];        |
            |              char     service_name"SQL_SERVICE_NAME_SZ+1];|
            |     };                                                    |
            |   /* ... */                                               |
            |___________________________________________________________|

    COBOL Structure


             ___________________________________________________________
            |                                                           |
            |   * File: sqlenv.cbl                                      |
            |   ** ....                                                 |
            |   01 SQL-NODE-TCPIP.                                      |
            |       05 HOSTNAME               PIC X(255).               |
            |       05 FILLER                 PIC X.                    |
            |       05 SERVICE-NAME           PIC X(14).                |
            |       05 FILLER                 PIC X.                    |
            |  ** ....                                                  |
            |___________________________________________________________|


8.3.5  Troubleshooting

To debug simple problems, use the DB2DIAG.LOG file for your instance.
To obtain the maximum amount of information, issue the following
command before issuing a db2start.

     DB2 UPDATE DBM CFG USING DIAGLEVEL 4

This will include error, warning and informational messages in
DB2DIAG.LOG.  In particular this log file should indicate whether the
connect failed when trying to connect to the SOCKS firewall server or
the DB2 target server.


8.3.6  Restrictions

The SOCKS option is only supported through the command line processor
or APIs.  You cannot use the Client Setup Utility or the Database
Director to set this option.


8.3.7  The IBM NetSP Secured Network Gateway V1.2 (SOCKS) Server

NOTE:  This section may be most relevant for the firewall
       administrator.

1.  Make sure that your sockd.conf file has an entry permitting the
    DB2 client to connect to the target server.

    a.  For UNIX, your sockd.conf must include the IP address of the
        DB2 client, but does not need to include the source logged-on
        user ID at the DB2 client unless you specifically want to
        permit connections based on both the user ID and the IP
        address.  There is no default source logged-on  user ID for
        UNIX. User IDs on UNIX may be case-sensitive, and should be
        entered in the sockd.conf file in their original case.

    b.  For OS/2, your sockd.conf must include the IP address of the
        DB2 client, but does not need to include the source logged-on
        user ID at the DB2 client unless you specifically want to
        permit connections based on both the user ID and the IP
        address.  The default source logged-on user ID for OS/2 is
        'OS2USER'.

    c.  For Windows 3.1, Windows 95, and Windows NT, your sockd.conf
        must include the IP address of the DB2 client, but does not
        need to include the source logged-on user ID at the DB2 client
        unless you specifically want to permit connections based on
        both the user ID and the IP address.  Typically for Windows
        3.1 the default source logged-on user ID is 'WINUSER'.  For
        Windows NT it is 'NTUSER'.

2.  Make sure that your SOCKS daemon, sockd, has been started at your
    SOCKS server.  Refer to the "IBM NetSP Secured Network Gateway
    V1.2 Installation, Configuration and Administration Guide' for
    details on configuring and starting the sockd daemon.

    NOTE:  The Secured Network Gateway product is only available on
           AIX.

3.  Check your messages file, in /var/adm/messages, if any problems
    occur or if you want to look at audit information.


8.4  CREATE IN DATABASE

All "CREATE TABLE" statements will have an "IN DATABASE <dbname>"
statement appended to the end if:

o   The connection is to DB2 for MVS.
o   The statements are issued through the ODBC driver.
o   The db2cli.ini keyword DBNAME is set (to <dbname>)
o   There is no "IN DATABASE" clause in the original SQL "CREATE
    TABLE" statement.


8.4.1  Deferred Prepare Support for ODBC/CLI Applications

Deferred Prepare is a performance enhancement for the ODBC/CLI
application.  This can be enabled or disable with a new configuration
parameter DEFERREDPREPARE=0 (disable) or 1 (enable) in the DB2
ODBC/CLI configuration file (DB2CLI.INI).  By default it is disabled
for the refresh.

When Deferred Prepare is enabled, the DB2 client will defer the
processing of the SQL Prepare request until the corresponding SQL OPEN
or EXECUTE is issued.  This is especially beneficial when a remote
database is accessed where the network flow for the two requests can
be combined.  This is an internal optimization that is transparent to
ODBC applications and does not require any application changes.

The following are considerations for enabling Deferred Prepare:

o   If you are using PeopleSoft, you should enable Deferred Prepare
    (DEFERREDPREPARE=1) and disable Cursor Hold (CURSORHOLD=0) for
    maximum performance.

o   If you are using SAP or BAAN, where their server ODBC applications
    PREPARE large number of statements ahead of time but won't Execute
    or Open the prepared statement until much later when a client
    application requests them, then there may not be any advantage in
    enabling Deferred Prepare.  The startup of the Server application
    will be faster, but the first execution of the actual SQL query
    might be slower.  Subsequent execution of the same query will have
    no difference.

o   For most ODBC application, enabling Deferred Prepare will increase
    performance by cutting down on the network flow of sending out the
    Prepare and Open/Execute separately.

o   Enabling Deferred Prepare will also defer the checking of the
    Optimization Estimate (DB2ESTIMATE=nn) until a cursor is opened
    instead of when it is prepared.

o   Deferred Prepare is disabled internally for SQL statements that
    reference the file descriptors of LOB data.


8.5  Support for Redirected Restore

A new command, SET TABLESPACE CONTAINERS, has been added to the
command line processor.  Also, new options have been added to the
RESTORE DATABASE command.  These changes enable you to perform the
redirected restore using the command line processor instead of writing
a program that calls the SET TABLESPACE CONTAINERS (sqlbstsc) API.

A redirected restore is a restore in which a set of table space
containers to contain the restored database is different from the one
of the original database at the time the backup was done.  This new
command allows you to add, change or remove table space containers for
a database that is to be restored.  For example, if one or more
containers are inaccessible for any reason, the restore will fail if
it is not redirected to different containers.

NOTE:  Redirected restore is not allowed when a user exit program is
       used to perform the restore.


8.5.1  The SET TABLESPACE CONTAINERS Command

COMMAND SYNTAX

    SET TABLESPACE CONTAINERS FOR tablespace-id
      [{REPLAY | IGNORE} ROLLFORWARD CONTAINER OPERATIONS]
      USING ( {PATH 'container-string' [{, PATH 'container-string'}...] |
              {FILE | DEVICE} 'container-string' number-of-pages
              [{, {FILE | DEVICE} 'container-string' number-of-pages}...]} )

COMMAND PARAMETERS

FOR TABLESPACE-ID
          An integer that uniquely represents a table space used by
          the database being restored.

{REPLAY | IGNORE} ROLLFORWARD CONTAINER OPERATIONS
          If REPLAY ROLLFORWARD CONTAINER OPERATIONS is specified
          (this is the default action), any ALTER TABLESPACE operation
          issued against this table space since the database was
          backed up will be redone during a subsequent roll forward of
          the database.

          If IGNORE ROLLFORWARD CONTAINER OPERATIONS is specified, the
          ALTER TABLESPACE operations in the log will be ignored when
          performing a roll forward.

USING ( PATH 'CONTAINER-STRING', ... )
          For a SMS table space, identifies one or more containers
          that will belong to the table space and into which the table
          space's data will be stored.

          The container-string is an absolute or relative directory
          name.  If the directory name is not absolute, it is relative
          to the database directory.  The container-string cannot
          exceed 240 bytes in length.

USING ( {FILE | DEVICE} 'CONTAINER-STRING' NUMBER-OF-PAGES, ... )
          For a DMS table space, identifies one or more containers
          that will belong to the table space and into which the table
          space's data will be stored.  The type of the container
          (either FILE or DEVICE) and its size (in 4K pages) are
          specified.  A mixture of FILE and DEVICE containers can be
          specified.  The container-string cannot exceed 254 bytes in
          length.

          For a FILE container, the container-string must be an
          absolute or relative file name.  The file name, if not
          absolute, is relative to the database directory.

          For a DEVICE container, the container-string must be a
          device name.  The device must already exist.


8.5.2  The Changes to the RESTORE DATABASE Command

COMMAND SYNTAX

   RESTORE DATABASE source-database-alias { restore-options | CONTINUE | ABORT }

 restore-options:
 [USER username [USING password]] [TABLESPACE ONLINE | HISTORY FILE] [USE ADSM
 [OPEN num-sess SESSIONS] | FROM dir/dev [ {,dir/dev} ... ] | LOAD shared-lib
 [OPEN num-sess SESSIONS]] [TAKEN AT date-time] [TO target-directory]
 [INTO target-database-alias] [WITH num-buff BUFFERS] [BUFFER buffer-size]
 [REPLACE EXISTING] [REDIRECT] [WITHOUT ROLLING FORWARD] [WITHOUT PROMPTING]

COMMAND PARAMETERS

The following parameters have been added: REPLACE EXISTING, REDIRECT,
CONTINUE and ABORT.

REPLACE EXISTING
          If a database with the same alias as the
          target-database-alias already exists, this parameter tells
          the restore utility to replace the existing database with
          the restored database.  This is useful when writing scripts
          containing the RESTORE DATABASE command, because the command
          line processor will not prompt you to instruct it whether
          the existing database should be deleted.  If you specify the
          WITHOUT PROMPTING parameter, there is no need to specify
          REPLACE EXISTING.  (However, WITHOUT PROMPTING does more
          than REPLACE EXISTING.  It will make the command fail in
          case there are any actions that would normally require user
          intervention.)

REDIRECT
          Specifies that the restore is a redirected one.  A RESTORE
          DATABASE command with this parameter is the first step of a
          redirected restore.  It should be followed by one or more
          SET TABLESPACE CONTAINERS commands, and finally by a RESTORE
          DATABASE command with the CONTINUE parameter.

CONTINUE
          Indicates to the restore utility that the containers have
          now been redefined and that the final step in the redirected
          restore should be performed.

ABORT
          Stops the redirected restore.  Useful in the case an error
          has occurred that would require one or more steps to be
          repeated.  After RESTORE DATABASE ...  ABORT has been
          issued, the entire set of steps of a redirected restore must
          be repeated, starting with a RESTORE DATABASE ...  REDIRECT
          command.

A TYPICAL REDIRECTED RESTORE SCENARIO:  Assuming that the database
alias of the database being restored is MYDB, a typical use of the
above commands would involve the following sequence of actions:

1.  Issue a RESTORE DATABASE command with REDIRECT parameter, for
    example:

          RESTORE DB MYDB REPLACE EXISTING REDIRECT

    NOTE:  Any time after a successful completion of step 1 and before
           issuing RESTORE DB MYDB CONTINUE (in step 3), you can abort
           the restore by issuing the following command:

                 RESTORE DB MYDB ABORT

2.  After a successful execution of step 1, issue a SET TABLESPACE
    CONTAINERS command for each tablespace whose containers must be
    redefined, for example:

          SET TABLESPACE CONTAINERS FOR 5 USING
             (FILE 'F:\TS3CON1' 20000, FILE 'F:\TS3CON2' 20000)

    To verify that the restored database's containers are the ones as
    specified in this step, use the LIST TABLESPACE CONTAINERS
    command.

3.  After a successful execution of steps 1 and 2, issue the command

          RESTORE DB MYDB CONTINUE

    which is the final step of the redirected restore.

4.  If step 3 has failed, or if you stopped the restore with RESTORE
    DB MYDB ABORT, you must start the redirected restore from step 1
    all over again.


8.6  NLS Additions

Code support for Latvia, Lithuania, and Estonia has been added to DB2
for OS/2 and DB2 for AIX V2.1.2. products.  The following tables list
the locales, code pages and date time formats for each country:

1.  For Country Code and Code Page Support tables:

        Locale  Code Set  Code Page  CountryCode   Country/Language
       -----------------------------------------------------------------------
        Lv_LV   IBM-921     921         371         Latvia/Latvian
        Lt_LT   IBM-921     921         370         Lithuania/Lithuanian
        Et_EE   IBM-922     922         372         Estonia/Estonian

    NOTE:  Note that the last two characters of locale name indicate
           territory.

2.  For Date and Time Formats table:

                     Local       Local      Default        Input
                     Date        Time       Output         Date
     Country code    Format      Format     Date Format    Formats
     -------------------------------------------------------------------------
     372 Estonia     dd-mm-yyyy   JIS       LOC            LOC, USA, EUR, ISO
     371 Latvia      yyyy.dd.mm   JIS       LOC            LOC, USA, EUR, ISO
     370 Lithuania   yyyy.mm.dd   JIS       LOC            LOC, USA, EUR, ISO


8.7  DB2 Support for Java Code Development

You can now develop Java applications and applets that access live
data from your DB2 databases!  With Version 2.1.2, DB2 adds support
for the Sunsoft Java Database Connectivity (JDBC) APIs for database
access.  JDBC APIs are similar to ODBC APIs, providing a standard way
of accessing databases from Java code.

DB2 provides a JDBC driver to handle JDBC API calls from the
client Java code. You can use this support to build both:

o   Java applications, which rely on the DB2 Client Application
    Enabler (CAE) to connect to DB2.
o   Java applets, which do not require any other DB2 component code on
    the client.

Add this to Java's portability, and you have the potential to deliver
DB2 access to clients on multiple platforms, requiring only a
Java-enabled web browser!

DB2's Java support is available on the following platforms:

o   Windows NT 3.51 or later
o   Windows95
o   OS/2 Warp 3.0 or later
o   AIX 3.2.5 (applet server only), and 4.1 or later
o   Solaris 2.5 or later.

For more information about developing DB2 applications in Java, see
DB2JAVA.HTM (HTML version) or DB2JAVA.TXT (flat text).  You can find
these files in the SQLLIB directory where DB2 is installed.


9.  Miscellaneous

9.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.                           **
  **                                                                   **
  ***********************************************************************
270         0           4532        0           0           0           0           0   `
8           68          678         1406        2172        2358        2552        2742        4532        copyright db2_02_01.sdk.c.al db2_02_01.sdk.c.size db2_02_01.sdk.c.prereq db2_02_01.sdk.cobol.prereq db2_02_01.sdk.cli.prereq db2_02_01.sdk.c.inventory lpp.README k)   $         D2D2[2                ./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_921             921     /* Codepage 921 - Latvia, Lithuania    */
#define SQL_CP_922             922     /* Codepage 922 - Estonia              */
#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_1126            1126    /* Codepage 1126 - Windows Korean Std  */
#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_1351            1351    /* Codepage 1351 - Japanese            */
#define SQL_CP_1362            1362    /* Codepage 1362 - Korean Windows      */
#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  897 + 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_1363            1363    /* Codepage 1363 - Korean Windows      */
#define SQL_CP_1381            1381    /* Codepage 1115 +1380 - China GB      */
#define SQL_CP_1383            1383    /* Codepage  367 +1382 - Chinese GB    */

#define SQL_CP_5039            5039    /* Codepage  1041 + 1351 - Japanese    */
/* 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_KSC2_PC            12      /* Korean Windows                      */
#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

/* Values used for option[n].val when option[n].type is SQL_CONNECT_OPT       */
#define SQL_DEFERRED_PREPARE_YES 1     /* Dynamic SQL statements will be      */
                                       /* chained.                            */
#define SQL_DEFERRED_PREPARE_NO 2      /* Dynamic SQL statements will not be  */
                                       /* chained.                            */
#define SQL_DEFERRED_PREPARE_ALL 3     /* Dynamic SQL statements will be      */
                                       /* chained in all cases.  The          */
                                       /* application must not allocate host  */
                                       /* vars a FETCH SQLDA until after the  */
                                       /* OPEN statement for the cursor.      */

/* 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                */

/* Application Context apis                                                   */


#define SQL_CTX_ORIGINAL 0                 /* serial access                   */
#define SQL_CTX_MULTI_MANUAL 1             /* concurrent access               */
SQL_API_RC SQL_API_FN                      /* Set Application Context         */
  sqleSetTypeCtx (
        long);                             /* options                         */


#define SQL_CTX_BEGIN_ALL 0                /* create & attach                 */
#define SQL_CTX_CREATE_ONLY 1              /* create only                     */
SQL_API_RC SQL_API_FN                      /* Create Application Context      */
  sqleBeginCtx (
        void **,                           /* pointer to ctx                  */
        long,                              /* lOptions                        */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


#define SQL_CTX_END_ALL 0                  /* detach & free                   */
#define SQL_CTX_FREE_ONLY 1                /* free only                       */
SQL_API_RC SQL_API_FN                      /* Destroy Application Context     */
  sqleEndCtx (
        void **,                           /* pointer to ctx                  */
        long,                              /* lOptions                        */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


SQL_API_RC SQL_API_FN                      /* Attach to Application Context   */
  sqleAttachToCtx (
        void *,                            /* pointer to ctx                  */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


SQL_API_RC SQL_API_FN                      /* Detach Application Context      */
  sqleDetachFromCtx (
        void *,                            /* pointer to ctx                  */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


SQL_API_RC SQL_API_FN                      /* Destroy Application Context     */
  sqleGetCurrentCtx (
        void **,                           /* pointer to ctx                  */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


SQL_API_RC SQL_API_FN                      /* Interrupt Context               */
  sqleInterruptCtx (
        void *,                            /* pointer to ctx                  */
        void *,                            /* reserved                        */
        struct sqlca *);                   /* SQLCA                           */


/* 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 */
morkpV   $        g E2E2[2           g     ./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
#define SQLA_EXECIMMD_ASYNC_COMMIT 52
#define SQLA_EXECUTE_ASYNC_COMMIT 53
#define SQLA_CMPDEXEC_ASYNC_COMMIT 54
#define SQLA_EXECIMMD_COMMIT   55
#define SQLA_EXECUTE_COMMIT    56
#define SQLA_CMPDEXEC_COMMIT   57
#define SQLA_CMPDEXEC_NA_ASYNC 58
#define SQLA_CMPDEXEC_NA_COMMIT 59
#define SQLA_CMPDEXEC_NA_DIAG  60
#define SQLA_CMPDEXEC_NA_ASYNC_COMMIT 61
#define SQLA_CMPDEXEC_NA_ASYNC_DIAG 62
#define SQLA_CMPDEXEC_NA_COMMIT_DIAG 63
#define SQLA_CMPDEXEC_NA_A_C_D 64
#define SQLA_CLOSE_OPEN        65
#define SQLA_CLOSE_OPEN_ASYNC  66
#define SQLA_CLOSEREL_OPEN_ASYNC 67
#define SQLA_CLOSEREL_OPEN     68

/* 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                           */

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 */
 kf   $          E2E2[2         ,'        ./usr/lpp/db2_02_01/include/sqlca.h .h .                    $          /******************************************************************************
 *
 * Source File Name = SQLCA.H
 *
 * (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:
 *              SQL Communications Area
 *
 * Operating System = Common C Include File
 *
 *****************************************************************************/


#ifndef  SQLCODE                           /* Permit Duplicate Includes  */

#include "sqlsystm.h"                      /* System dependent defines   */

#if (defined(DB2OS2) || defined(DB2NT))
#pragma pack(4)
#elif (defined(DB2WIN))
#pragma pack(2)
#elif (defined(DB2MAC))
#if (defined(DB2PPC))
#pragma align 4
#elif (defined(DB268K))
#pragma align 2
#endif
#elif (defined(DB2HP) || defined(DB2SNI) || defined(SQLSGI)) 
                                              
#elif (defined(DB2SUN))                                          
#pragma options align=natural
#elif (defined(DB2AIX))                                          
#pragma options align=power
#endif

/* SQL Communication Area - SQLCA */
/* _SQLOLDCHAR defaults to 'char'.  See sqlsystm.h for details. */

SQL_STRUCTURE  sqlca
{
   _SQLOLDCHAR    sqlcaid[8];           /* Eyecatcher = 'SQLCA   '        */
   long           sqlcabc;              /* SQLCA size in bytes = 136      */
   long           sqlcode;              /* SQL return code                */
   short          sqlerrml;             /* Length for SQLERRMC            */
   _SQLOLDCHAR    sqlerrmc[70];         /* Error message tokens           */

   _SQLOLDCHAR    sqlerrp[8];           /* Diagnostic information         */

   long           sqlerrd[6];           /* Diagnostic information         */
   _SQLOLDCHAR    sqlwarn[11];          /* Warning flags                  */

   _SQLOLDCHAR    sqlstate[5];          /* State corresponding to SQLCODE */

};

#define   SQLCODE        sqlca.sqlcode
#define   SQLWARN0       sqlca.sqlwarn[0]
#define   SQLWARN1       sqlca.sqlwarn[1]
#define   SQLWARN2       sqlca.sqlwarn[2]
#define   SQLWARN3       sqlca.sqlwarn[3]
#define   SQLWARN4       sqlca.sqlwarn[4]
#define   SQLWARN5       sqlca.sqlwarn[5]
#define   SQLWARN6       sqlca.sqlwarn[6]
#define   SQLWARN7       sqlca.sqlwarn[7]
#define   SQLWARN8       sqlca.sqlwarn[8]
#define   SQLWARN9       sqlca.sqlwarn[9]
#define   SQLWARNA       sqlca.sqlwarn[10]


/* sqlerrd tokens updated when compound SQL statements processed */

#define   SQL_CMP_NA_ERRORS       1
#define   SQL_CMP_ROWS_AFFECTED   2
#define   SQL_CMP_STMTS_COMPLETED 3
#define   SQL_CMP_REF_INT_ROWS    4


/* sqlerrd tokens updated when CONNECT statements processed */

#define   SQL_CONNECT_DB_APP2DB_CONVFACTOR     0
#define   SQL_CONNECT_DB_DB2APP_CONVFACTOR     1
#define   SQL_CONNECT_DB_UPDATEABILITY_IN_UOW  2
#define   SQL_CONNECT_DB_COMMIT_TYPE           3


/* Values returned for sqlerrd[SQL_CONNECT_DB_UPDATEABILITY_IN_UOW]     */

#define   SQL_DB_UPDATEABLE                    1
#define   SQL_DB_READ_ONLY                     2


/* Values returned for sqlerrd[SQL_CONNECT_DB_COMMIT_TYPE]       */

#define   SQL_DB_ONE_PHASE_COMMIT              1
#define   SQL_DB_ONE_PHASE_READ_ONLY           2
#define   SQL_DB_TWO_PHASE_COMMIT              3

#if (defined(DB2OS2) || defined(DB2NT) || defined(DB2WIN))
#pragma pack()
#elif (defined(DB2MAC))
#pragma align
#elif (defined(DB2HP) || defined(DB2SNI))

#elif (defined(DB2AIX) || defined(DB2SUN))                       
#pragma options align=reset
#endif

#endif /* SQLCODE */
*,   k   $        =  E2E2[2           =      ./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 kv   $        Р  E2E2[2            Р      ./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 */
kk   $        ݚ  E2E2[2         8  ݚ      ./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_E750            -750    /* rename table error                  */

#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_E4300           -4300   /* Java support not installed          */
#define SQL_RC_E4301           -4301   /* Java startup, comm, shutdown        */
                                       /* failed                              */
#define SQL_RC_E4302           -4302   /* Java unclassificed exception        */
#define SQL_RC_E4303           -4303   /* Java cannot parse class!method      */
#define SQL_RC_E4304           -4304   /* Java cannot instantiate class       */
#define SQL_RC_E4305           -4305   /* Java internal error code            */
#define SQL_RC_E4306           -4306   /* Java cannot call method             */
#define SQL_RC_E4307           -4307   /* Java call problems                  */
#define SQL_RC_E4308           -4308   /* DB2CLI.PROCEDURES has wrong schema  */

#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 */
08 k   $        = F2F2[2         X  =     ./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_SCO       "QDB2/SCO"
#define SQL_DBMS_DB2_SGI       "QDB2/SGI"
#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                          */
#define SQL_PROTOCOL_SOCKS     0x8     /* TCPIP using SOCKS                   */

/* 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                        */

/* Security Type for TCPIP                                                    */
#define SQL_TCPIP_SECURITY_NONE        0    /* None                           */
#define SQL_TCPIP_SECURITY_SOCKS       1    /* TCPIP SOCKS Support            */

/* 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      */
#define SQL_DEFERRED_PREPARE   6       /* 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_CTX_INV_PARM -1441           /* Ctx parm invalid              */
#define SQLE_RC_CTX_NOTINUSE -1442           /* App Ctx not in use            */
#define SQLE_RC_CTX_USING -1443              /* Already using Ctx             */
#define SQLE_RC_CTX_INUSE -1444              /* App Ctx in use                */
#define SQLE_RC_CTX_NO_CTX -1445             /* Thread does not have context  */

#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_INVSTYPE_TCP -1461           /* Invalid TCPIP Security        */

#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                        */

#define SQLE_RC_JAVA_NOTSUPP -4300           /* Java not installed or not     */
                                             /* supported on this platform    */
#define SQLE_RC_JAVA_INTERP_FAIL -4301       /* Java interpreter startup      */
                                             /* communication/shutdown        */
                                             /* failure                       */
#define SQLE_RC_JAVA_UNCLASSIFIED -4302      /* Java STP/UDF <name>:          */
                                             /* unclassified exception:       */
                                             /* <msg>                         */
#define SQLE_RC_JAVA_PATH_PARSE -4303        /* Java STP/UDF <name>: cannot   */
                                             /* parse class!method in <path>  */
#define SQLE_RC_JAVA_LOAD_CLASS -4304        /* Java STP/UDF <name>: cannot   */
                                             /* load/instantiate Java class   */
                                             /* <name>                        */
#define SQLE_RC_JAVA_INTERNAL -4305          /* Java STP/UDF <name>:          */
                                             /* internal error code <id>      */
#define SQLE_RC_JAVA_METHODLOOKUP -4306      /* Java STP/UDF <name>: cannot   */
                                             /* find matching Java method     */
                                             /* <name>                        */
#define SQLE_RC_JAVA_ARGS -4307              /* Java STP/UDF <name>:          */
                                             /* argument problems: reason     */
                                             /* code <num>                    */
#define SQLE_RC_DARI_TABLE_MODIFIED -4308    /* DB2CLI.PROCEDURES structure   */
                                             /* has been modified             */

/******************************************************************************
** 
** 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@ #  $         G2G2[2                ./usr/lpp/db2_02_01/include/sqlmon.h h .                    $          /******************************************************************************
 *
 * Source File Name = SQLMON.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:
 *              Database Monitor - Constants
 *              Database Monitor - Structures
 *              Database Monitor - Function Prototypes
 *
 * Operating System: Common C Include File
 *
 *****************************************************************************/

#ifndef  SQL_H_SQLMON
   #define SQL_H_SQLMON            /* Permit duplicate Includes */

#ifdef __cplusplus
extern "C" {
#endif

#include "sqlsystm.h"              /* System dependent defines     */
#include "sqlca.h"                 /* SQL API - Communication Area */
#include "sqlenv.h"                /* DB2 Environment commands     */

#if (defined(DB2OS2) || defined(DB2NT))
#pragma pack(4)
#elif (defined(DB2WIN))
#pragma pack(2)
#elif (defined(DB2MAC))
#if (defined(DB2PPC))
#pragma align 4
#elif (defined(DB268K))
#pragma align 2
#endif
#elif (defined(DB2HP) || defined(DB2SNI))

#elif (defined(DB2SUN))
#pragma options align=natural
#elif (defined(DB2AIX))
#pragma options align=power
#endif

/******************************************************************************/
/* Database Monitor Version Constant                                          */
/******************************************************************************/

#define SQLM_DBMON_VERSION1  1
#define SQLM_DBMON_VERSION2  2

/******************************************************************************/
/* Snapshot Monitor Collected Information types                               */
/* Structure identifier in Snapshot buffer (info_type element)                */
/******************************************************************************/

#define SQLM_DB2_SS                '1'   /* DB2 information                   */
#define SQLM_DBASE_SS              '2'   /* Database information              */
#define SQLM_APPL_SS               '3'   /* Application information           */
#define SQLM_APPLINFO_SS           '4'   /* Summary Application information   */
#define SQLM_TABLE_HEADER_SS       '5'   /* Table Header information          */
#define SQLM_TABLE_SS              '6'   /* Table information                 */
#define SQLM_DBASE_LOCK_SS         '7'   /* Database Lock information         */
#define SQLM_APPL_LOCK_SS          '8'   /* Application Lock information      */
#define SQLM_LOCK_SS               '9'   /* Lock information                  */
#define SQLM_DCS_APPLINFO_SS       'A'   /* DCS Application info              */
#define SQLM_TABLESPACE_HEADER_SS  'B'   /* Tablespace Header information     */
#define SQLM_TABLESPACE_SS         'C'   /* Tablespace information            */

/******************************************************************************/
/* level of data to collect                                                   */
/******************************************************************************/

#define SQLMA_DB2                 1      /* DB2 related information           */
#define SQLMA_DBASE               2      /* database related information      */
#define SQLMA_APPL                3      /* appl info - by appl_id            */
#define SQLMA_AGENT_ID            4      /* appl info by agentid              */
#define SQLMA_DBASE_TABLES        5      /* table related info for a database */
#define SQLMA_DBASE_APPLS         6      /* appl related info for a database  */
#define SQLMA_DBASE_APPLINFO      7      /* appl related info for a database  */
#define SQLMA_DBASE_LOCKS         8      /* lock related info for a database  */
#define SQLMA_DBASE_ALL           9      /* db info for all database in DB2   */
#define SQLMA_APPL_ALL           10      /* appl info for all apps            */
#define SQLMA_APPLINFO_ALL       11      /* summary appl info for all appls   */
#define SQLMA_DCS_APPLINFO_ALL   12      /* summary appl info for all appls   */
#define SQLMA_DBASE_TABLESPACES  13      /* tablespace related info for dbase */

/******************************************************************************/
/* size definitions                                                           */
/******************************************************************************/

#define SQLM_APPLID_SZ        32          /* size of the application id       */
#define SQLM_SEQ_SZ            4          /* sequence number size             */
#define SQLM_SH_IDENT_SZ       8          /* Small identifier size            */
#define SQLM_IDENT_SZ         20          /* General identifier size          */
#define SQLM_OBJECT_SZ        36          /* object size in sqlma structure   */
#define SQLM_RESERVED_SZ      32          /* Reserved space size              */
#define SQLM_DBPATH_SZ       256          /* Database Path size               */

/******************************************************************************/
/* Information group state switches                                           */
/******************************************************************************/

#define SQLM_OFF    0              /* Turn monitoring group OFF               */
#define SQLM_ON     1              /* Turn monitoring group ON                */
#define SQLM_HOLD   2              /* leave monitoring group in current state */

/******************************************************************************/
/* Information groups array indexes                                           */
/******************************************************************************/

#define SQLM_UOW_SW          0           /* Select Unit of Work information   */
#define SQLM_STATEMENT_SW    1           /* Select Statement information      */
#define SQLM_TABLE_SW        2           /* Select Table information          */
#define SQLM_BUFFER_POOL_SW  3           /* Select Buffer Pool information    */
#define SQLM_LOCK_SW         4           /* Select Lock information           */
#define SQLM_SORT_SW         5           /* Select Sort information           */

#define SQLM_NUM_GROUPS      6           /* number of monitor groups          */

/******************************************************************************/
/* Statement Types                                                            */
/******************************************************************************/
#define SQLM_STATIC            1         /* Static statement                  */
#define SQLM_DYNAMIC           2         /* Dynamic statement                 */
#define SQLM_NON_STMT          3         /* Operation other than an SQL stmt  */
#define SQLM_STMT_TYPE_UNKNOWN 4         /* Unknown statement type            */

/******************************************************************************/
/* Statement Operation Types                                                  */
/******************************************************************************/
#define SQLM_PREPARE            1        /* Prepare operation                 */
#define SQLM_EXECUTE            2        /* Execute operation                 */
#define SQLM_EXECUTE_IMMEDIATE  3        /* Execute Immediate operation       */
#define SQLM_OPEN               4        /* Open operation                    */
#define SQLM_FETCH              5        /* Fetch operation                   */
#define SQLM_CLOSE              6        /* Close operation                   */
#define SQLM_DESCRIBE           7        /* Describe operation                */
#define SQLM_STATIC_COMMIT      8        /* Static Commit operation           */
#define SQLM_STATIC_ROLLBACK    9        /* Static Rollback operation         */
#define SQLM_FREE_LOCATOR      10        /* Free Locator operation            */

/******************************************************************************/
/* Table Types                                                                */
/******************************************************************************/
#define SQLM_USER_TABLE      1           /* User table                        */
#define SQLM_DROPPED_TABLE   2           /* Dropped user table                */
#define SQLM_TEMP_TABLE      3           /* Temporary table                   */
#define SQLM_CATALOG_TABLE   4           /* System Catalog table              */
#define SQLM_REORG_TABLE     5           /* Reorg table                       */

/******************************************************************************/
/* lock modes                                                                 */
/******************************************************************************/

#define SQLM_LNON  0                  /*  No Lock                             */
#define SQLM_LOIS  1                  /*  Intention Share Lock                */
#define SQLM_LOIX  2                  /*  Intention Exclusive Lock            */
#define SQLM_LOOS  3                  /*  Share Lock                          */
#define SQLM_LSIX  4                  /*  Share with Intention Exclusive Lock */
#define SQLM_LOOX  5                  /*  Exclusive Lock                      */
#define SQLM_LOIN  6                  /*  Intent None (For Dirty Read)        */
#define SQLM_LOOZ  7                  /*  Super Exclusive Lock                */
#define SQLM_LOOU  8                  /*  Update Lock                         */

/******************************************************************************/
/* application status                                                         */
/******************************************************************************/

#define SQLM_CONNECTPEND          1            /* connect pending             */
#define SQLM_CONNECTED            2            /* connect completed           */
#define SQLM_UOWEXEC              3            /* UOW executing               */
#define SQLM_UOWWAIT              4            /* UOW waiting                 */
#define SQLM_LOCKWAIT             5            /* lock wait                   */
#define SQLM_COMMIT_ACT           6            /* commit active               */
#define SQLM_ROLLBACK_ACT         7            /* rollback active             */
#define SQLM_RECOMP               8            /* recompiling a plan          */
#define SQLM_COMP                 9            /* compiling a SQL statement   */
#define SQLM_INTR                10            /* request interrupted         */
#define SQLM_DISCONNECTPEND      11            /* disconnect pending          */
#define SQLM_TPREP               12            /* Prepared transaction        */
#define SQLM_THCOMT              13            /* heuristically committed     */
#define SQLM_THABRT              14            /* heuristically rolled back   */
#define SQLM_TEND                15            /* Transaction ended           */
#define SQLM_CREATE_DB           16            /* Creating Database           */
#define SQLM_RESTART             17            /* Restarting a Database       */
#define SQLM_RESTORE             18            /* Restoring a Database        */
#define SQLM_BACKUP              19            /* Performing a Backup         */
#define SQLM_LOAD                20            /* Performing a fast load      */
#define SQLM_UNLOAD              21            /* Performing a fast unload    */
#define SQLM_IOERROR_WAIT        22            /* Wait to disable tablespace  */
#define SQLM_QUIESCE_TABLESPACE  23            /* Quiescing a tablespace      */

/******************************************************************************/
/* database status                                                            */
/******************************************************************************/

#define SQLM_DB_ACTIVE          0              /* Database is active          */
#define SQLM_DB_QUIESCE_PEND    1              /* Quiesce is pending for DB   */
#define SQLM_DB_QUIESCED        2              /* Database has been quiesced  */

/******************************************************************************/
/* database manager status                                                    */
/******************************************************************************/

#define SQLM_DB2_ACTIVE          0             /* DB2 is active               */
#define SQLM_DB2_QUIESCE_PEND    1             /* Quiesce is pending for DB2  */
#define SQLM_DB2_QUIESCED        2             /* DB2 has been quiesced       */

/******************************************************************************/
/* UOW completion status                                                      */
/******************************************************************************/

#define SQLM_UOWCOMMIT       1       /* UOW issued a commit                   */
#define SQLM_UOWROLLBACK     2       /* UOW issued a rollback                 */
#define SQLM_UOWDEADLOCK     3       /* UOW was rolled back due to a deadlock */
#define SQLM_UOWABEND        4       /* UOW was rolled back due to an abend   */
#define SQLM_APPL_END        5       /* application normal termination        */
#define SQLM_UOWLOCKTIMEOUT  6       /* UOW was rolled back from lock timeout */

/******************************************************************************/
/* lock object type                                                           */
/******************************************************************************/

#define SQLM_TABLE_LOCK       1          /* table lock type                   */
#define SQLM_ROW_LOCK         2          /* table row lock type               */
#define SQLM_INTERNAL_LOCK    3          /* Internal lock type                */
#define SQLM_TABLESPACE_LOCK  4          /* Tablespace lock type              */

/******************************************************************************/
/* lock status                                                                */
/******************************************************************************/

#define SQLM_LRBGRNT      1                     /*  Granted State             */
#define SQLM_LRBCONV      2                     /*  Converting state          */

/******************************************************************************/
/* client communications protocols                                            */
/******************************************************************************/
#define SQLM_PROT_APPC         SQL_PROTOCOL_APPC    /* appc                   */
#define SQLM_PROT_NETBIOS      SQL_PROTOCOL_NETB    /* netbios                */
#define SQLM_PROT_APPN         SQL_PROTOCOL_APPN    /* appn                   */
#define SQLM_PROT_TCPIP        SQL_PROTOCOL_TCPIP   /* tcp/ip                 */
#define SQLM_PROT_CPIC         SQL_PROTOCOL_CPIC    /* APPC using CPIC        */
#define SQLM_PROT_IPXSPX       SQL_PROTOCOL_IPXSPX  /* ipx/spx                */
#define SQLM_PROT_LOCAL        SQL_PROTOCOL_LOCAL   /* local client           */
#define SQLM_PROT_NPIPE        SQL_PROTOCOL_NPIPE   /* Named pipe             */


/******************************************************************************/
/* client platforms                                                           */
/******************************************************************************/
#define SQLM_PLATFORM_UNKNOWN         0         /* Unknown client platform    */
#define SQLM_PLATFORM_OS2             1         /* OS/2 client                */
#define SQLM_PLATFORM_DOS             2         /* DOS client                 */
#define SQLM_PLATFORM_WINDOWS         3         /* Windows client             */
#define SQLM_PLATFORM_AIX             4         /* AIX client                 */
#define SQLM_PLATFORM_NT              5         /* NT client                  */
#define SQLM_PLATFORM_HP              6         /* HP client                  */
#define SQLM_PLATFORM_SUN             7         /* Sun client                 */
#define SQLM_PLATFORM_MVS_DRDA        8         /* MVS client via DRDA        */
#define SQLM_PLATFORM_AS400_DRDA      9         /* AS400 client via DRDA      */
#define SQLM_PLATFORM_VM_DRDA        10         /* VM client via DRDA         */
#define SQLM_PLATFORM_VSE_DRDA       11         /* VSE client via DRDA        */
#define SQLM_PLATFORM_UNKNOWN_DRDA   12         /* Unknown DRDA Client        */
#define SQLM_PLATFORM_SNI            13         /* Siemens Nixdorf            */
#define SQLM_PLATFORM_MAC            14         /* Macintosh Client           */
#define SQLM_PLATFORM_WINDOWS95      15         /* Windows 95                 */
#define SQLM_PLATFORM_SCO            16         /* SCO                        */
#define SQLM_PLATFORM_SGI            17         /* Silicon Graphic            */


/******************************************************************************/
/* Event Monitor Type Identifiers                                             */
/******************************************************************************/
#define SQLM_EVENT_DB               1  /* Database Event                      */
#define SQLM_EVENT_CONN             2  /* Connection Event                    */
#define SQLM_EVENT_TABLE            3  /* Table Event                         */
#define SQLM_EVENT_STMT             4  /* Statement Event                     */
#define SQLM_EVENT_STMTTEXT         5  /* Dynamic Statement Text Event        */
#define SQLM_EVENT_XACT             6  /* Transaction Event                   */
#define SQLM_EVENT_DEADLOCK         7  /* Deadlock Event                      */
#define SQLM_EVENT_DLCONN           8  /* Deadlock Connection Event           */
#define SQLM_EVENT_TABLESPACE       9  /* Tablespace Event                    */
#define SQLM_EVENT_DBHEADER        10  /* Database Header Event               */
#define SQLM_EVENT_START           11  /* Event monitor start Event           */
#define SQLM_EVENT_CONNHEADER      12  /* Connection Header Event             */
#define SQLM_EVENT_OVERFLOW        13  /* Overflow Event                      */

/******************************************************************************/
/* Event Monitor Byte Order Identifiers                                       */
/******************************************************************************/
#define SQLM_LITTLE_ENDIAN      0         /* Little endian server             */
#define SQLM_BIG_ENDIAN        -1         /* Big endian server                */

/******************************************************************************/
/* Database Monitor Error Constants                                           */
/******************************************************************************/

#define SQLM_RC_INV_PTR         -1601 /* Parameter is a NULL pointer          */
#define SQLM_RC_INV_OBJ_TYPE    -1602 /* invalid obj_type in sqlma struct     */
#define SQLM_RC_NOT_SPECIFIED   -1603 /* dbname/appl_id not specified in sqlma*/
#define SQLM_RC_NOT_NULL_TERM   -1604 /* dbname/appl_id not NULL terminated   */
#define SQLM_RC_DBNOACT         +1605 /* database is not active               */
#define SQLM_RC_BUFFER_FULL     +1606 /* DBMON buffer area is full            */
#define SQLM_RC_NOMEM           -1607 /* not enough working memory for DBMON  */
#define SQLM_RC_DUPLICATE_DB    +1608 /* duplicate database aliases           */
#define SQLM_RC_REMOTE_DB       -1609 /* cannot monitor remote databases      */
#define SQLM_RC_INV_VALUE       -1610 /* invalid value for input parameter    */
#define SQLM_RC_NO_DATA         +1611 /* No data returned by Database Monitor */
#define SQLM_RC_TOO_MANY_OBJECTS -1623/* Too many objects for this request.   */
#define SQLM_RC_MULTIPLE_NODES  -1624 /* Databases in a sqlmonsz or sqlmonss  */
                                      /* call reside at different nodes.      */

/******************************************************************************/
/* Database Monitor Snapshot Data Structures                                  */
/******************************************************************************/

/******************************************************************************/
/*  SQL Monitor Area object definition                                        */
/******************************************************************************/

typedef struct sqlm_obj_struct
{
   unsigned long agent_id;                        /* agent id                 */
   unsigned long obj_type;                        /* type of object           */
   _SQLOLDCHAR   object[SQLM_OBJECT_SZ];          /* object name              */
}sqlm_obj_struct;

/******************************************************************************/
/*  SQL Monitor Area                                                          */
/******************************************************************************/
typedef struct sqlma
{
   unsigned long obj_num;                         /* number obj_vars elements */
   sqlm_obj_struct obj_var[1];                    /* object details           */
}sqlma;

/******************************************************************************/
/* macro for estimating SQLMA size                                            */
/******************************************************************************/

#define SQLMASIZE(n) (sizeof(struct sqlma)+(n-1)*(sizeof(struct sqlm_obj_struct)) )

/******************************************************************************/
/* time stamp data structure                                                  */
/******************************************************************************/

typedef struct sqlm_timestamp
{
  unsigned long seconds;          /* time in seconds since Jan.1,1970         */
  unsigned long microsec;         /* microseconds, range 0 to 999999          */
}sqlm_timestamp;

/******************************************************************************/
/* Elpased time stamp data structure (for CPU times)                          */
/******************************************************************************/

typedef struct sqlm_time
{
  unsigned long seconds;           /* elpsed seconds                          */
  unsigned long microsec;          /* elpased microseconds, range 0 to 999999 */
}sqlm_time;


/******************************************************************************/
/* State information for each monitor group                                   */
/******************************************************************************/
typedef struct sqlm_recording_group
{
  unsigned long  input_state;        /* input state to set group              */
  unsigned long  output_state;       /* returned current state                */
  sqlm_timestamp start_time;         /* monitor group start time              */
}sqlm_recording_group;

/******************************************************************************/
/* collection count data structure returned from get monitor info             */
/******************************************************************************/

typedef struct sqlm_collected
{
  unsigned long  size;            /* size of sqlm_collected                   */
  unsigned long  db2;             /* 1 if db2 info collected, 0 otherwise     */
  unsigned long  databases;       /* # databases for which info was collected */
  unsigned long  table_databases; /* # databases for which table info was     */
                                  /* collected                                */
  unsigned long  lock_databases;  /* # databases for which lock info was      */
                                  /* collected                                */
  unsigned long  applications;    /* # appls for which info was collected     */
  unsigned long  applinfos;       /* # appls for which summary info was coll. */
  unsigned long  dcs_applinfos;   /* # DDCS appls for which info was collected*/
  unsigned long  server_db2_type; /* Server DB2 Type                          */
  sqlm_timestamp time_stamp;      /* time stamp when Snapshot was taken       */
  sqlm_recording_group group_states[SQLM_NUM_GROUPS];
                                              /* current group states         */
  _SQLOLDCHAR    server_prdid[SQLM_IDENT_SZ]; /* product/version on server    */
  _SQLOLDCHAR    server_nname[SQLM_IDENT_SZ]; /* Config NNAME of server       */
  _SQLOLDCHAR    server_instance_name[SQLM_IDENT_SZ]; /*instance name of DB2  */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  unsigned long  tablespace_databases; /* # dbases for which tblspace info col*/
                                     /* was collected                         */
  unsigned long  server_version;       /* Version of server returning data    */
}sqlm_collected;

/******************************************************************************/
/* Application Identification Information                                     */
/******************************************************************************/

typedef struct sqlm_appl_id_info
{
  unsigned long  agent_id;                   /* agent id                      */
  unsigned long  appl_status;                /* Application Status            */
  unsigned long  codepage_id;                /* codepage/CCSID at node        */
                                             /* where app started             */
  sqlm_timestamp status_change_time;         /* last appl status change time  */
  _SQLOLDCHAR    appl_name[SQLM_IDENT_SZ];   /* Application Program Name      */
  _SQLOLDCHAR    appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  _SQLOLDCHAR    sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  _SQLOLDCHAR    auth_id[SQLM_IDENT_SZ];     /* Authorization Id              */
  _SQLOLDCHAR    client_nname[SQLM_IDENT_SZ]; /* Config NNAME of client       */
  _SQLOLDCHAR    client_prdid[SQLM_IDENT_SZ]; /* product/version on client    */
  _SQLOLDCHAR    input_db_alias[SQLM_IDENT_SZ]; /* Input Database Alias       */
  _SQLOLDCHAR    client_db_alias[SQLM_IDENT_SZ]; /* Client Database Alias     */
  _SQLOLDCHAR    db_name[SQLM_IDENT_SZ];     /* Database name                 */
  _SQLOLDCHAR    db_path[SQLM_DBPATH_SZ];    /* Database Path                 */
}sqlm_appl_id_info;

/******************************************************************************/
/* Application Id Information data structutre                                 */
/******************************************************************************/


typedef struct sqlm_applinfo
{
  unsigned long  size;                       /* size of sqlm_applinfo         */
  _SQLOLDCHAR    info_type;                  /* collected information type    */
  _SQLOLDCHAR    pad[3];                     /* padding for 4 byte alignment  */
  sqlm_appl_id_info   id_info;               /* Identification information    */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ]; /* reserved for future use       */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Client Identification Information                   */
  /****************************************************************************/
  char           execution_id[SQLM_IDENT_SZ]; /* login ID */
  char           corr_token[SQLM_APPLID_SZ];  /* DRDA AS Correlation Token    */
  unsigned long  client_pid;           /* Process ID of client application    */
  unsigned short client_platform;      /* Platform of client application      */
  unsigned short client_protocol;      /* Communications protocol of client   */
  unsigned short country_code;         /* Country code of client application  */
  char           pad2[2];              /* Padding for 4 byte alignment        */
}sqlm_applinfo;

/******************************************************************************/
/* DCS Application Identification Information                                 */
/******************************************************************************/

typedef struct sqlm_dcs_applinfo
{
  unsigned long  size;                       /* size of sqlm_dcs_applinfo     */
  _SQLOLDCHAR    info_type;                  /* collected information type    */
  _SQLOLDCHAR    pad[3];                     /* padding for 4 byte alignment  */
  unsigned long  agent_id;                   /* agent id                      */
  unsigned long  codepage_id;                /* codepage/CCSID at node        */
                                             /* where app started             */
  _SQLOLDCHAR    appl_name[SQLM_IDENT_SZ];   /* Application Program Name      */
  _SQLOLDCHAR    appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  _SQLOLDCHAR    sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  _SQLOLDCHAR    auth_id[SQLM_IDENT_SZ];     /* Authorization Id              */
  _SQLOLDCHAR    client_nname[SQLM_IDENT_SZ]; /* Config NNAME of client       */
  _SQLOLDCHAR    client_prdid[SQLM_IDENT_SZ]; /* product/version on client    */
  _SQLOLDCHAR    client_db_alias[SQLM_IDENT_SZ]; /* Client Database Alias     */
  _SQLOLDCHAR    db_name[SQLM_IDENT_SZ];     /* Host Database name            */
  _SQLOLDCHAR    host_prdid[SQLM_IDENT_SZ];  /* Host Product id               */
  _SQLOLDCHAR    outbound_appl_id[SQLM_APPLID_SZ];   /* Outbound LUWID        */
  _SQLOLDCHAR    outbound_sequence_no[SQLM_SEQ_SZ];  /* Outbound sequence #   */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ]; /* reserved for future use       */
}sqlm_dcs_applinfo;


/******************************************************************************/
/* DB2 Related Snapshot Information                                           */
/******************************************************************************/

typedef struct sqlm_db2
{
  unsigned long  size;                  /* size of sqlm_db2                   */
  _SQLOLDCHAR    info_type;             /* collected information type         */
  _SQLOLDCHAR    pad1[3];               /* padding for 4 byte alignment       */

  /****************************************************************************/
  /* Sorting Information                                                      */
  /****************************************************************************/
  unsigned long  sort_heap_allocated;   /* Sort heap currently allocated      */
  unsigned long  post_threshold_sorts;  /* # sorts started after heap         */
                                        /* threshold exceeded                 */
  unsigned long  piped_sorts_requested; /* # of piped sorts requested         */
                                        /* by RDS to SLS                      */
  unsigned long  piped_sorts_accepted;  /* # of piped sorts accepted by SLS   */

  /****************************************************************************/
  /* Timestamps                                                               */
  /****************************************************************************/
  sqlm_timestamp db2start_time;          /* DB2START timestamp                */
  sqlm_timestamp last_reset;             /* Date/Time of Last Reset           */

  /****************************************************************************/
  /* Connection Information                                                   */
  /****************************************************************************/
  unsigned long  rem_cons_in;           /* Remote connects to target DB2      */
  unsigned long  rem_cons_in_exec;      /* Remote connects to target exec DB2 */
  unsigned long  local_cons;            /* Current Local Connections          */
  unsigned long  local_cons_in_exec;    /* Local connects curr exec in DB2    */
  unsigned long  con_local_dbases;      /* Local databases w/current connects */
  unsigned long  agents_registered;     /* Number of agents registered in DB2 */
  unsigned long  agents_waiting_on_token;   /* # of agents waiting on a token */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  DB2 Instance Status                                 */
  /****************************************************************************/
  unsigned long  db2_status;            /* status of the DB2 instance         */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  High Water Marks                                    */
  /****************************************************************************/
  unsigned long  agents_registered_top; /* agents_registered high water mark  */
  unsigned long  agents_waiting_top;    /* agents_waiting high water mark     */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  DB2 Instance Memory Usage Information               */
  /****************************************************************************/
  unsigned long  comm_private_mem;      /* Committed Private Memory           */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Agent Information                                   */
  /****************************************************************************/
  unsigned long idle_agents;            /* number of unassigned agents in pool*/

}sqlm_db2;

/******************************************************************************/
/* Database Related Snapshot Information                                      */
/******************************************************************************/

typedef struct sqlm_dbase
{
  unsigned long  size;                  /* size of sqlm_dbase                 */
  _SQLOLDCHAR    info_type;             /* collected information type         */
  _SQLOLDCHAR    pad1[3];               /* padding for 4 byte alignment       */
  _SQLOLDCHAR    input_db_alias[SQLM_IDENT_SZ]; /* Input Database Alias       */
  _SQLOLDCHAR    db_name[SQLM_IDENT_SZ];        /* Database name              */
  _SQLOLDCHAR    db_path[SQLM_DBPATH_SZ];       /* Database Path              */

  /****************************************************************************/
  /* Locking Information                                                      */
  /****************************************************************************/
  unsigned long  locks_held;             /* Locks currently held              */
  unsigned long  lock_waits;             /* Lock waits since 1st connect      */
  unsigned long  lock_wait_time;         /* Total time dbase waited on locks  */
  unsigned long  lock_list_in_use;       /* total lock list memory in use     */
  unsigned long  deadlocks;              /* Deadlocks since 1st db connect    */
  unsigned long  lock_escals;            /* lock escals since 1st db connect  */
  unsigned long  x_lock_escals;          /* X lock escals since 1st db connect*/
  unsigned long  locks_waiting;          /* Appls. currently waiting on locks */

  /****************************************************************************/
  /* Sorting Information                                                      */
  /****************************************************************************/
  unsigned long  sort_heap_allocated;    /* Total sort heap allocated         */
  unsigned long  total_sorts;            /* number of sorts since 1st connect */
  unsigned long  total_sort_time;        /* elapsed time spent in sorts       */
  unsigned long  sort_overflows;         /* number of sort overflows          */
  unsigned long  active_sorts;           /* sorts currently active            */

  /****************************************************************************/
  /* Buffer Pool Information                                                  */
  /****************************************************************************/
  unsigned long  pool_data_l_reads;      /* pool data logical reads since conn*/
  unsigned long  pool_data_p_reads;      /* pool data reads since 1st connect */
  unsigned long  pool_data_writes;       /* pool data writes since 1st connect*/
  unsigned long  pool_index_l_reads;     /* pool indx logical reads since conn*/
  unsigned long  pool_index_p_reads;     /* pool indx reads since 1st connect */
  unsigned long  pool_index_writes;      /* pool indx writes since 1st connect*/
  unsigned long  pool_read_time;         /* Buff pool read time since 1st conn*/
  unsigned long  pool_write_time;        /* Buff pool write time since 1st con*/

  unsigned long  files_closed;           /* files closed since first db conn  */

  /****************************************************************************/
  /* SQL statement counts                                                     */
  /****************************************************************************/
  unsigned long  commit_sql_stmts;       /* # of Commit SQL stmts since conn  */
  unsigned long  rollback_sql_stmts;     /* # of Rollback SQL stmts since conn*/
  unsigned long  dynamic_sql_stmts;      /* # of Dynamic SQL stmts since conn */
  unsigned long  static_sql_stmts;       /* # of Static SQL stmts since conn  */
  unsigned long  failed_sql_stmts;       /* # of Failed SQL stmts since conn  */
  unsigned long  select_sql_stmts;       /* # of SQL select stmts since conn  */
  unsigned long  ddl_sql_stmts;          /* # of data definition lang. stmts  */
  unsigned long  uid_sql_stmts;          /* # of update/insert/delete stmts   */

  /****************************************************************************/
  /* Internal counts                                                          */
  /****************************************************************************/
  unsigned long  int_auto_rebinds;       /* # of Auto Rebinds since 1st conn  */
  unsigned long  int_rows_deleted;       /* # of Casc. Deletes since 1st conn */
  unsigned long  int_rows_updated;       /* # of Set Null Deletes since conn  */
  unsigned long  int_commits;            /* # of int. Commits since 1st conn  */
  unsigned long  int_rollbacks;          /* # of int. Rollbacks since 1st conn*/
  unsigned long  int_deadlock_rollbacks; /* # of Rollbacks due to deadlock    */
                                         /*      since 1st connect            */

  /****************************************************************************/
  /* Row counts                                                               */
  /****************************************************************************/
  unsigned long  rows_deleted;           /* # of Rows Deleted since connect   */
  unsigned long  rows_inserted;          /* # of Rows Inserted since connect  */
  unsigned long  rows_updated;           /* # of Rows Updated since connect   */
  unsigned long  rows_selected;          /* # of Rows Selected since connect  */

  /****************************************************************************/
  /* Binds/Precompiles                                                        */
  /****************************************************************************/
  unsigned long  binds_precompiles;      /* # of Binds/Precomps since 1st conn*/

  /****************************************************************************/
  /* Timestamps                                                               */
  /****************************************************************************/
  sqlm_timestamp  db_conn_time;           /* Time of 1st database connection  */
  sqlm_timestamp  last_reset;             /* Date/Time of Last Reset          */
  sqlm_timestamp  last_backup;            /* Date/Time of Last Backup         */

  /****************************************************************************/
  /* Application connection counters                                          */
  /****************************************************************************/
  unsigned long  total_cons;             /* Connects since 1st db connect     */
  unsigned long  appls_cur_cons;         /* Appls currently connected         */
  unsigned long  appls_in_db2;           /* Appls executing in the DB2        */

  /****************************************************************************/
  /* Logging Information                                                      */
  /****************************************************************************/
  unsigned long  sec_log_used_top;       /* Maximum secondary log space used  */
  unsigned long  tot_log_used_top;       /* Maximum total log space used      */
  unsigned long  sec_logs_allocated;     /* Number of secondary logs allocated*/

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Database Status                                     */
  /****************************************************************************/
  unsigned long  db_status;             /* status of the Database             */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  lock information                                    */
  /****************************************************************************/
  unsigned long  lock_timeouts;        /* # of lock timeouts since 1st conn   */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  High Water Marks                                    */
  /****************************************************************************/
  unsigned long  connections_top;  /* high water mark for current connections */
  unsigned long  db_heap_top;      /* high water mark for database heap       */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Buffer Pool and I/O Information                     */
  /****************************************************************************/
  unsigned long  pool_async_data_reads;    /* asynchronous pool data reads    */
  unsigned long  pool_async_data_writes;   /* asynchronous pool data writes   */
  unsigned long  pool_async_index_writes;  /* asynchronous pool index writes  */
  unsigned long  pool_async_read_time;     /* total async read time           */
  unsigned long  pool_async_write_time;    /* total async write time          */
  unsigned long  pool_async_data_read_reqs; /* # async read requests          */
  unsigned long  pool_lsn_gap_clns;        /* LSN Gap cleaner triggers        */
  unsigned long  pool_drty_pg_steal_clns;  /* dirty page steal cleaner trig.  */
  unsigned long  pool_drty_pg_thrsh_clns;  /* dirty list threshold cln trig.  */
  unsigned long  direct_reads;             /* direct reads since 1st connect  */
  unsigned long  direct_writes;            /* direct writes since 1st conn    */
  unsigned long  direct_read_reqs;         /* direct read requests            */
  unsigned long  direct_write_reqs;        /* direct write requests           */
  unsigned long  direct_read_time;         /* direct read time since 1st conn */
  unsigned long  direct_write_time;        /* direct write time since 1st conn*/

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Internal counts                                      */
  /****************************************************************************/
  unsigned long  int_rows_inserted;      /* # rows insrted for Trigger        */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Logging Information                                  */
  /****************************************************************************/
  unsigned long  log_reads;             /* # of log pages read since 1st conn */
  unsigned long  log_writes;            /* # of log pages read since 1st conn */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Package Cache Information                            */
  /****************************************************************************/
  unsigned long  pkg_cache_lookups;     /* # of section lookups               */
  unsigned long  pkg_cache_inserts;     /* # of sections inserted into cache  */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Catalog Cache Information                            */
  /****************************************************************************/
  unsigned long  cat_cache_lookups;     /* # of table descriptor lookups      */
  unsigned long  cat_cache_inserts;     /* # of table descriptors inserted    */
  unsigned long  cat_cache_overflows;   /* # of catalog cache overflows       */
  unsigned long  cat_cache_heap_full;   /* # of overflows due to db heap full */
}sqlm_dbase;

/******************************************************************************/
/* Application Related Snapshot Information                                   */
/******************************************************************************/

typedef struct sqlm_appl
{
  unsigned long  size;                  /* size of sqlm_appl                  */
  _SQLOLDCHAR    info_type;             /* collected information type         */
  _SQLOLDCHAR    pad1[3];               /* padding for 4 byte alignment       */

  /****************************************************************************/
  /* Identification Information                                               */
  /****************************************************************************/
  sqlm_appl_id_info   id_info;               /* identification information    */

  /****************************************************************************/
  /* Lock Information                                                         */
  /****************************************************************************/
  unsigned long  locks_held;             /* locks currently held by appl.     */
  unsigned long  lock_waits;             /* Lock waits since appl. connect    */
  unsigned long  lock_wait_time;         /* total time appl waited on locks   */
  unsigned long  lock_escals;            /* Lock Escalations since appl conn. */
  unsigned long  x_lock_escals;          /* X lock escals since appl connect  */
  unsigned long  deadlocks;              /* Deadlocks since appl. connect     */
  unsigned long  uow_lock_wait_time;     /* time UOW waited on locks          */
  unsigned long  agent_id_holding_lk;    /* agent id Holding Lock             */
  unsigned long  table_file_id;          /* id of table of lock waited on     */
  unsigned long  lock_mode;              /* Mode of Lock waited on            */
  unsigned long  lock_object_type;       /* Lock Obj type for lock waited on  */
  unsigned long  lock_object_name;       /* Waited On lock obj name           */
  sqlm_timestamp lock_wait_start_time;   /* Time when lock wait entered       */
  _SQLOLDCHAR    appl_id_holding_lk[SQLM_APPLID_SZ]; /* id of appl holding lk */
  _SQLOLDCHAR    sequence_no_holding_lk[SQLM_SEQ_SZ]; /* seq no. holding lock */


  /****************************************************************************/
  /* Sorting Information                                                      */
  /****************************************************************************/
  unsigned long  total_sorts;            /* Total Sorts since connect         */
  unsigned long  total_sort_time;        /* elapsed time spent in sorts       */
  unsigned long  sort_overflows;         /* number of sort overflows          */

  /****************************************************************************/
  /* Buffer Pool Information                                                  */
  /****************************************************************************/
  unsigned long  pool_data_l_reads;      /* pool data logical reads since conn*/
  unsigned long  pool_data_p_reads;      /* pool data reads since 1st connect */
  unsigned long  pool_data_writes;       /* pool data writes since 1st connect*/
  unsigned long  pool_index_l_reads;     /* pool indx logical reads since conn*/
  unsigned long  pool_index_p_reads;     /* pool indx reads since 1st connect */
  unsigned long  pool_index_writes;      /* pool indx writes since 1st connect*/
  unsigned long  pool_read_time;         /* Buff pool read time since 1st conn*/
  unsigned long  pool_write_time;        /* Buff pool write time since 1st con*/

  /****************************************************************************/
  /* SQL statement counts                                                     */
  /****************************************************************************/
  unsigned long  commit_sql_stmts;       /* # of Commit SQL stmts since conn  */
  unsigned long  rollback_sql_stmts;     /* # of Rollback SQL stmts since conn*/
  unsigned long  dynamic_sql_stmts;      /* # of Dynamic SQL stmts since conn */
  unsigned long  static_sql_stmts;       /* # of Static SQL stmts since conn  */
  unsigned long  failed_sql_stmts;       /* # of Failed SQL stmts since conn  */
  unsigned long  select_sql_stmts;       /* # of SQL select stmts since conn  */
  unsigned long  ddl_sql_stmts;          /* # of data definition lang. stmts  */
  unsigned long  uid_sql_stmts;          /* # of update/insert/delete stmts   */

  /****************************************************************************/
  /* Internal counts                                                          */
  /****************************************************************************/
  unsigned long  int_auto_rebinds;       /* # of Auto Rebinds since 1st conn  */
  unsigned long  int_rows_deleted;       /* # of Casc. Deletes since 1st conn */
  unsigned long  int_rows_updated;       /* # of Set Null Deletes since conn  */
  unsigned long  int_commits;            /* # of int. Commits since 1st conn  */
  unsigned long  int_rollbacks;          /* # of int. Rollbacks since 1st conn*/
  unsigned long  int_deadlock_rollbacks; /* # of Rollbacks due to deadlock    */
                                         /*      since 1st connect            */

  /****************************************************************************/
  /* Row counts                                                               */
  /****************************************************************************/
  unsigned long  rows_deleted;           /* # of Rows Deleted since connect   */
  unsigned long  rows_inserted;          /* # of Rows Inserted since connect  */
  unsigned long  rows_updated;           /* # of Rows Updated since connect   */
  unsigned long  rows_selected;          /* # of Rows Selected since connect  */

  /****************************************************************************/
  /* Binds/Precompiles                                                        */
  /****************************************************************************/
  unsigned long  binds_precompiles;      /* # of Binds/Precomps since 1st conn*/

  /****************************************************************************/
  /* SQL Statement Information                                                */
  /****************************************************************************/
  unsigned long  stmt_type;              /* type of stmt: Dynamic or static   */
  unsigned long  stmt_operation;         /* Statement Operation               */
  unsigned long  section_number;         /* Section Number                    */
  unsigned long  stmt_length;            /* length of SQL statement following */
  unsigned long  stmt_sorts;             /* number of sorts for this statement*/
  sqlm_timestamp stmt_start;             /* SQL statement operation start time*/
  sqlm_timestamp stmt_stop;              /* SQL statement operation stop time */
  _SQLOLDCHAR    cursor_name[SQLM_IDENT_SZ];  /* sql stmt.cursor name         */
  _SQLOLDCHAR    creator[SQLM_IDENT_SZ];      /* auth id for precompile       */
  _SQLOLDCHAR    package_name[SQLM_IDENT_SZ]; /* Package Name                 */

  /****************************************************************************/
  /* Unit-Of-Work Information                                                 */
  /****************************************************************************/
  unsigned long   uow_log_space_used;   /* Log space used in most recent UOW  */
  unsigned long   uow_comp_status;      /* previous uow completion status     */
  sqlm_timestamp  prev_uow_stop_time;   /* prev commit or rollback time       */
  sqlm_timestamp  uow_start_time;       /* time trans exec started            */
  sqlm_timestamp  uow_stop_time;        /* unit-of-work stop time             */

  /****************************************************************************/
  /* Remote cursor Information                                                */
  /****************************************************************************/
  unsigned long  open_rem_curs;         /* Currently open remote cursors      */
  unsigned long  open_rem_curs_blk;     /* Currently open remote cursors w/blk*/
  unsigned long  rej_curs_blk;          /* Rej block remote cursor requests   */
  unsigned long  acc_curs_blk;          /* Acc block remote cursor requests   */

  /****************************************************************************/
  /* Timestamps                                                               */
  /****************************************************************************/
  sqlm_timestamp  appl_con_time;        /* Connect start date/time            */
  sqlm_timestamp  conn_complete_time;   /* Connect complete date/time         */
  sqlm_timestamp  last_reset;           /* Last reset date and time           */

  /****************************************************************************/
  /* Communication Information                                                */
  /****************************************************************************/
  unsigned long  curr_comm_heap_size;   /* Communication heap currently alloc */
  unsigned long  max_comm_heap_size;    /* client comheapsz config parameter  */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Lock Wait Information                               */
  /****************************************************************************/
  char           table_name[SQLM_IDENT_SZ];      /* table name                */
  char           table_schema[SQLM_IDENT_SZ];    /* table schema              */
  char           tablespace_name[SQLM_IDENT_SZ]; /* name of the tablespace    */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  lock information                                    */
  /****************************************************************************/
  unsigned long  lock_timeouts;        /* number of lock timeouts since conn  */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Agent CPU times                                     */
  /****************************************************************************/
  sqlm_time      agent_usr_cpu_time;   /* total user CPU time of agent        */
  sqlm_time      agent_sys_cpu_time;   /* total system CPU time for agent     */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  SQL Statement CPU times                             */
  /****************************************************************************/
  sqlm_time      stmt_usr_cpu_time;    /* total user CPU time of SQL stmt     */
  sqlm_time      stmt_sys_cpu_time;    /* total system CPU time for SQL stmt  */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Internal counts                                     */
  /****************************************************************************/
  unsigned long  int_rows_inserted;      /* # rows insrted for Trigger        */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Row Counts                                          */
  /****************************************************************************/
  unsigned long  rows_read;              /* # rows read since connection      */
  unsigned long  rows_written;           /* # rows written since connetion    */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  I/O Information                                     */
  /****************************************************************************/
  unsigned long  direct_reads;             /* direct reads since connect      */
  unsigned long  direct_writes;            /* direct writes since connect     */
  unsigned long  direct_read_reqs;         /* direct read requests since conn */
  unsigned long  direct_write_reqs;        /* direct write requests since conn*/
  unsigned long  direct_read_time;         /* direct read time since connect  */
  unsigned long  direct_write_time;        /* direct write time since connect */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Local Cursor Information                            */
  /****************************************************************************/
  unsigned long  open_loc_curs;         /* Currently open local cursors       */
  unsigned long  open_loc_curs_blk;     /* Currently open local cursors w/blk */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Client Identification Information                   */
  /****************************************************************************/
  char           execution_id[SQLM_IDENT_SZ]; /* login ID                     */
  char           corr_token[SQLM_APPLID_SZ];  /* DRDA AS Correlation Token    */
  unsigned long  client_pid;           /* Process ID of client application    */
  unsigned short client_platform;      /* Platform of client application      */
  unsigned short client_protocol;      /* Communications protocol of client   */
  unsigned short country_code;         /* Country code of client application  */
  char           pad2[2];              /* Padding for 4 byte alignment        */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Package Cache Information                            */
  /****************************************************************************/
  unsigned long  pkg_cache_lookups;     /* # of section lookups               */
  unsigned long  pkg_cache_inserts;     /* # of sections inserted into cache  */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2 Catalog Cache Information                            */
  /****************************************************************************/
  unsigned long  cat_cache_lookups;     /* # of table descriptor lookups      */
  unsigned long  cat_cache_inserts;     /* # of table descriptors inserted    */
  unsigned long  cat_cache_overflows;   /* # of catalog cache overflows       */
  unsigned long  cat_cache_heap_full;   /* # of overflows due to db heap full */
}sqlm_appl;

/******************************************************************************/
/* Table Related Snapshot Information                                         */
/******************************************************************************/

typedef struct sqlm_table_header
{
  unsigned long  size;                   /* size of sqlm_table_header         */
  _SQLOLDCHAR    info_type;              /* collected information type        */
  _SQLOLDCHAR    pad1[3];                /* padding for 4 byte alignment      */
  unsigned long  num_tables;             /* # of sqlm_table struct returned   */
  sqlm_timestamp db_conn_time;           /* Time of 1st database connection   */
  sqlm_timestamp last_reset;             /* last reset date and time          */
  _SQLOLDCHAR    input_db_alias[SQLM_IDENT_SZ]; /* Input Database Alias       */
  _SQLOLDCHAR    db_name[SQLM_IDENT_SZ];        /* Database name              */
  _SQLOLDCHAR    db_path[SQLM_DBPATH_SZ];       /* Database Path              */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */
}sqlm_table_header;

typedef struct sqlm_table
{
  unsigned long  size;                    /* size of sqlm_table               */
  _SQLOLDCHAR    info_type;               /* collected information type       */
  _SQLOLDCHAR    pad1[3];                 /* padding for 4 byte alignment     */
  unsigned long  table_file_id;           /* the file ID for the table        */
  unsigned long  table_type;              /* table type                       */
  unsigned long  rows_written;            /* number of changes to the table   */
  unsigned long  rows_read;               /* number of reads from the table   */
  unsigned long  overflow_accesses;       /* no. of accesses to overflow rec  */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Table Identification                                */
  /****************************************************************************/
  char           table_name[SQLM_IDENT_SZ];   /* table name                   */
  char           table_schema[SQLM_IDENT_SZ]; /* table schema                 */
}sqlm_table;

/******************************************************************************/
/* lock related information                                                   */
/******************************************************************************/

typedef struct sqlm_dbase_lock
{
  unsigned long  size;                   /* size of sqlm_dbase_lock           */
  _SQLOLDCHAR    info_type;              /* collected information type        */
  _SQLOLDCHAR    pad[3];                 /* padding for 4 byte alignment      */
  unsigned long  locks_held;             /* number of locks currently held    */
  unsigned long  appls_cur_cons;         /* Appls currently connected         */
  unsigned long  num_appls;              /* # sqlm_appl_lock structs returned */
  unsigned long  locks_waiting;          /* Appls. currently waiting on locks */
  _SQLOLDCHAR    input_db_alias[SQLM_IDENT_SZ]; /* Input Database Alias       */
  _SQLOLDCHAR    db_name[SQLM_IDENT_SZ];        /* Database name              */
  _SQLOLDCHAR    db_path[SQLM_DBPATH_SZ];       /* Database Path              */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */
}sqlm_dbase_lock;

typedef struct sqlm_appl_lock
{
  unsigned long  size;                   /* size of sqlm_appl_lock            */
  _SQLOLDCHAR    info_type;              /* collected information type        */
  _SQLOLDCHAR    pad[3];                 /* padding for 4 byte alignment      */

  /****************************************************************************/
  /* Application Identification Information                                   */
  /****************************************************************************/
  unsigned long  agent_id;                 /* Agent Id                        */
  unsigned long  appl_status;              /* Application Status              */
  unsigned long  codepage_id;              /* codepage/CCSID at node          */
                                           /* where app started               */
  unsigned long  locks_held;               /* locks currently held by appl.   */
  unsigned long  num_locks;                /* # sqlm_lock structures returned */
  sqlm_timestamp status_change_time;       /* last appl status change time    */
  _SQLOLDCHAR    appl_id[SQLM_APPLID_SZ];  /* Application Id                  */
  _SQLOLDCHAR    sequence_no[SQLM_SEQ_SZ]; /* appl id sequence number         */
  _SQLOLDCHAR    appl_name[SQLM_IDENT_SZ]; /* Application Name                */
  _SQLOLDCHAR    auth_id[SQLM_IDENT_SZ];   /* Authorization Id                */
  _SQLOLDCHAR    client_db_alias[SQLM_IDENT_SZ]; /* Client Database Alias     */

  /****************************************************************************/
  /* Lock Waited On Information                                               */
  /****************************************************************************/
  unsigned long  agent_id_holding_lk;    /* Agent Id Holding Lock             */
  unsigned long  lock_object_name;       /* Lock Object Name                  */
  unsigned long  lock_object_type;       /* Lock Object Type                  */
  unsigned long  table_file_id;           /* the file ID for the table        */
  _SQLOLDCHAR    appl_id_holding_lk[SQLM_APPLID_SZ]; /* id of appl holding lk */
  _SQLOLDCHAR    sequence_no_holding_lk[SQLM_SEQ_SZ]; /* seq. no holding lk   */

  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Lock Wait Information                               */
  /****************************************************************************/
  char           table_name[SQLM_IDENT_SZ];       /* table name               */
  char           table_schema[SQLM_IDENT_SZ];     /* table schema             */
  char           tablespace_name[SQLM_IDENT_SZ];  /* name of the tablespace   */
}sqlm_appl_lock;

typedef struct sqlm_lock
{
  unsigned long  size;                   /* size of sqlm_lock                 */
  _SQLOLDCHAR    info_type;              /* collected information type        */
  _SQLOLDCHAR    pad[3];                 /* padding for 4 byte alignment      */
  unsigned long  table_file_id;          /* FID of table involved in lock     */
  unsigned long  lock_object_type;       /* lock object type: row, table      */
  unsigned long  lock_mode;              /* Lock mode                         */
  unsigned long  lock_status;            /* Lock status                       */
  unsigned long  lock_object_name;       /* Lock Object Name -                */
                                         /* RID or FID of lock obj            */
  _SQLOLDCHAR    reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */

  /****************************************************************************/
  /* SQLM_DBMON_VERSION2  Lock Information                                    */
  /****************************************************************************/
  char           table_name[SQLM_IDENT_SZ];       /* table name               */
  char           table_schema[SQLM_IDENT_SZ];     /* table schema             */
  char           tablespace_name[SQLM_IDENT_SZ];  /* name of the tablespace   */
}sqlm_lock;


/******************************************************************************/
/* Tablespace Related Snapshot Information                                    */
/******************************************************************************/
typedef struct sqlm_tablespace_header
{
  unsigned long  size;                   /* size of sqlm_tablespace_header    */
  char           info_type;              /* collected information type        */
  char           pad[3];                 /* padding for 4 byte alignment      */
  unsigned long  num_tablespaces;        /* # sqlm_tablespace structs returned*/
  sqlm_timestamp db_conn_time;           /* Time of 1st database connection   */
  sqlm_timestamp last_reset;             /* last reset date and time          */
  char           input_db_alias[SQLM_IDENT_SZ]; /* Input Database Alias       */
  char           db_name[SQLM_IDENT_SZ];        /* Database name              */
  char           db_path[SQLM_DBPATH_SZ];       /* Database Path              */

  char           reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */
}sqlm_tablespace_header;


typedef struct sqlm_tablespace
{
  unsigned long  size;                   /* size of sqlm_table                */
  char           info_type;              /* collected information type        */
  char           pad[3];                 /* padding for 4 byte alignment      */

  char           tablespace_name[SQLM_IDENT_SZ];  /* name of the tablespace   */

  unsigned long  pool_data_l_reads;      /* pool data logical reads since conn*/
  unsigned long  pool_data_p_reads;      /* pool data physical reads since con*/
  unsigned long  pool_async_data_reads;  /* asynchronous pool data reads      */
  unsigned long  pool_data_writes;       /* pool data writes since connect    */
  unsigned long  pool_async_data_writes; /* asynchronous pool data writes     */
  unsigned long  pool_index_l_reads;     /* pool index logical reads since con*/
  unsigned long  pool_index_p_reads;     /* pool index physical reads since cn*/
  unsigned long  pool_index_writes;      /* pool index writes since connect   */
  unsigned long  pool_async_index_writes; /* asynchronous pool index writes   */
  unsigned long  pool_read_time;         /* Buff pool read time since 1st conn*/
  unsigned long  pool_write_time;        /* Buff pool write time since 1st con*/
  unsigned long  pool_async_read_time;   /* asynchronous read time            */
  unsigned long  pool_async_write_time;  /* asynchronous write time           */
  unsigned long  pool_async_data_read_reqs; /* # async read requests          */

  unsigned long  direct_reads;           /* direct reads since 1st connect    */
  unsigned long  direct_writes;          /* direct writes since 1st conn      */
  unsigned long  direct_read_reqs;       /* direct read requests              */
  unsigned long  direct_write_reqs;      /* direct write requests             */
  unsigned long  direct_read_time;       /* direct read time since 1st conn   */
  unsigned long  direct_write_time;      /* direct write time since 1st conn  */

  unsigned long  files_closed;           /* files closed for tablespace       */

  char           reserved[SQLM_RESERVED_SZ];  /* reserved for future use      */
}sqlm_tablespace;



/******************************************************************************/
/* Database Monitor Event Monitor Data Structures                             */
/******************************************************************************/

/******************************************************************************/
/*  Event Monitor Log Header Record                                           */
/******************************************************************************/
typedef struct sqlm_event_log_header
{
  int            byte_order;                   /* Big Endian or Little Endian */
  unsigned long  size;                         /* Size of this record         */
  unsigned long  version;                      /* Event Monitor Version       */
  char           event_monitor_name[SQLM_IDENT_SZ];  /* Name of the Event Mon */
  unsigned short codepage_id;                  /* Code page of Database       */
  unsigned short country_code;                 /* Country Code of Database    */
  char           server_prdid[SQLM_IDENT_SZ];  /* Server Product Id           */
  char           server_instance_name[SQLM_IDENT_SZ]; /*instance name of DB2  */

}sqlm_event_log_header;

/******************************************************************************/
/* Event Monitor Record Header                                                */
/******************************************************************************/
typedef struct sqlm_event_rec_header {
  /*
     All event monitor event records have size and type as their first data
     elements.  These fields can be viewed as a 'header' that has to be read
     first to determine how to read the rest of the data.
     The record size for a given event type may vary between releases of DB2.
   */
   unsigned long size;               /* size of Event (size of entire struct) */
   unsigned long type;               /* type of Event                         */
} sqlm_event_rec_header;

/******************************************************************************/
/*  Event Monitor Database Event Record                                       */
/******************************************************************************/
typedef struct sqlm_db_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */

  /****************************************************************************/
  /* Locking Information                                                      */
  /****************************************************************************/
  unsigned long  lock_waits;             /* Lock waits                        */
  unsigned long  lock_wait_time;         /* Total time dbase waited on locks  */
  unsigned long  deadlocks;              /* Deadlocks                         */
  unsigned long  lock_escals;            /* lock escalations                  */
  unsigned long  x_lock_escals;          /* X lock escalations                */
  unsigned long  lock_timeouts;          /* Lock timeouts                     */

  /****************************************************************************/
  /* Sorting Information                                                      */
  /****************************************************************************/
  unsigned long  total_sorts;            /* number of sorts                   */
  unsigned long  total_sort_time;        /* elapsed time spent in sorts       */
  unsigned long  sort_overflows;         /* number of sort overflows          */

  /****************************************************************************/
  /* Buffer Pool and I/O Information                                          */
  /****************************************************************************/
  unsigned long  pool_data_l_reads;      /* pool data logical reads           */
  unsigned long  pool_data_p_reads;      /* pool data physical reads          */
  unsigned long  pool_async_data_reads;  /* asynchronous pool data reads      */
  unsigned long  pool_data_writes;       /* pool data writes                  */
  unsigned long  pool_async_data_writes; /* asynchronous pool data writes     */
  unsigned long  pool_index_l_reads;     /* pool index logical reads          */
  unsigned long  pool_index_p_reads;     /* pool index physicl reads          */
  unsigned long  pool_index_writes;      /* pool index page writes            */
  unsigned long  pool_async_index_writes; /* asynchronous pool index writes   */
  unsigned long  pool_read_time;         /* Buff pool read time               */
  unsigned long  pool_write_time;        /* Buff pool write time              */
  unsigned long  pool_async_read_time;   /* asynchronous read time            */
  unsigned long  pool_async_write_time;  /* asynchronous write time           */
  unsigned long  pool_async_data_read_reqs; /* # async read requests          */
  unsigned long  pool_lsn_gap_clns;      /* LSN Gap cleaner triggers          */
  unsigned long  pool_drty_pg_steal_clns;    /* dirty page steal cleaner trig.*/
  unsigned long  pool_drty_pg_thrsh_clns;    /* dirty list threshold cln trig.*/
  unsigned long  direct_reads;           /* direct reads                      */
  unsigned long  direct_writes;          /* direct writes                     */
  unsigned long  direct_read_reqs;       /* direct read requests              */
  unsigned long  direct_write_reqs;      /* direct write requests             */
  unsigned long  direct_read_time;       /* direct read time                  */
  unsigned long  direct_write_time;      /* direct write time                 */

  unsigned long  files_closed;           /* files closed                      */

  /****************************************************************************/
  /* SQL statement counts                                                     */
  /****************************************************************************/
  unsigned long  commit_sql_stmts;       /* # of Commit SQL statements        */
  unsigned long  rollback_sql_stmts;     /* # of Rollback SQL statements      */
  unsigned long  dynamic_sql_stmts;      /* # of Dynamic SQL statements       */
  unsigned long  static_sql_stmts;       /* # of Static SQL statements        */
  unsigned long  failed_sql_stmts;       /* # of Failed SQL statements        */
  unsigned long  select_sql_stmts;       /* # of SQL select statements        */
  unsigned long  ddl_sql_stmts;          /* # of data definition lang. stmts  */
  unsigned long  uid_sql_stmts;          /* # of update/insert/delete stmts   */

  /****************************************************************************/
  /* Internal counts                                                          */
  /****************************************************************************/
  unsigned long  int_auto_rebinds;       /* # of interanl auto rebinds        */
  unsigned long  int_rows_deleted;       /* # of internal rows deleted        */
  unsigned long  int_rows_updated;       /* # of internal rows updated        */
  unsigned long  int_rows_inserted;      /* # of internal rows inserted       */
  unsigned long  int_commits;            /* # of internal commits             */
  unsigned long  int_rollbacks;          /* # of internal rollbacks           */

  /****************************************************************************/
  /* Row counts                                                               */
  /****************************************************************************/
  unsigned long  rows_deleted;           /* # of Rows Deleted                 */
  unsigned long  rows_inserted;          /* # of Rows Inserted                */
  unsigned long  rows_updated;           /* # of Rows Updated                 */
  unsigned long  rows_selected;          /* # of Rows Selected                */

  /****************************************************************************/
  /* Binds/Precompiles                                                        */
  /****************************************************************************/
  unsigned long  binds_precompiles;      /* # of Binds/Precomps/Rebinds       */

  /****************************************************************************/
  /* Timestamps                                                               */
  /****************************************************************************/
  sqlm_timestamp disconn_time;            /* Time of last database disconnect */

  /****************************************************************************/
  /* Application connection counters                                          */
  /****************************************************************************/
  unsigned long  total_cons;             /* Total Connects                    */
  unsigned long  connections_top;        /* High water mark for connections   */

  /****************************************************************************/
  /* Database memory pool high water marks                                    */
  /****************************************************************************/
  unsigned long  db_heap_top;            /* High water mark for dbheap        */


  /****************************************************************************/
  /* Logging Information                                                      */
  /****************************************************************************/
  unsigned long  sec_log_used_top;       /* Maximum secondary log space used  */
  unsigned long  tot_log_used_top;       /* Maximum total log space used      */
  unsigned long  log_reads;              /* # of log pages read               */
  unsigned long  log_writes;             /* # of log pages written            */

  /****************************************************************************/
  /* Package Cache Information                                                */
  /****************************************************************************/
  unsigned long  pkg_cache_lookups;     /* # of section lookups               */
  unsigned long  pkg_cache_inserts;     /* # of sections inserted into cache  */

  /****************************************************************************/
  /* Catalog Cache Information                                                */
  /****************************************************************************/
  unsigned long  cat_cache_lookups;     /* # of table descriptor lookups      */
  unsigned long  cat_cache_inserts;     /* # of table descriptors inserted    */
  unsigned long  cat_cache_overflows;   /* # of catalog cache overflows       */
  unsigned long  cat_cache_heap_full;   /* # of overflows due to db heap full */

}sqlm_db_event;


/******************************************************************************/
/*  Event Monitor Connection Event Record                                     */
/******************************************************************************/
typedef struct sqlm_conn_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/

  /****************************************************************************/
  /* Locking Information                                                      */
  /****************************************************************************/
  unsigned long  lock_waits;             /* Lock waits since appl. connect    */
  unsigned long  lock_wait_time;         /* total time appl waited on locks   */
  unsigned long  lock_escals;            /* Lock Escalations since appl conn. */
  unsigned long  x_lock_escals;          /* X lock escals since appl connect  */
  unsigned long  deadlocks;              /* Deadlocks since appl. connect     */
  unsigned long  lock_timeouts;          /* Lock timeouts since 1st db connect*/

  /****************************************************************************/
  /* Sorting Information                                                      */
  /****************************************************************************/
  unsigned long  total_sorts;            /* Total Sorts since connect         */
  unsigned long  total_sort_time;        /* elapsed time spent in sorts       */
  unsigned long  sort_overflows;         /* number of sort overflows          */

  /****************************************************************************/
  /* Buffer Pool and I/O Information                                          */
  /****************************************************************************/
  unsigned long  pool_data_l_reads;      /* pool data logical reads since conn*/
  unsigned long  pool_data_p_reads;      /* pool data physical reads since con*/
  unsigned long  pool_data_writes;       /* pool data writes since 1st connect*/
  unsigned long  pool_index_l_reads;     /* pool indx logical reads since conn*/
  unsigned long  pool_index_p_reads;     /* pool indx physical reads since con*/
  unsigned long  pool_index_writes;      /* pool indx writes since 1st connect*/
  unsigned long  pool_read_time;         /* Buff pool read time since 1st conn*/
  unsigned long  pool_write_time;        /* Buff pool write time since 1st con*/
  unsigned long  direct_reads;           /* direct reads since connect        */
  unsigned long  direct_writes;          /* direct writes since connect       */
  unsigned long  direct_read_reqs;       /* direct read requests since conn   */
  unsigned long  direct_write_reqs;      /* direct write requests since conn  */
  unsigned long  direct_read_time;       /* direct read time since connect    */
  unsigned long  direct_write_time;      /* direct write time since connect   */

  /****************************************************************************/
  /* SQL statement counts                                                     */
  /****************************************************************************/
  unsigned long  commit_sql_stmts;       /* # of Commit SQL stmts since conn  */
  unsigned long  rollback_sql_stmts;     /* # of Rollback SQL stmts since conn*/
  unsigned long  dynamic_sql_stmts;      /* # of Dynamic SQL stmts since conn */
  unsigned long  static_sql_stmts;       /* # of Static SQL stmts since conn  */
  unsigned long  failed_sql_stmts;       /* # of Failed SQL stmts since conn  */
  unsigned long  select_sql_stmts;       /* # of SQL select stmts since conn  */
  unsigned long  ddl_sql_stmts;          /* # of data definition lang. stmts  */
  unsigned long  uid_sql_stmts;          /* # of update/insert/delete stmts   */

  /****************************************************************************/
  /* Internal counts                                                          */
  /****************************************************************************/
  unsigned long  int_auto_rebinds;       /* # of Auto Rebinds since connect   */
  unsigned long  int_rows_deleted;       /* # of internal deletes since conn  */
  unsigned long  int_rows_updated;       /* # of internal updates since conn  */
  unsigned long  int_rows_inserted;      /* # of internal inserts since conn  */
  unsigned long  int_commits;            /* # of int. Commits since 1st conn  */
  unsigned long  int_rollbacks;          /* # of int. Rollbacks since 1st conn*/
  unsigned long  int_deadlock_rollbacks; /* # of Rollbacks due to deadlock    */
                                         /*      since 1st connect            */

  /****************************************************************************/
  /* Row counts                                                               */
  /****************************************************************************/
  unsigned long  rows_deleted;           /* # of Rows Deleted since connect   */
  unsigned long  rows_inserted;          /* # of Rows Inserted since connect  */
  unsigned long  rows_updated;           /* # of Rows Updated since connect   */
  unsigned long  rows_selected;          /* # of Rows Selected since connect  */
  unsigned long  rows_read;              /* # of Rows read since connect      */
  unsigned long  rows_written;           /* # of Rows written since connect   */

  /****************************************************************************/
  /* Binds/Precompiles                                                        */
  /****************************************************************************/
  unsigned long  binds_precompiles;      /* # of Binds/Precomps/Rebinds       */

  /****************************************************************************/
  /* Blocking Cursor Information                                              */
  /****************************************************************************/
  unsigned long  rej_curs_blk;          /* Rejected block cursor requests     */
  unsigned long  acc_curs_blk;          /* Accepted block cursor requests     */

  /****************************************************************************/
  /* Timestamps                                                               */
  /****************************************************************************/
  sqlm_timestamp  disconn_time;         /* Disconnection  date/time           */

  /****************************************************************************/
  /* Agent activity                                                           */
  /****************************************************************************/
  sqlm_time       user_cpu_time;        /* Total user CPU time of agent       */
  sqlm_time       system_cpu_time;      /* Total system CPU time of agent     */

  /****************************************************************************/
  /* Package Cache Information                                                */
  /****************************************************************************/
  unsigned long  pkg_cache_lookups;     /* # of section lookups               */
  unsigned long  pkg_cache_inserts;     /* # of sections inserted into cache  */

  /****************************************************************************/
  /* Catalog Cache Information                                                */
  /****************************************************************************/
  unsigned long  cat_cache_overflows;   /* # of catalog cache overflows       */
  unsigned long  cat_cache_heap_full;   /* # of overflows due to db heap full */

}sqlm_conn_event;


/******************************************************************************/
/*  Event Monitor Table Event Record                                          */
/******************************************************************************/
typedef struct sqlm_table_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */
  char           table_name[SQLM_IDENT_SZ];     /* the name of the table      */
  char           table_schema[SQLM_IDENT_SZ];   /* the name of the table      */
  unsigned long  table_type;             /* table type                        */
  unsigned long  rows_written;           /* number of changes to the table    */
  unsigned long  rows_read;              /* number of reads from the table    */
  unsigned long  overflow_accesses;      /* no. of accesses to overflow rec   */
  sqlm_timestamp table_event_time;       /* Table Event Date and Time         */

}sqlm_table_event;


/******************************************************************************/
/*  Event Monitor Statment and Statment Text Event Records                    */
/******************************************************************************/
typedef struct sqlm_stmt_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  unsigned long  stmt_type;              /* type of stmt: Dynamic or static   */
  unsigned long  operation;              /* Statement Operation               */
  unsigned long  fetch_count;            /* Count of fetches                  */
  unsigned long  section_number;         /* Section Number                    */
  sqlm_timestamp start_time;             /* SQL statement operation start time*/
  sqlm_timestamp stop_time;              /* SQL statement operation stop time */
  char           cursor_name[SQLM_IDENT_SZ];  /* sql stmt.cursor name         */
  char           creator[SQLM_IDENT_SZ];      /* auth id for precompile       */
  char           package_name[SQLM_IDENT_SZ]; /* Package Name                 */
  sqlm_time      user_cpu_time;         /* Total user CPU time of statement   */
  sqlm_time      system_cpu_time;       /* Total system CPU time of statement */
  unsigned long  total_sorts;           /* Total number of sorts for this stmt*/
  unsigned long  total_sort_time;       /* Total sort time for this statement */
  unsigned long  sort_overflows;        /* # of sort overflows for this stmt  */
  unsigned long  rows_read;             /* # of rows read by this statement   */
  unsigned long  rows_written;          /* # of rows upd/ins/del for this stmt*/
  unsigned long  int_rows_deleted;      /* # of internal deletes by the stmt  */
  unsigned long  int_rows_updated;      /* # of internal updates by the stmt  */
  unsigned long  int_rows_inserted;     /* # of internal inserts by the stmt  */
  struct sqlca   sqlca;                 /* sqlca from statement               */

}sqlm_stmt_event;

typedef struct sqlm_stmttext_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  char           creator[SQLM_IDENT_SZ];      /* auth id for precompile       */
  char           package_name[SQLM_IDENT_SZ]; /* Package Name                 */
  unsigned long  section_number;         /* Section Number                    */
  unsigned long  stmt_length;           /* length of SQL statement following  */
  char           stmt_text[1];          /* dynamic sql statement text         */


}sqlm_stmttext_event;


/******************************************************************************/
/*  Event Monitor Transaction Event Record                                    */
/******************************************************************************/
typedef struct sqlm_xaction_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;                 /* event type identifier         */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  unsigned long  log_space_used;        /* Log space used in transaction      */
  unsigned long  status;                /* transaction completion status      */
  unsigned long  lock_wait_time;        /* transaction lock wait time         */
  unsigned long  locks_held_top;        /* max locks held in transaction      */
  unsigned long  lock_escals;           /* # of lock escalation in transaction*/
  unsigned long  x_lock_escals;         /* # of x lock escals in transaction  */
  unsigned long  rows_read;             /* # of rows read by this transaction */
  unsigned long  rows_written;          /* # of rows upd/ins/del for this xact*/
  sqlm_time      user_cpu_time;         /* Total user CPU time of transaction */
  sqlm_time      system_cpu_time;       /* Total system CPU time of xaction   */
  sqlm_timestamp prev_stop_time;        /* prev commit or rollback time       */
  sqlm_timestamp start_time;            /* time trans exec started            */
  sqlm_timestamp stop_time;             /* trans stop time                    */

}sqlm_xaction_event;


/******************************************************************************/
/*  Event Monitor Deadlock and Deadlocked Connection Event Records            */
/******************************************************************************/
typedef struct sqlm_deadlock_event
{
  unsigned long  size;                       /* event record size             */
  unsigned long  event_type;                 /* event type identifier         */
  unsigned long  dl_conns;                   /* number of conns deadlocked    */
  sqlm_timestamp start_time;                 /* Time when deadlock detected   */

}sqlm_deadlock_event;


typedef struct sqlm_dlconn_event
{
  unsigned long  size;                       /* event record size             */
  unsigned long  event_type;                 /* event type identifier         */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  char           appl_id_holding_lk[SQLM_APPLID_SZ];  /* id of appl holding lk */
  char           sequence_no_holding_lk[SQLM_SEQ_SZ]; /* seq no. holding lock */
  char           table_name[SQLM_IDENT_SZ];   /* name of tb of lock waited on */
  char           table_schema[SQLM_IDENT_SZ]; /* table schema of lk waited on */
  char           tablespace_name[SQLM_IDENT_SZ];  /* name of the tablespace   */
  unsigned long  lock_mode;              /* Mode of Lock waited on            */
  unsigned long  lock_object_type;       /* Lock Obj type for lock waited on  */
  unsigned long  lock_object_name;       /* Waited On lock obj name           */
  sqlm_timestamp lock_wait_start_time;   /* Time when lock wait started       */
  sqlm_timestamp start_time;             /* Time when deadlock detected       */

}sqlm_dlconn_event;


/******************************************************************************/
/*  Event Monitor Tablespace Event Record                                     */
/******************************************************************************/
typedef struct sqlm_tablespace_event
{
  unsigned long  size;                   /* event record size                 */
  unsigned long  event_type;             /* event type identifier             */

  char           tablespace_name[SQLM_IDENT_SZ];  /* name of tablespace       */
  unsigned long  pool_data_l_reads;      /* pool data logical reads since conn*/
  unsigned long  pool_data_p_reads;      /* pool data physical reads since con*/
  unsigned long  pool_async_data_reads;  /* asynchronous pool data reads      */
  unsigned long  pool_data_writes;       /* pool data writes since connect    */
  unsigned long  pool_async_data_writes; /* asynchronous pool data writes     */
  unsigned long  pool_index_l_reads;     /* pool index logical reads since con*/
  unsigned long  pool_index_p_reads;     /* pool index physical reads since cn*/
  unsigned long  pool_index_writes;      /* pool index writes since connect   */
  unsigned long  pool_async_index_writes; /* asynchronous pool index writes   */
  unsigned long  pool_read_time;         /* Buff pool read time since 1st conn*/
  unsigned long  pool_write_time;        /* Buff pool write time since 1st con*/
  unsigned long  pool_async_read_time;   /* asynchronous read time            */
  unsigned long  pool_async_write_time;  /* asynchronous write time           */
  unsigned long  pool_async_data_read_reqs; /* # async read requests          */

  unsigned long  direct_reads;           /* direct reads since 1st connect    */
  unsigned long  direct_writes;          /* direct writes since 1st conn      */
  unsigned long  direct_read_reqs;       /* direct read requests              */
  unsigned long  direct_write_reqs;      /* direct write requests             */
  unsigned long  direct_read_time;       /* direct read time since 1st conn   */
  unsigned long  direct_write_time;      /* direct write time since 1st conn  */

  unsigned long  files_closed;           /* files closed since first db conn  */
  sqlm_timestamp ts_event_time;          /* Tablespace event date and time    */

}sqlm_tablespace_event;


/******************************************************************************/
/*  Event Monitor Database Header Event Record                                */
/******************************************************************************/
typedef struct sqlm_dbheader_event
{
  unsigned long  size;                    /* event record size                */
  unsigned long  event_type;              /* event type identifier            */
  char           db_name[SQLM_IDENT_SZ];  /* Database name                    */
  char           db_path[SQLM_DBPATH_SZ]; /* Database Path                    */
  sqlm_timestamp conn_time;               /* Time of 1st database connection  */

}sqlm_dbheader_event;



/******************************************************************************/
/*  Event Monitor Start Event Record                                          */
/******************************************************************************/
typedef struct sqlm_evmon_start_event
{
  unsigned long  size;                    /* event record size                */
  unsigned long  event_type;              /* event type identifier            */
  sqlm_timestamp start_time;              /* Time event monitor started       */

} sqlm_evmon_start_event;


/******************************************************************************/
/*  Event Monitor Connection Header Event Record                              */
/******************************************************************************/
typedef struct sqlm_connheader_event
{
  unsigned long  size;                       /* event record size             */
  unsigned long  event_type;                 /* event type identifier         */
  char           appl_id[SQLM_APPLID_SZ];    /* Application Id                */
  char           sequence_no[SQLM_SEQ_SZ];   /* application id sequence number*/
  char           corr_token[SQLM_APPLID_SZ]; /* DRDA AS Correlation Token     */
  char           appl_name[SQLM_IDENT_SZ];   /* Application Program Name      */
  char           auth_id[SQLM_IDENT_SZ];     /* Authorization Id              */
  char           execution_id[SQLM_IDENT_SZ]; /* Login ID                     */
  char           client_nname[SQLM_IDENT_SZ]; /* Config NNAME of client       */
  char           client_prdid[SQLM_IDENT_SZ]; /* product/version on client    */
  char           client_db_alias[SQLM_IDENT_SZ]; /* Client Database Alias     */
  long           client_pid;                 /* PID of client                 */
  long           agent_id;                   /* agent id                      */
  unsigned short codepage_id;                /* codepage at client node       */
  unsigned short country_code;               /* country code of client app    */
  unsigned short client_platform;            /* platform of client app        */
  unsigned short client_protocol;            /* Comms protocol of client      */
  sqlm_timestamp conn_time;                  /* Connect start date/time       */

} sqlm_connheader_event;


/******************************************************************************/
/*  Event Monitor Overflow Event Record                                       */
/******************************************************************************/
typedef struct sqlm_overflow_event
{
  unsigned long  size;                       /* event record size             */
  unsigned long  event_type;                 /* event type identifier         */
  unsigned long  count;                      /* The number of overflows       */
  sqlm_timestamp first_overflow_time;        /* The time of the first overflow*/
  sqlm_timestamp last_overflow_time;         /* The time of the last overflow */

} sqlm_overflow_event;


/******************************************************************************/
/* data structure sizes                                                       */
/* DON'T USE THESE CONSTANTS. THEY ARE PROVIDED FOR COMPATIBILITY ONLY        */
/******************************************************************************/

#define SQLM_APPLINFO_SZ        492    /* size of old sqlm_applinfo struct    */
#define SQLM_DB2_SZ             100    /* size of old sqlm_db2 structure      */
#define SQLM_DBASE_SZ           548    /* size of old sqlm_dbase structure    */
#define SQLM_TABLE_HEADER_SZ    356    /* size of old sqlm_table_header struct*/
#define SQLM_TABLE_SZ           60     /* size of old sqlm_table structure    */
#define SQLM_APPL_SZ            880    /* size of old sqlm_appl structure     */
#define SQLM_DBASE_LOCK_SZ      352    /* size of old sqlm_dbase_lock struct  */
#define SQLM_APPL_LOCK_SZ       216    /* size of old sqlm_appl_lock struct   */
#define SQLM_LOCK_SZ            60     /* size of old sqlm_lock structure     */
#define SQLM_COLLECTED_SZ       232    /* size of old sqlm_collected structure*/
#define SQLM_DCS_APPLINFO_SZ    260    /* size of old sqlm_dcs_applinfo struct*/

#define SQLM_TIMESTAMP_SZ       sizeof(sqlm_timestamp)


/******************************************************************************/
/* Database Monitor APIs                                                      */
/******************************************************************************/

/* Database Monitor Switch API */
int SQL_API_FN sqlmon(unsigned long        version,       /* Version Id       */
                      _SQLOLDCHAR          *reserved,     /* reserved         */
                      sqlm_recording_group group_states[],
                                      /* monitor switches and current states  */
                      struct sqlca         *sqlca         /* sqlca            */
                     );

/* Database Monitor Snapshot API */
int SQL_API_FN sqlmonss(unsigned long     version,        /* Version id       */
                        _SQLOLDCHAR       *reserved,      /* reserved         */
                        sqlma             *sqlma_ptr,     /* monitoring area  */
                        unsigned long     buffer_length,  /* buffer length    */
                        void              *buffer_area,   /* buffer area      */
                        sqlm_collected    *collected,     /* num collected    */
                        struct sqlca      *sqlca          /* sqlca            */
                       );

/* Estimate the buffer size that user need to allocate */
int SQL_API_FN sqlmonsz(unsigned long         version,    /* Version id       */
                        _SQLOLDCHAR           *reserved,  /* reserved         */
                        sqlma                 *sqlma_ptr, /* sqlma pointer    */
                        unsigned long         *buff_size, /* est. buffer sz   */
                        struct sqlca          *sqlca      /* sqlca structure  */
                       );

/* Reset Database Monitor */
int SQL_API_FN sqlmrset(unsigned long          version,   /* Version Id       */
                        _SQLOLDCHAR            *reserved, /* reserved         */
                        unsigned long          reset_all, /* reset db or all  */
                        _SQLOLDCHAR            *db_alias, /* ptr to db_alias  */
                        struct sqlca           *sqlca     /* sqlca            */
                       );


/******************************************************************************/
/* Database Monitor Generic APIs                                              */
/******************************************************************************/

/* Generic Database Monitor Switch API  */
int SQL_API_FN sqlgmon
   (
     unsigned long          reserved_lgth,   /* length of reserved field      */
     struct   sqlca         *sqlca,          /* pointer to sqlca              */
     sqlm_recording_group   group_states[],  /* ptr to returned states        */

     _SQLOLDCHAR            *reserved,       /* reserved for future use       */
     unsigned long          version          /* Version id                    */
   );


/* Generic Database Monitor Snapshot API */
int SQL_API_FN sqlgmnss
   (
     unsigned long           reserved_lgth,  /* length of reserved field      */
     struct   sqlca          *sqlca,         /* pointer to sqlca              */
     sqlm_collected          *collected,     /* pointer to # collected        */
     void                    *buffer_area,   /* pointer to buffer area        */
     unsigned long           buffer_length,  /* length of buffer              */
     sqlma                   *sqlma_ptr,     /* pointer to monitor area       */
     _SQLOLDCHAR             *reserved,      /* reserved for future use       */
     unsigned long           version         /* Version id                    */
   );


/* Generic Database Monitor Estimate Buffer Size API */
int SQL_API_FN sqlgmnsz
   (
     unsigned long           reserved_lgth,  /* length of reserved field      */
     struct   sqlca          *sqlca,         /* pointer to sqlca              */
     unsigned long           *buff_size,     /* length of buffer              */
     sqlma                   *sqlma_ptr,     /* pointer to sqlma              */
     _SQLOLDCHAR             *reserved,      /* reserved for future use       */
     unsigned long           version         /* Version id                    */
   );



/* Generic Database Monitor Reset API */
int SQL_API_FN sqlgmrst
   (
     unsigned short           dbnamel,       /* length of database            */
     unsigned long            reserved_lgth, /* length of reserved field      */
     struct   sqlca           *sqlca,        /* pointer to sqlca              */
     _SQLOLDCHAR              *db_alias,     /* database alias                */
     unsigned long            reset_all,     /* reset db or all info          */
     _SQLOLDCHAR              *reserved,     /* reserved for future use       */
     unsigned long            version        /* Version id                    */
   );

#if (defined(DB2OS2) || defined(DB2NT) || defined(DB2WIN))
#pragma pack()
#elif (defined(DB2MAC))
#pragma align
#elif (defined(DB2HP) || defined(DB2SNI))

#elif (defined(DB2AIX) || defined(DB2SUN))
#pragma options align=reset
#endif

#ifdef __cplusplus
}
#endif

#endif  /* SQL_H_SQLMON */
kB %  $        dx  G2G2[2           dx      ./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_CALL_ERROR                  "38501"
#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 */
3"
#k )  $        r H2H2[2         @  r     ./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              */
#define SQLUD_STORDEF_NOINTERRUPT 101  /* initial call, tablespace container  */
                                       /* redefinition requested without      */
                                       /* prompting                           */

/* 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)         */
#define SQLCC_RC_NO_SOCKS_ENV_VAR      -1460   /* SOCKS env vars not found    */

/* 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E   $        $  22\2         }  $      ./usr/lpp/db2_02_01/samples/c/backrest.c .4120/l                    $          /*******************************************************************************
**
** Source File Name = backrest.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 :
**       an example showing how to use BACKUP & RESTORE APIs in order to:
**          - backup a database
**          - restore a database
**          - roll forward database to return the database to a state it was
**            in prior to the damage...
**
**    APIs USED :
**       BACKUP DATABASE                   sqlubckp()
**       RESTORE DATABASE                  sqludrst()
**       GET TABLESPACE CONTAINER QUERY    sqlbtcq()
**       SET TABLESPACE CONTAINERS         sqlbstsc()
**       ROLL FORWARD DATABASE             sqlurfwd()
**
**    STRUCTURES USED :
**       sqlca
**
**    OTHER FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**
**       internal :
**
**       external :
**          check_error :     Checks for SQLCODE error, and prints out any
**          [in UTIL.C]          related information available.
**                               This procedure is located in the UTIL.C file.
**
**    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.
**
*******************************************************************************/

/*--> SQLB0X01.C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlutil.h>
#include <sqlenv.h>
#include "util.h"
/*<--*/

#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) return 1;
#if (defined(DB2AIX) || defined(DB2SUN) || defined(DB2HP) || defined(DB2SNI) \
                     || defined(DB2SCO) || defined(DB2SGI))
   #define TEMPDIR "/u/backup"
#else
   #define TEMPDIR "\\BACKUP"
#endif



/*-->*/
int main (int argc, char *argv[]) {
   char option;

   struct sqlu_media_list *mediaList;
   char timeStamp[SQLU_TIME_STAMP_LEN + 1];
   char nextarcdel[12];
   char firstarcdel[12];
   char lastarcdel[12];

   /* Variables for the BACKUP API */
   unsigned long buff_size;
   unsigned long num_buff;
   struct sqlu_tablespace_bkrst_list *tablespace_list;
   struct SQLB_TBSCONTQRY_DATA *cont;
   struct sqlca sqlca;
   struct sqlu_media_entry media_entry;
   struct sqlu_media_list media_list;
   char applid[SQLU_APPLID_LEN+1];
   char timestamp[SQLU_TIME_STAMP_LEN+1];
   char *target_path;

   unsigned long tsc_id;
   unsigned long num_cont;

   /* variables for the Update Database Configuration API */
   struct sqlfupd itemList;
   short log_retain;

   /* variables for the ROLL FORWARD API */
   char lastCommitTime[SQL_STAMP_STRLEN+1];
   char overFlowLogPath[SQL_PATH_SZ] = TEMPDIR;
/*<--*/

   if (argc != 4) {
      printf ("\nUSAGE: backrest database userID password\n\n");
      return 1;
   } /* endif */


   printf ("this is sample program : backrest.c\n\n");
   printf ("NOTE: for this sample program, there needs to be a backup\n");
   printf ("      directory already created that is accessable by this\n");
   printf ("      program.  On UNIX-based platforms this program sets the\n"); 
   printf ("      directory to '/u/backup'. On OS/2 and Windows-based platforms,\n"); 
   printf ("      it is set to  '\\BACKUP'\n");
   printf ("      Make sure that the database is not in use.\n");
   printf ("Do you wish to continue? (Y/N)   <-- default is 'N'\n");
   option = getc(stdin);
   if (option != 'y' && option != 'Y') return 0;



   /* Altering the default Database Configuration to enable roll-forward
      recovery of the TESTBACK database. */

   log_retain = 1;
   itemList.token = SQLF_DBTN_LOG_RETAIN;
 
   itemList.ptrvalue = (char *) &log_retain;


   printf ("Updating the %s database configuration parameter LOGRETAIN \n", argv[1]);   
   printf ("to 'ON' to enable roll-forward recovery.\n\n");

   /******************************************\
   * UPDATE DATABASE CONFIGURATION API called *
   \******************************************/
   sqlfudb(argv[1], 1, &itemList, &sqlca);
   CHECKERR("updating the database configuration");



  /* Initialize the BACKUP API variables */
   buff_size = 16;
   num_buff = 1;
   tablespace_list = NULL;
   media_list.media_type = 'L';
   media_list.sessions = 1;

   strcpy (media_entry.media_entry, TEMPDIR);

   media_list.target.media = &media_entry;
   printf ("Backing up the '%s' database.\n", argv[1]);
/*-->*/
   /*****************\
   * BACKUP DATABASE *
   \*****************/
   sqlubkup (argv[1],
             buff_size,
             SQLUB_OFFLINE,
             SQLUB_FULL,
             SQLUB_BACKUP,
             applid,
             timestamp,
             num_buff,
             tablespace_list,
             &media_list,
             argv[2],
             argv[3],
             NULL,
             0,
             NULL,
             NULL,
             &sqlca);

/*<--*/
   CHECKERR ("backing up the database");
   printf ("The database has been successfully backed up.\n\n");


   
   /* Altering the default Database Configuration to disable roll-forward
      recovery of the TESTBACK database. */

   log_retain = 0;
   itemList.token = SQLF_DBTN_LOG_RETAIN;
   itemList.ptrvalue = (char *) &log_retain;


   printf ("Updating the %s database configuration parameter LOGRETAIN \n", argv[1]);   
   printf ("to 'OFF'.\n\n");

   /******************************************\
   * UPDATE DATABASE CONFIGURATION API called *
   \******************************************/
   sqlfudb(argv[1], 1, &itemList, &sqlca);
   CHECKERR("updating the database configuration");



   
   /* Initialize the variables for the RESTORE API */
   buff_size = 1024;
   target_path = NULL;
   printf ("Restoring the database '%s' as 'TESTBACK' (1st pass).\n", argv[1]);
   printf ("Should get returned value = SQLUD_INACCESSABLE_CONTAINER.\n");
/*-->*/
   /******************\
   * RESTORE DATABASE *
   \******************/
   sqlursto (argv[1],
             "TESTBACK",
             buff_size,
             SQLUD_ROLLFWD,
             SQLUD_FULL,
             SQLUD_RESTORE_STORDEF,
             applid,
             timestamp,
             target_path,
             num_buff,
             tablespace_list,
             &media_list,
             argv[2],
             argv[3],
             NULL,
             0,
             NULL,
             NULL,
             &sqlca);
/*<--*/
   if (sqlca.sqlcode != SQLUD_INACCESSABLE_CONTAINER)
      CHECKERR ("restoring database");

   printf ("SQLUD_INACCESSABLE_CONTAINER is returned.\n\n");
   printf ("Need to SET TABLESPACES CONTAINERS\n");
   /* Set the containers structure to a new list of containers */
   tsc_id = 1;
   cont = (struct SQLB_TBSCONTQRY_DATA *) malloc
      (sizeof(struct SQLB_TBSCONTQRY_DATA));

   /********************************\
   * GET TABLESPACE CONTAINER QUERY *
   \********************************/
   sqlbtcq (&sqlca, tsc_id, &num_cont, &cont);
   CHECKERR ("GET TABLESPACE CONTAINER QUERY");
   printf ("Tablespace container information for tablespace 1 obtained.\n");
/*-->*/
   /***************************\
   * SET TABLESPACE CONTAINERS *
   \***************************/
   sqlbstsc (&sqlca,
             SQLB_SET_CONT_INIT_STATE,
             tsc_id,
             num_cont,
             cont);
/*<--*/
   CHECKERR ("SET TABLESPACE CONTAINERS");
   printf ("Tablespace containers have been set for tablespace 1.\n\n");

   printf ("Restoring the database '%s' as 'TESTBACK' (2nd pass).\n", argv[1]);
/*-->*/
   /******************\
   * RESTORE DATABASE *
   \******************/
   sqlursto (argv[1],
             "TESTBACK",
             buff_size,
             SQLUD_ROLLFWD,
             SQLUD_FULL,
             SQLUD_CONTINUE,
             applid,
             timestamp,
             target_path,
             num_buff,
             tablespace_list,
             &media_list,
             argv[2],
             argv[3],
             NULL,
             0,
             NULL,
             NULL,
             &sqlca);
/*<--*/
   CHECKERR ("restoring database 2");
   printf ("Database %s has been restored as 'TESTBACK'.\n\n", argv[1]);






/*-->*/
   /***********************\
   * ROLL FORWARD DATABASE *
   \***********************/
   sqlurllf ("TESTBACK",
             SQLUM_ROLLFWD,
             applid,
             SQLUM_INFINITY_TIMESTAMP,
             nextarcdel,
             firstarcdel,
             lastarcdel,
             lastCommitTime,
             argv[2],
             argv[3],
             overFlowLogPath,
             SQLUM_OFFLINE,
             NULL,
             &sqlca);
/*<--*/
   CHECKERR ("rolling forward database");
   printf ("The database 'TESTBACK' has been successfully rolled forward.\n\n", argv[1]);


   /***************\
   * DROP DATABASE *
   \***************/
   sqledrpd ("TESTBACK",
             &sqlca);
   CHECKERR ("DROP DATABASE");
   printf ("The database 'TESTBACK' has been successfully dropped.\n");


   return 0;
}
    &sqk|   $         22\2                ./usr/lpp/db2_02_01/samples/c/db2mon.c 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v v  $        2  22\2           2      ./usr/lpp/db2_02_01/samples/c/evmprint.c .4120/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(ks   $           22\2         H         ./usr/lpp/db2_02_01/samples/c/expsamp.sqc 4120/l                    $          /******************************************************************************
**
** Source File Name = expsamp.sqc  %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 program is an example of how APIs are implemented in order to
**       export and import tables and table data to a DRDA database.
**       The order of the program is as follows:
**          - export a table to an IXF file format
**          - import the IXF file to a DB2 DRDA database table
**       This program needs the embedded SQL calls in order to connect to
**       an existing database, then to create a temporary table to work with.
**
**       For DRDA database imports, the data file format MUST be of the IXF
**       form.  The IMPORT command must be issued an "INSERT" statement.
**
**    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.
**
*****************************************************************************
** !!!!! NOTE !!!!!
** the proper node and database need to be available in order for this to
** work with a DRDA datbase.
** However, if you wish to EXPORT and IMPORT between the SAMPLE database
** and some other database, that already exists, this program will work
** appropriately.
*****************************************************************************
**
**    STRUCTURES USED :
**       sqldcol
**       sqlchar
**       sqluexpt_out
**       sqluimp_in
**       sqluimp_out
**       sqlca
**
**    APIs USED :
**            IMPORT TO             sqluimpr
**            EXPORT                sqlgexpr
**
**    FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**          string.h -  fgets, strncpy
**
**       DBMS LIBRARY :
**          sqlenv.h -  see "APIs USED" above
**
**       OTHER :
**          internal :
**             list_dcs :         Displays a directory of databases
**
**          external :
**             check_error :     Checks for SQLCODE error, and prints out any
**             [in UTIL.C]       related information available.
**
**    EXTERNAL DEPENDANCIES :
**       - Existing database (SAMPLE) for precompile purposes.
**       - Precompile with the SQL precompiler (PREP in DB2)
**       - Binding to a database (BIND in DB2)
**       - Compiling and linking with "xlc" compiler.
**
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include <sqlutil.h>
#ifndef DB2MAC
#include <malloc.h>
#endif
#include "util.h"

#ifdef DB268K
/* Need to include ASLM for 68K applications */
#include <LibraryManager.h>
#endif

#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) return 1;
#define  STMTLEN 80

EXEC SQL INCLUDE SQLCA;
int main (int argc, char *argv[]) {
   short int            callerAction = 0;
   struct sqldcol       columnData;
   struct sqlchar       *columnStringPointer;
   struct sqluexpt_out  outputInfo;
   struct sqluimpt_in   impInput;
   struct sqluimpt_out  impOutput;
   char datafile[] = "EXPTABL1.IXF";
   char datafile2[] = "EXPTABL2.IXF";
   char statement[STMTLEN] = "select * from staff";
   char impStatement[STMTLEN] = "create into impstaff";
   char statement2[STMTLEN] = "select * from org";
   char impStatement2[STMTLEN] = "create into imporg";
   char msgfile_x[] = "EXPMSG.TXT";
   char msgfile_m[] = "IMPMSG.TXT";
   char fileFormat[] = "IXF";

   EXEC SQL BEGIN DECLARE SECTION;
      char username[9];
      char passwd[19];
      char database[9];
      char sqlStatement[256];
   EXEC SQL END DECLARE SECTION;

#ifdef DB268K
   /* Before making any API calls for 68K environment, need to initial the Library Manager */
	InitLibraryManager(0,kCurrentZone,kNormalMemory);
	atexit(CleanupLibraryManager);
#endif

   if (argc < 6) {
      printf ("\nUSAGE: expsamp username passwd DRDA_database DRDA_username "
	 "DRDA_passwd\n\n");
      return 1;
   }

   /* need to preset the size of structure field and counts */
   outputInfo.sizeOfStruct = SQLUEXPT_OUT_SIZE;
   impInput.sizeOfStruct = SQLUIMPT_IN_SIZE;
   impOutput.sizeOfStruct = SQLUIMPT_OUT_SIZE;
   impInput.restartcnt = impInput.commitcnt = 0;

   /******************************************************************\
   * need to allocate the proper amount of space for the SQL statment *
   \******************************************************************/
   columnStringPointer = (struct sqlchar *)malloc(STMTLEN
      + sizeof (struct sqlchar));

   /* DELimited format can not have specified names, therefore the
      column method is 'D'efault */
   columnData.dcolmeth = 'D';

   strcpy (username, argv[1]);
   strcpy (passwd, argv[2]);
					
   printf ("Connecting to SAMPLE database\n");
   /* CONNECTing to the 'sample' database */
   EXEC SQL CONNECT TO sample USER :username USING :passwd;
   CHECKERR ("CONNECT TO database");

   columnStringPointer->length = strlen(statement);
   strncpy (columnStringPointer->data, statement, strlen(statement));
   printf ("Exporting STAFF table into file '%s'\n", datafile);
   /*******************\
   * EXPORT API called *
   \*******************/
   sqluexpr (datafile, NULL, NULL, &columnData, columnStringPointer,
      fileFormat, NULL, msgfile_x, 0, &outputInfo, NULL, &sqlca);
   CHECKERR ("exporting table");
   printf ("Rows exported %d\n", outputInfo.rowsExported);

   columnStringPointer->length = strlen(statement2);
   strncpy (columnStringPointer->data, statement2, strlen(statement2));
   printf ("Exporting ORG table into file '%s'\n", datafile2);
   /*******************\
   * EXPORT API called *
   \*******************/
   sqluexpr (datafile2, NULL, NULL, &columnData, columnStringPointer,
      fileFormat, NULL, msgfile_x, 0, &outputInfo, NULL, &sqlca);
   CHECKERR ("exporting table");
   printf ("Rows exported %d\n", outputInfo.rowsExported);

   strcpy (database, argv[3]);
   strcpy (username, argv[4]);
   strcpy (passwd, argv[5]);
   printf ("Connect to DRDA database\n");
   EXEC SQL CONNECT TO :database USER :username USING :passwd;
   CHECKERR ("CONNECT TO DRDA DATABASE");

   /* drop the table, just incase it already exists */
   strcpy (sqlStatement, "drop table impstaff");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   strcpy (sqlStatement, "drop table imporg");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   strcpy (sqlStatement, "drop index SAMPLE.TESTIND");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   EXEC SQL COMMIT;
   CHECKERR ("COMMIT the DROP TABLE");

   columnStringPointer->length = strlen(impStatement);
   strncpy (columnStringPointer->data, impStatement, strlen(impStatement));
   printf ("Importing the file '%s' into 'impstaff'\n", datafile);
   /*******************\
   * IMPORT API called *
   \*******************/
   sqluimpr (datafile, NULL, &columnData, columnStringPointer, fileFormat,
      NULL, msgfile_m, 0, &impInput, &impOutput, NULL, NULL, &sqlca);
   CHECKERR ("importing table");
   printf ("rows imported %d\nnumber of rows committed %d\n",
      impOutput.rowsInserted, impOutput.rowsCommitted);

   columnStringPointer->length = strlen(impStatement2);
   strncpy (columnStringPointer->data, impStatement2, strlen(impStatement2));
   printf ("importing the file '%s' into 'imporg'\n", datafile2);
   /*******************\
   * IMPORT API called *
   \*******************/
   sqluimpr (datafile2, NULL, &columnData, columnStringPointer, fileFormat,
      NULL, msgfile_m, 0, &impInput, &impOutput, NULL, NULL, &sqlca);
   CHECKERR ("importing table");
   printf ("rows imported %d\nnumber of rows committed %d\n",
      impOutput.rowsInserted, impOutput.rowsCommitted);

   free (columnStringPointer);

   EXEC SQL CONNECT RESET;
   CHECKERR ("CONNECT RESET");
}
/* end of program : expsamp.sqc */
ekF/ x  $        1&  22\2         ;  1&      ./usr/lpp/db2_02_01/samples/c/makeapi.sqc 4120/l                    $          /******************************************************************************
**
** Source File Name = makeapi.sqc  1.14.1.6
**
** 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 program is an example of how API programs are compiled and
**       bounded for DB2 applications.  Input parameters from the command line
**       are as follows:
**             makeapi programName.ext [programName.ext] [databaseName]
**
**       where the first program will be the output name of the application.
**       The program will discern how to compile and link the programs from
**       the extensions that are input from the programName in the command
**       line.  Preparing and Binding will be done on appropriate programs.
**
**
**    STRUCTURES USED :
**       sqlca
**
**    APIs USED :
**       START DATABASE MANAGER     sqlestar()
**       PREOCOMPILE PROGRAM        sqlaprep()
**       BIND                       sqlabndx()
**       STOP DATABASE MANAGER      sqlestop()
**
**    FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**          string.h -  strncpy
**
**       DBMS LIBRARY :
**          sqlenv.h -  see "APIs USED" above
**
**       OTHER :
**
**    EXTERNAL DEPENDANCIES :
**       - 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
**
**    EXAMPLE USAGE:
**       - "makeapi updat.sqc util.obj sample" (OS/2)
**       - "makeapi updat.sqc util.o sample" (UNIX)
**
*******************************************************************************/
/*--> SQLB0X14.C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include "util.h"
/*<-- */

#ifdef DB2OS2
   #define INCL_DOSPROCESS
   #include <os2.h>
   #define StartProgram(CL) DosExecPgm(LoadError,sizeof(LoadError),EXEC_SYNC,\
                               CL,0L,&ReturnCodes,CL);
   #define COMPILER     "icc.exe\0 -c -Ti "
   #define COMPILER_LEN 16
   #define LINKER1      "ilink.exe\0 /NOFREE /MAP /NOI /DEBUG /ST:32000 /PM:VIO "
   #define LINKER_LEN   53
   #define LINKER2      ",,,db2api,;\0\0"
   #define OBJECT_EXT   ".obj"
   #define BINDFILE     " "
#elif defined(DB2AIX)
   #define StartProgram system
   #define COMPILER     "xlc -I/usr/lpp/db2_02_01/include -c "
   #define COMPILER_LEN 36
   #define LINKER1      "xlc -o "
   #define LINKER_LEN   7
   #define LINKER2      " -ldb2 -L/usr/lpp/db2_02_01/lib"
   #define RESULTCODES  int
   #define OBJECT_EXT   ".o"
   #define BINDFILE     programName
#elif defined(DB2WIN)
#endif

#define  STR_ENDER "\0\0"
#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) \
                                return 1;

EXEC SQL INCLUDE SQLCA;

int main (int argc, char *argv[]) {
/*--> */
   struct sqlopt *sqloptStructPointer;
   struct sqloptions *optionsPointer;
/*<-- */
   short allocated = 2, used = 2, rc;
   short nameind, compind, linkind = LINKER_LEN, index, index2;
   char LoadError[100] = "";
   char programName[12] = "";
   char programSrcName[12] = "";
   char programObjName[12] = "";
/*--> */
   char bindName[12] = "";
/*<-- */
   char compiler[255] = COMPILER;
   char linker[255] = LINKER1;
   char linker2[80] = LINKER2;
   RESULTCODES ReturnCodes;
   char *extension;
   char connInput[19];
   char option;

   EXEC SQL BEGIN DECLARE SECTION;
      char dbAlias[9];
      char userid[9];
      char passwd[19];
   EXEC SQL END DECLARE SECTION;

   if (argc < 2) {
      printf ("\nUSAGE : makeapi program(.c/.sqc/" OBJECT_EXT
         ") [db_name]\n\n");
      return 1;
   }

   for (index = 1; index < argc; index++) {   
      extension = strstr(argv[index], ".");
      if (extension == NULL) break;
      if (strcmp(extension, ".sqc") == 0 ||
          strcmp(extension, ".c") == 0 ||
          strcmp(extension, OBJECT_EXT) == 0) {

         /* this input file needs to be compiled and/or linked*/

         nameind = 0;
         while ((argv[index])[nameind] != '.') {
            programName[nameind] = (argv[index])[nameind];
            nameind++;
         } /* endwhile */
         programName[nameind] = '\0';

         strcpy (programSrcName, programName);
         strcat (programSrcName, ".c");

         strcpy (programObjName, programName);
         strcat (programObjName, OBJECT_EXT);


         if (index == 1) {
            strcpy (bindName, BINDFILE);
            for (nameind = 0; nameind < strlen(bindName);
               nameind++, linkind++) {
               linker[linkind] = bindName[nameind];
            } /* endfor */
            strcpy (bindName, programName);
            strcat (bindName, ".bnd");
         } /* endif */

         if (strstr(argv[index], ".sqc") != NULL ||
            strstr(argv[index], ".c") != NULL) {

            if (strstr(argv[index], ".sqc") != NULL) {
               /* the file is an embedded SQL program */

               printf ("--->starting the Database Manager\n");
/*--> */
               /***********************************\
               * START DATABASE MANAGER API called *
               \***********************************/
               sqlestar ();
/*<-- */
               CHECKERR ("START DATABASE MANAGER");

               printf ("input your user id:\n");
               gets (connInput);
               strcpy (userid, connInput);

               printf ("input your passwd:\n");
               gets (connInput);
               strcpy (passwd, connInput);

               printf ("\n--->Connecting to %s database\n", argv[argc - 1]);
               /* by definition of this program, the last argument must be the
                  name of the database */
               strncpy (dbAlias, argv[argc - 1], SQL_ALIAS_SZ);
               EXEC SQL CONNECT TO :dbAlias USER :userid USING :passwd;
               CHECKERR ("CONNECT TO database");
/*--> */
               sqloptStructPointer = (struct sqlopt *) malloc
                  (sizeof (struct sqlopt)
                  + (allocated * sizeof (struct sqloptions)));
               sqloptStructPointer->header.allocated = allocated;
               sqloptStructPointer->header.used = used;
               optionsPointer = sqloptStructPointer->option;
/*<-- */

               optionsPointer->type = SQL_BIND_OPT;
               optionsPointer->val = 0;            /* bind with default name */
               optionsPointer++;
               optionsPointer->type = SQL_PKG_OPT;
               optionsPointer->val = 0;

               printf ("\n--->precompiling the program: %s\n", argv[index]);
/*--> */
               /*******************************\
               * PRECOMPILE PROGRAM API called *
               \*******************************/
               sqlaprep (argv[index], "message.pb1", sqloptStructPointer,
                  &sqlca);
/*<-- */
               CHECKERR ("precompile program");
               printf ("precompiling successful\n");
/*--> */
               /* nullifying the options for the BIND API */
               optionsPointer = sqloptStructPointer->option;
               optionsPointer->type = SQL_NO_OPT;
               optionsPointer->val = 0;
               optionsPointer++;
               optionsPointer->type = SQL_NO_OPT;
               optionsPointer->val = 0;
/*<-- */

               printf ("\n--->binding the application: %s\n", bindName);
/*--> */
               /*****************\
               * BIND API called *
               \*****************/
               sqlabndx (bindName, "message.pb2", sqloptStructPointer, &sqlca);
/*<-- */
               CHECKERR ("binding the application");

               printf ("\n--->connect resetting\n");
               EXEC SQL CONNECT RESET;
               CHECKERR ("CONNECT RESET");

               printf ("\nWould you like to stop the Database Manager? (y/n)\n");

               option = getc(stdin);
               if (option == 'y') {
                  printf ("\n--->stopping the Database Manager\n");
/*--> */
                  /**********************************\
                  * STOP DATABASE MANAGER API called *
                  \**********************************/
                  sqlestop (&sqlca);
/*<-- */
                  CHECKERR ("stopping database manager");
               } /* endif */
            } /* endif */

            for (nameind = 0, compind = COMPILER_LEN;
               nameind < strlen(programSrcName); nameind++, compind++) {
               compiler[compind] = programSrcName[nameind];
            } /* endfor */
            compiler[compind] = '\0';

            /* executing the compiler */
            printf ("\n--->compiling %s\n", programSrcName);
            rc = StartProgram (compiler);
            printf ("return value = %d\n",rc);

         }
         linker[linkind++] = ' ';
         for (nameind = 0;
            nameind < strlen(programObjName); nameind++, linkind++) {
            linker[linkind] = programObjName[nameind];
         } /* endfor */
      } else {
         if (extension != NULL)
            printf (":%s: can not be compiled, must end with '.c' or '.sqc'\n",
            argv[index]);
      }
   } /* endfor */


   for (index = 0; index < strlen(linker2); index++, linkind++) {
      linker[linkind] = linker2[index];
   } /* endfor */

   /* executing the linker */
   printf ("\n--->linking program\n");
   rc = StartProgram (linker);
   printf ("return value = %d\n",rc);
   return 0;
}
/* end of program : makeapi.sqc */
f ("inpkS 2  $          22\2         m        ./usr/lpp/db2_02_01/samples/c/rechist.c                     $          /*******************************************************************************
**
** Source File Name = rechist.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 :
**       an example showing how to use RECOVERY HISTORY FILE
**       SCAN APIs in order to:
**          - Update a Recovery History File
**          - List the contents of a Recovery History File
**          - Prune the Recovery History File
**
**    APIs USED :
**      BACKUP DATABASE                         sqlubkup
**      OPEN RECOVERY HISTORY FILE SCAN         sqluhops
**      GET NEXT RECOVERY HISTORY FILE ENTRY    sqluhgne
**      CLOSE RECOVERY HISTORY FILE SCAN        sqluhcls
**      UPDATE RECOVERY HISTORY FILE            sqluhupd
**      PRUNE RECOVERY HISTORY FILE             sqluhprn
**
**    STRUCTURES USED :
**       sqlca
**
**    OTHER FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**
**       internal :
**          list_rhf :         Displays a directory of databases
**
**       external :
**          check_error :     Checks for SQLCODE error, and prints out any
**          [in UTIL.C]          related information available.
**                               This procedure is located in the UTIL.C file.
**
**    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.
**
**       NOTE: To run this example, the DB2DBDFT environment variable
**             must be set to "sample".
**
*******************************************************************************/
/*--> SQLB0X18.C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlutil.h>
#include <sqlenv.h>
#include "util.h"
/*<-- */

#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) return 1;

int list_rhf (struct sqlca, char *, char *);

int main (int argc, char *argv[]) {
   struct sqlca sqlca;

   /* Variables for the BACKUP DATABASE API */
   struct sqlu_media_list mediaList;
   char applid[SQLU_APPLID_LEN+1];

/*--> */
   char timestamp[SQLU_TIME_STAMP_LEN+1];
   char objectPart[SQLU_TIME_STAMP_LEN+4];
/*<-- */

   char location[SQLU_DB_DIR_LEN+1];
   unsigned short forceOption;


   if (argc != 4) {
      printf ("\nUSAGE: rechist dbname userid passwd\n\n");
      return 1;
   } /* endif */
   printf( "Sample C program: RECHIST.C\n" );



   mediaList.target.media = (struct sqlu_media_entry *) malloc (sizeof(struct sqlu_media_entry));
   mediaList.media_type = 'L';
   mediaList.sessions   = 1;

   #if (defined(DB2AIX) || defined(DB2SUN) || defined(DB2HP) \
	|| defined(DB2SNI) || defined(DB2SCO) || defined(DB2SGI))
   strcpy (mediaList.target.media->media_entry, "/dev/null");
   #else
   strcpy (mediaList.target.media->media_entry, "NUL");
   #endif

   printf ("creating a history file entry ... backing up the database to null\n");
   /*****************\
   * BACKUP DATABASE *
   \*****************/
   sqlubkup (argv[1], 0, 0, 0, 0, applid, timestamp, 0, NULL, &mediaList,
      argv[2], argv[3], NULL, 0, NULL, NULL, &sqlca);
   CHECKERR ("BACKUP DATABASE");

   strcpy(objectPart, timestamp);
   strcat(objectPart, "001");
   printf ("object part = :%s:\n", objectPart);

   printf ("updating the recovery history file...\n");
/*--> */
   /******************************\
   * UPDATE RECOVERY HISTORY FILE *
   \******************************/
   sqluhupd (objectPart , NULL, NULL, "THIS IS A COMMENT", NULL, &sqlca);
/*<-- */
   CHECKERR ("TEST UPDATE");
/*   sqluhupd (&objectPart, &newLocation, &newDeviceType, &newComment, NULL,
      &sqlca);
*/
   CHECKERR ("UPDATE RECOVERY HISTORY FILE");

   printf ("listing all entries to the recovery history file...\n");
   list_rhf (sqlca, timestamp, argv[1]);

   printf ("Pruning the recovery history file...\n");
/*--> */
   /*****************************\
   * PRUNE RECOVERY HISTORY FILE *
   \*****************************/
   sqluhprn (timestamp, 1, NULL, &sqlca);
/*<-- */
   CHECKERR ("PRUNE RECOVERY HISTORY FILE");

   printf ("listing all entries to the recovery history file [after PRUNE]\n");
   list_rhf (sqlca, timestamp, argv[1]);

   return 0;
}

/*--> SQLB0X36.C */
/*******************************************************************************
** Procedure : list_rhf
**
** Purpose :   This procedure displays the data contained in each recovery
**             history file entry.
**
*******************************************************************************/
int list_rhf (struct sqlca sqlca, char *tstamp, char *dbname) {
   short idx;
   unsigned short count;
   unsigned short handle;
   unsigned short callerac = 1;   /* for history */
   char *database = "sample";
   char *objectName = "\0";
   struct sqluhinfo *buffer;

   /*********************************\
   * OPEN RECOVERY HISTORY FILE SCAN *
   \*********************************/
   sqluhops (dbname, tstamp, objectName, &count, &handle, callerac,
      NULL, &sqlca);
/*<-- */
   CHECKERR ("OPEN RECOVERY HISTORY FILE SCAN");
   printf ("count = %d\ntimestamp = %s\n", count, tstamp);

   buffer = (struct sqluhinfo *) malloc (SQLUHINFOSIZE(count));
   buffer->sqln = count;

   do {
/*--> */
      /**************************************\
      * GET NEXT RECOVERY HISTORY FILE ENTRY *
      \**************************************/
      sqluhgne (handle, NULL, buffer, &sqlca);
/*<-- */
      if (sqlca.sqlcode == SQLUH_SQLUHINFO_VARS_WARNING) {

         count = buffer->sqld;
         free (buffer);

         buffer = (struct sqluhinfo *) malloc (SQLUHINFOSIZE(count));
         buffer->sqln = count;

      } else if (sqlca.sqlcode == SQLE_RC_NOMORE) {
         break;
      } else {
printf ("need to print out the information from the sqluhinfo struct\n\n");
/* need to print out the buffer information at this point */
         CHECKERR ("GET NEXT RECOVERY HISTORY FILE SCAN");
      } /* endif */
   } while ( 1 ); /* enddo */

/*--> */
   /**********************************\
   * CLOSE RECOVERY HISTORY FILE SCAN *
   \**********************************/
   sqluhcls (handle, NULL, &sqlca);
/*<-- */
   CHECKERR ("CLOSE RECOVERY HISTORY FILE SCAN");
   return 0;
}
TIk
 ",
          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(ks   $           22\2         H         ./usr/lpp/db2_02_01/samples/c/expsamp.sqc 4120/l                    $          /******************************************************************************
**
** Source File Name = expsamp.sqc  %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 program is an example of how APIs are implemented in order to
**       export and import tables and table data to a DRDA database.
**       The order of the program is as follows:
**          - export a table to an IXF file format
**          - import the IXF file to a DB2 DRDA database table
**       This program needs the embedded SQL calls in order to connect to
**       an existing database, then to create a temporary table to work with.
**
**       For DRDA database imports, the data file format MUST be of the IXF
**       form.  The IMPORT command must be issued an "INSERT" statement.
**
**    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.
**
*****************************************************************************
** !!!!! NOTE !!!!!
** the proper node and database need to be available in order for this to
** work with a DRDA datbase.
** However, if you wish to EXPORT and IMPORT between the SAMPLE database
** and some other database, that already exists, this program will work
** appropriately.
*****************************************************************************
**
**    STRUCTURES USED :
**       sqldcol
**       sqlchar
**       sqluexpt_out
**       sqluimp_in
**       sqluimp_out
**       sqlca
**
**    APIs USED :
**            IMPORT TO             sqluimpr
**            EXPORT                sqlgexpr
**
**    FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**          string.h -  fgets, strncpy
**
**       DBMS LIBRARY :
**          sqlenv.h -  see "APIs USED" above
**
**       OTHER :
**          internal :
**             list_dcs :         Displays a directory of databases
**
**          external :
**             check_error :     Checks for SQLCODE error, and prints out any
**             [in UTIL.C]       related information available.
**
**    EXTERNAL DEPENDANCIES :
**       - Existing database (SAMPLE) for precompile purposes.
**       - Precompile with the SQL precompiler (PREP in DB2)
**       - Binding to a database (BIND in DB2)
**       - Compiling and linking with "xlc" compiler.
**
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include <sqlutil.h>
#ifndef DB2MAC
#include <malloc.h>
#endif
#include "util.h"

#ifdef DB268K
/* Need to include ASLM for 68K applications */
#include <LibraryManager.h>
#endif

#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) return 1;
#define  STMTLEN 80

EXEC SQL INCLUDE SQLCA;
int main (int argc, char *argv[]) {
   short int            callerAction = 0;
   struct sqldcol       columnData;
   struct sqlchar       *columnStringPointer;
   struct sqluexpt_out  outputInfo;
   struct sqluimpt_in   impInput;
   struct sqluimpt_out  impOutput;
   char datafile[] = "EXPTABL1.IXF";
   char datafile2[] = "EXPTABL2.IXF";
   char statement[STMTLEN] = "select * from staff";
   char impStatement[STMTLEN] = "create into impstaff";
   char statement2[STMTLEN] = "select * from org";
   char impStatement2[STMTLEN] = "create into imporg";
   char msgfile_x[] = "EXPMSG.TXT";
   char msgfile_m[] = "IMPMSG.TXT";
   char fileFormat[] = "IXF";

   EXEC SQL BEGIN DECLARE SECTION;
      char username[9];
      char passwd[19];
      char database[9];
      char sqlStatement[256];
   EXEC SQL END DECLARE SECTION;

#ifdef DB268K
   /* Before making any API calls for 68K environment, need to initial the Library Manager */
	InitLibraryManager(0,kCurrentZone,kNormalMemory);
	atexit(CleanupLibraryManager);
#endif

   if (argc < 6) {
      printf ("\nUSAGE: expsamp username passwd DRDA_database DRDA_username "
	 "DRDA_passwd\n\n");
      return 1;
   }

   /* need to preset the size of structure field and counts */
   outputInfo.sizeOfStruct = SQLUEXPT_OUT_SIZE;
   impInput.sizeOfStruct = SQLUIMPT_IN_SIZE;
   impOutput.sizeOfStruct = SQLUIMPT_OUT_SIZE;
   impInput.restartcnt = impInput.commitcnt = 0;

   /******************************************************************\
   * need to allocate the proper amount of space for the SQL statment *
   \******************************************************************/
   columnStringPointer = (struct sqlchar *)malloc(STMTLEN
      + sizeof (struct sqlchar));

   /* DELimited format can not have specified names, therefore the
      column method is 'D'efault */
   columnData.dcolmeth = 'D';

   strcpy (username, argv[1]);
   strcpy (passwd, argv[2]);
					
   printf ("Connecting to SAMPLE database\n");
   /* CONNECTing to the 'sample' database */
   EXEC SQL CONNECT TO sample USER :username USING :passwd;
   CHECKERR ("CONNECT TO database");

   columnStringPointer->length = strlen(statement);
   strncpy (columnStringPointer->data, statement, strlen(statement));
   printf ("Exporting STAFF table into file '%s'\n", datafile);
   /*******************\
   * EXPORT API called *
   \*******************/
   sqluexpr (datafile, NULL, NULL, &columnData, columnStringPointer,
      fileFormat, NULL, msgfile_x, 0, &outputInfo, NULL, &sqlca);
   CHECKERR ("exporting table");
   printf ("Rows exported %d\n", outputInfo.rowsExported);

   columnStringPointer->length = strlen(statement2);
   strncpy (columnStringPointer->data, statement2, strlen(statement2));
   printf ("Exporting ORG table into file '%s'\n", datafile2);
   /*******************\
   * EXPORT API called *
   \*******************/
   sqluexpr (datafile2, NULL, NULL, &columnData, columnStringPointer,
      fileFormat, NULL, msgfile_x, 0, &outputInfo, NULL, &sqlca);
   CHECKERR ("exporting table");
   printf ("Rows exported %d\n", outputInfo.rowsExported);

   strcpy (database, argv[3]);
   strcpy (username, argv[4]);
   strcpy (passwd, argv[5]);
   printf ("Connect to DRDA database\n");
   EXEC SQL CONNECT TO :database USER :username USING :passwd;
   CHECKERR ("CONNECT TO DRDA DATABASE");

   /* drop the table, just incase it already exists */
   strcpy (sqlStatement, "drop table impstaff");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   strcpy (sqlStatement, "drop table imporg");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   strcpy (sqlStatement, "drop index SAMPLE.TESTIND");
   EXEC SQL EXECUTE IMMEDIATE :sqlStatement;
   EXEC SQL COMMIT;
   CHECKERR ("COMMIT the DROP TABLE");

   columnStringPointer->length = strlen(impStatement);
   strncpy (columnStringPointer->data, impStatement, strlen(impStatement));
   printf ("Importing the file '%s' into 'impstaff'\n", datafile);
   /*******************\
   * IMPORT API called *
   \*******************/
   sqluimpr (datafile, NULL, &columnData, columnStringPointer, fileFormat,
      NULL, msgfile_m, 0, &impInput, &impOutput, NULL, NULL, &sqlca);
   CHECKERR ("importing table");
   printf ("rows imported %d\nnumber of rows committed %d\n",
      impOutput.rowsInserted, impOutput.rowsCommitted);

   columnStringPointer->length = strlen(impStatement2);
   strncpy (columnStringPointer->data, impStatement2, strlen(impStatement2));
   printf ("importing the file '%s' into 'imporg'\n", datafile2);
   /*******************\
   * IMPORT API called *
   \*******************/
   sqluimpr (datafile2, NULL, &columnData, columnStringPointer, fileFormat,
      NULL, msgfile_m, 0, &impInput, &impOutput, NULL, NULL, &sqlca);
   CHECKERR ("importing table");
   printf ("rows imported %d\nnumber of rows committed %d\n",
      impOutput.rowsInserted, impOutput.rowsCommitted);

   free (columnStringPointer);

   EXEC SQL CONNECT RESET;
   CHECKERR ("CONNECT RESET");
}
/* end of program : expsamp.sqc */
ekF/ x  $        1&  22\2         ;  1&      ./usr/lpp/db2_02_01/samples/c/makeapi.sqc 4120/l                    $          /******************************************************************************
**
** Source File Name = makeapi.sqc  1.14.1.6
**
** 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 program is an example of how API programs are compiled and
**       bounded for DB2 applications.  Input parameters from the command line
**       are as follows:
**             makeapi programName.ext [programName.ext] [databaseName]
**
**       where the first program will be the output name of the application.
**       The program will discern how to compile and link the programs from
**       the extensions that are input from the programName in the command
**       line.  Preparing and Binding will be done on appropriate programs.
**
**
**    STRUCTURES USED :
**       sqlca
**
**    APIs USED :
**       START DATABASE MANAGER     sqlestar()
**       PREOCOMPILE PROGRAM        sqlaprep()
**       BIND                       sqlabndx()
**       STOP DATABASE MANAGER      sqlestop()
**
**    FUNCTIONS DECLARED :
**       'C' COMPILER LIBRARY :
**          stdio.h  -  printf
**          string.h -  strncpy
**
**       DBMS LIBRARY :
**          sqlenv.h -  see "APIs USED" above
**
**       OTHER :
**
**    EXTERNAL DEPENDANCIES :
**       - 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
**
**    EXAMPLE USAGE:
**       - "makeapi updat.sqc util.obj sample" (OS/2)
**       - "makeapi updat.sqc util.o sample" (UNIX)
**
*******************************************************************************/
/*--> SQLB0X14.C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include "util.h"
/*<-- */

#ifdef DB2OS2
   #define INCL_DOSPROCESS
   #include <os2.h>
   #define StartProgram(CL) DosExecPgm(LoadError,sizeof(LoadError),EXEC_SYNC,\
                               CL,0L,&ReturnCodes,CL);
   #define COMPILER     "icc.exe\0 -c -Ti "
   #define COMPILER_LEN 16
   #define LINKER1      "ilink.exe\0 /NOFREE /MAP /NOI /DEBUG /ST:32000 /PM:VIO "
   #define LINKER_LEN   53
   #define LINKER2      ",,,db2api,;\0\0"
   #define OBJECT_EXT   ".obj"
   #define BINDFILE     " "
#elif defined(DB2AIX)
   #define StartProgram system
   #define COMPILER     "xlc -I/usr/lpp/db2_02_01/include -c "
   #define COMPILER_LEN 36
   #define LINKER1      "xlc -o "
   #define LINKER_LEN   7
   #define LINKER2      " -ldb2 -L/usr/lpp/db2_02_01/lib"
   #define RESULTCODES  int
   #define OBJECT_EXT   ".o"
   #define BINDFILE     programName
#elif defined(DB2WIN)
#endif

#define  STR_ENDER "\0\0"
#define  CHECKERR(CE_STR)   if (check_error (CE_STR, &sqlca) != 0) \
                                return 1;

EXEC SQL INCLUDE SQLCA;

int main (int argc, char *argv[]) {
/*--> */
   struct sqlopt *sqloptStructPointer;
   struct sqloptions *optionsPointer;
/*<-- */
   short allocated = 2, used = 2, rc;
   short nameind, compind, linkind = LINKER_LEN, index, index2;
   char LoadError[100] = "";
   char programName[12] = "";
   char programSrcName[12] = "";
   char programObjName[12] = "";
/*--> */
   char bindName[12] = "";
/*<-- */
   char compiler[255] = COMPILER;
   char linker[255] = LINKER1;
   char linker2[80] = LINKER2;
   RESULTCODES ReturnCodes;
   char *extension;
   char connInput[19];
   char option;

   EXEC SQL BEGIN DECLARE SECTION;
      char dbAlias[9];
      char userid[9];
      char passwd[19];
   EXEC SQL END DECLARE SECTION;

   if (argc < 2) {
      printf ("\nUSAGE : makeapi program(.c/.sqc/" OBJECT_EXT
         ") [db_name]\n\n");
      return 1;
   }

   for (index = 1; index < argc; index++) {   
      extension = strstr(argv[index], ".");
      if (extension == NULL) break;
      if (strcmp(extension, ".sqc") == 0 ||
          strcmp(extension, ".c") == 0 ||
          strcmp(extension, OBJECT_EXT) == 0) {

         /* this input file needs to be compiled and/or linked*/

         nameind = 0;
         while ((argv[index])[nameind] != '.') {
            programName[nameind] = (argv[index])[nameind];
            nameind++;
         } /* endwhile */
         programName[nameind] = '\0';

         strcpy (programSrcName, programName);
         strcat (programSrcName, ".c");

         strcpy (programObjName, programName);
         strcat (programObjName, OBJECT_EXT);


         if (index == 1) {
            strcpy (bindName, BINDFILE);
            for (nameind = 0; nameind < strlen(bindName);
               nameind++, linkind++) {
               linker[linkind] = bindName[nameind];
            } /* endfor */
            strcpy (bindName, programName);
            strcat (bindName, ".bnd");
         } /* endif */

         if (strstr(argv[index], ".sqc") != NULL ||
            strstr(argv[index], ".c") != NULL) {

            if (strstr(argv[index], ".sqc") != NULL) {
               /* the file is an embedded SQL program */

               printf ("--->starting the Database Manager\n");
/*--> */
               /***********************************\
               * START DATABASE MANAGER API called *
               \***********************************/
               sqlestar ();
/*<-- */
               CHECKERR ("START DATABASE MANAGER");

               printf ("input your user id:\n");
               gets (connInput);
               strcpy (userid, connInput);

               printf ("input your passwd:\n");
               gets (connInput);
               strcpy (passwd, connInput);

               printf ("\n--->Connecting to %s database\n", argv[argc - 1]);
               /* by definition of this program, the last argument must be the
                  name of the database */
               strncpy (dbAlias, argv[argc - 1], SQL_ALIAS_SZ);
               EXEC SQL CONNECT TO :dbAlias USER :userid USING :passwd;
               CHECKERR ("CONNECT TO database");
/*--> */
               sqloptStructPointer = (struct sqlopt *) malloc
                  (sizeof (struct sqlopt)
                  + (allocated * sizeof (struct sqloptions)));
               sqloptStructPointer->header.allocated = allocated;
               sqloptStructPointer->header.used = used;
               optionsPointer = sqloptStructPointer->option;
/*<-- */

               optionsPointer->type = SQL_BIND_OPT;
               optionsPointer->val = 0;            /* bind with default name */
               optionsPointer++;
               optionsPointer->type = SQL_PKG_OPT;
               optionsPointer->val = 0;

               printf ("\n--->precompiling the program: %s\n", argv[index]);
/*--> */
               /*******************************\
               * PRECOMPILE PROGRAM API called *
               \*******************************/
               sqlaprep (argv[index], "message.pb1", sqloptStructPointer,
                  &sqlca);
/*<-- */
               CHECKERR ("precompile program");
               printf ("precompiling successful\n");
/*--> */
               /* nullifying the options for the BIND API */
               optionsPointer = sqloptStructPointer->option;
               optionsPointer->type = SQL_NO_OPT;
               optionsPointer->val = 0;
               optionsPointer++;
               optionsPointer->type = SQL_NO_OPT;
               optionsPointer->val = 0;
/*<-- */

               printf ("\n--->binding the application: %s\n", bindName);
/*--> */
               /*****************\
               * BIND API called *
               \*****************/
               sqlabndx (bindName, "message.pb2", sqloptStructPointer, &sqlca);
/*<-- */
               CHECKERR ("binding the application");

               printf ("\n--->connect resetting\n");
               EXEC SQL CONNECT RESET;
               CHECKERR ("CONNECT RESET");

               printf ("\nWould you like to stop the Database Manager? (y/n)\n");

               option = getc(stdin);
               if (option == 'y') {
                  printf ("\n--->stopping the Database Manager\n");
/*--> */
                  /**********************************\
                  * STOP DATABASE MANAGER API called *
                  \**********************************/
                  sqlestop (&sqlca);
/*<-- */
                  CHECKERR ("stopping database manager");
               } /* endif */
            } /* endif */

            for (nameind = 0, compind = COMPILER_LEN;
               nameind < strlen(programSrcName); nameind++, compind++) {
               compiler[compind] = programSrcName[nameind];
            } /* endfor */
            compiler[compind] = '\0';

            /* executing the compiler */
            printf ("\n--->compil