SQL/MP Version Management Guide

Version Compatibility for SQL Programs
Compaq NonStop™ SQL/MP Version Management Guide429833-001
7-6
Version Independent SQL Data Structures
specify INCLUDE STRUCTURES ALL VERSION 2 or INCLUDE STRUCTURES
SQLDA 2.
To continue using version 1 SQLDA structures in a version 300 or newer program,
follow the guidelines for converting to a version 300 or newer SQLDA, but use the
INCLUDE STRUCTURES ALL VERSION 1 directive or the INCLUDE
STRUCTURES SQLDA 1 directive.
If you need a version 300 or newer SQLDA in one part of a program but do not want to
convert any other SQLDA structures in the program to a newer version, still another
special situation arises. Version 300 and newer versions do not permit multiple versions
of an SQLDA in a single module of a program. Therefore, in this case, you have two
choices:
Convert all SQLDA structures to version 300 or newer, as described previously.
This recommendation requires extra effort but is the safest choice.
Separate your program into separately compiled modules in such a way that all
version 300 or newer SQLDA structures, along with any supporting code, are in
different modules from version 1 or version 2 SQLDA structures. Specify a different
INCLUDE STRUCTURES directive in each module then host compile each
module.
If you choose to use separate modules with different version SQLDA structures, be
careful not to specify two different SQLDA structures with the same name but with
different versions in the global scope of each module. For more details on this topic, see
Declaring SQL Data Structures in the Global Scope
on page 7-6.
Declaring SQL Data Structures in the Global Scope
In TAL, C, and Pascal programs (but not in COBOL85 programs), you can declare an
SQL data structure as a global variable by placing a global-scope declaration of the
INCLUDE SQLCA, INCLUDE SQLDA, or INCLUDE SQLSA directive in any
module. When SQL data structures are declared as global variables, they follow the
same host language and Binder rules that apply to any language variable declared in
global scope.
When you use SQL data structures in a program, follow these rules of scope:
In a C or Pascal program, place an INCLUDE SQLCA or INCLUDE SQLSA
directive in the global scope of only one module. In a TAL program, place an
INCLUDE SQLCA or INCLUDE SQLSA directive in the public block of only one
module; an SQLCA or SQLDA declared in the private block does not conflict with
these declarations in any other module.
You can declare individual SQLDA structures in different modules of a program if
the names you specify in each INCLUDE SQLDA directive do not conflict with any
SQLDA structures declared globally in the program.
If you want to share a global data structure (SQLCA, SQLSA, or SQLDA) across
several modules, include the structure in one module and declare it as an external
structure in the other modules.