SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-39
SQLMEM
For example, a host variable used in a DECLARE CURSOR statement is not
accessed when the DECLARE CURSOR statement is processed; it is accessed
when the cursor is opened.
STACK
places the SQL data structures in the default extended segment only initially. Before an
SQL statement executes, the system allocates space at the top of the stack and issues
a MOVEX procedure call to copy the SQL data structures needed for that statement to
the top of the stack. After each SQL statement executes, the system deallocates the
top of the stack.
The STACK option allows you to have any extended segment active at the time an
SQL statement executes, because the MOVEX procedure can copy data from inactive
segments. In programs that are close to using all their stack space, however, using the
STACK option can cause a stack overflow because extra stack space must be used to
temporarily hold the SQL data structures.
When an error is returned from a generated call to the MOVEX procedure, the TAL
compiler sets SQLCODE to 254. If an SQLCA structure is present, NonStop SQL also
sets this error in the SQLCA.
The STACK option cannot appear in a subprocedure.
MAPPED address length
places the SQL data structures in the default extended segment only initially. Before
each SQL statement, the system calls the MOVEX procedure to copy the SQL data
structures to a location in memory you specify in the currently active extended
segment. Because moving data between segments is slower than moving data to the
stack, the MAPPED option can degrade system performance.
To use the MAPPED option, your SOURCE directive for
$SYSTEM.SYSTEM.EXTDECS must specify the MOVEX and USESEGMENT
procedures.
Use the MAPPED option if your program manages extended segments with the
USESEGMENT procedure and does one of these:
Does not use the default extended segment
Contains SQL statements that refer to host variables located in a segment other
than the default extended segment and you do not have enough memory available
in the data stack to select the USER or STACK option.
address
is the address in the current extended segment where you want the compiler to
place the data structures. This address can be a constant, literal, or variable
string (data type STRING .EXT). When you use a variable or literal, the
compiler evaluates the name in the same scope as the SQL statement being
compiled, and not where the SQLMEM directive appears.