	 kVk J3J3by name         by name         service         d   
kZI o
             J3J3J3         $-        ./lpp_name                                    4 R S db2_02_01 {
db2_02_01.sdk.c 04.01.0002.4124 1 N U US_ENG DB2 C Language Include Files and Samples
[
*prereq db2_02_01.sdk.c 4.1.2.0

*ifreq db2_02_01.client 04.01.0002.4124
%
/usr/lpp/db2_02_01/include/sql.h 144
/usr/lpp/db2_02_01/include/sqlaprep.h 136
]
}
kp            J3J3J3               ./usr/lpp/db2_02_01/db2_02_01.sdk.c/4.1.2.4124/liblpp.a                               <aiaff>
100274      0           68          1942        0           509         678         0           868549064   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.
 73          860         68          868567733   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
 79          1050        678         868567734   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 136
 73          1236        860         868567733   2379        200         644         22  db2_02_01.sdk.c.prereq`
*prereq db2_02_01.sdk.c 4.1.2.0

*ifreq db2_02_01.client 04.01.0002.4124
 77          1430        1050        868558180   2379        200         644         26  db2_02_01.sdk.cobol.prereq`
*prereq db2_02_01.sdk.cobol 4.1.2.0

*ifreq db2_02_01.client 04.01.0002.4124
 75          1620        1236        868558186   2379        200         644         24  db2_02_01.sdk.cli.prereq`
*prereq db2_02_01.sdk.cli 4.1.2.0

*ifreq db2_02_01.client 04.01.0002.4124
 205         1942        1430        868567734   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 = 73035

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

 98232       100274      1620        868567236   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           1942        0           0           0           0           0   `
8           68          678         860         1050        1236        1430        1620        1942        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  stoppkdI Z  $        K F3F38I3           K     ./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_CNULREQD_OPT       11      /* Option for adding NULLs to strings  */
                                       /* - bind 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_CNULREQD_OPT      */
#define SQL_CNULREQD_NO        0       /* C NULL value not required           */
#define SQL_CNULREQD_YES       1       /* C NULL value required               */

/* 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 */
mory k|2 ]  $        * F3F38I3           *     ./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_CNULREQD_OPT      SQL_CNULREQD_OPT  /* C NULL required option    */
#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_CNULREQD_OPT in  */
/* the Precompiler Option array                                               */
#define SQLA_CNULREQD_NO       SQL_CNULREQD_NO   /* C NULL is not required    */
#define SQLA_CNULREQD_YES      SQL_CNULREQD_YES  /* C NULL is not required    */

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

#pragma options align=reset

#ifdef __cplusplus 
}
#endif

#endif /* SQL_H_SQLAPREP */
L statk
 R_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_CNULREQD_OPT in  */
/* the Precompiler Option array                                               */
#define SQLA_CNULREQD_NO       SQL_CNULREQD_NO   /* C NULL is not required    */
#define SQLA_CNULREQD_YES      SQL_CNULREQD_YES  /* C NULL is not required    */

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