SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-40
SQLMEM
length
is the number of bytes that are available at address for the data structures.
This length should be large enough to hold the largest SQL statement
description expected in your program (that is, the sum in bytes of the SQLIN,
SQLIVARS, and SQLOVARS structures).
The value cannot exceed 65,536.
You can use a constant or a literal for length. When you use a literal, the
compiler evaluates the name as for address, in the same scope as the SQL
statement being compiled.
Follow these steps to estimate a value for length:
1. Compile the program with a high value. Use the information under
Estimating Sizes for SQLIN and SQLVARS on page 3-41 to estimate the
value.
2. Check the compiler listing. When SQLMEM MAPPED is specified, the
listing shows the total size needed to store the SQL data structures for
each SQL statement by printing the this message after each SQL
statement:
SQLMEM: MOVEX length = movex-length.
The maximum size needed is also computed and printed at the end of the
listing with the message:
SQLMEM: Maximum MOVEX length = maximum-length.
If length is too small, the compiler generates an error.
3. If necessary, change the length to a value at least equal to the maximum
MOVEX length as shown at the end of the listing.
Ensuring That SQL Data Structures Are Accessible
The following data structures must be accessible in the active extended segment
whenever your program executes an SQL statement:
SQLIN for the specific statement
SQLIVARS and SQLOVARS (together called SQLVARS) for the input and output
host variables in the statement. The host variables themselves must also be
accessible. For a static OPEN, any host variables referenced in the DECLARE
CURSOR statement must also be accessible.
SQLCA structure for error handling
SQLSA structure for statistics and dynamic SQL
The SQLCA and SQLSA structures are always allocated on the standard data stack.
SQLIN and SQLVARS are allocated by default in the default extended segment, or by
the programmer using SQLMEM.