SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-41
SQLMEM
Estimating Sizes for SQLIN and SQLVARS
The size estimates for the SQL data structures are:
To estimate the size of the SQLIVARS and SQLOVARS structures, use this formula:
size = (4 + 24 * n ) bytes
where n is the number of host variables. For example, for the statement:
SELECT * FROM table WHERE col1 = :a AND col2 = :b ;
where TABLE has 200 columns, you would need 4804 bytes to store the SQLOVARS
structure for the host variables to receive the column values, plus 52 bytes to store the
SQLIVARS structure for the host variables to supply values for the WHERE clause.
Using Shared Memory
If you are using shared memory, consider these items, which apply to any shared
memory situation in TAL:
If two or more programs use the same data area for SQL data structures, you must
protect each SQL statement from concurrent execution of other SQL statements.
To avoid this situation, use different areas of memory for each program or
synchronize access to the shared segment.
If you place the SQL data structures in a read-only data segment, obscure errors
can occur as a result of interactions with the operating system.
Recommendations
For various programming environments follow these general guidelines. Specific
programs, however, might require different analysis and methods.
If your program does not need to manage extended segments, omit SQLMEM and
allow the compiler to place the SQLIN and SQLVARS structures in the default
extended segment. If your program has few SQL statements, the statements are
small, and you do not expect to add statements, use SQLMEM USER.
If your program was written before the availability of the default extended segment
and the program manages its own extended segments with the
ALLOCATESEGMENT and USESEGMENT procedures, use one of these choices
(listed in order of preference):
°
Specify the USER option if your program has a small number of SQL
statements, the statements reference a small number of host variables, and
you do not expect to add statements.
Structure Size, Bytes
SQLCA 430 (approximate)
SQLSA 838 (approximate)
SQLIN 72