Host variables are COBOL
language variables that are referenced within SQL statements. Host
variables allow an application to exchange data with the database
manager.
After the application is precompiled, host variables are used
by the compiler as any other COBOL variable. Follow the rules described
in the following sections when naming, declaring, and using host
variables.
Declare section for host variables in COBOL embedded SQL applications
You must use an SQL
declare section must be used to identify host variable declarations.
The SQL declare section alerts the precompiler to any host variables
that can be referenced in subsequent SQL statements.
SQLSTATE and SQLCODE Variables in COBOL embedded SQL application
To handle errors or
debug your embedded SQL application, you should test the values of
the SQLCODE or SQLSTATE variable. You can return these values as output
parameters or as part of a diagnostic message string, or you can insert
these values into a table to provide basic tracing support.
Declaration of numeric host variables in COBOL embedded SQL applications
Numeric host variables
that you declare in your embedded COBOL application are treated as
if they were declared in a COBOL program. You can use host variables
to exchange data between the embedded application and the database
manager.
Declaration of large object type host variables in COBOL embedded SQL applications
Large object (LOB) type
host variables that you declare in your embedded COBOL application
are treated as if they were declared in a COBOL program. You can use
host variables to exchange data between the embedded application and
the database manager.
Grouping data items using REDEFINES in COBOL embedded SQL applications
You can use the REDEFINES
clause when declaring host variables. If you declare a member of a
group data item 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 are not expanded.