![HP NonStop SQL/MP Скачать руководство пользователя страница 216](http://html.mh-extra.com/html/hp/nonstop-sql-mp/nonstop-sql-mp_programming-manual_165149216.webp)
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-18
Dynamic Allocation of Memory
Null Values and the Names Buffer
If your program processes indicator parameters, the names of the indicator parameters
are included in the names buffer after DESCRIBE INPUT runs. The
ind_ptr
field
points to the length field for the first indicator parameter name in the names buffer. This
behavior is parallel to that of
var_ptr
after DESCRIBE INPUT or DESCRIBE.
Figure 10-1
is a diagram of the names buffer immediately after the DESCRIBE INPUT
statement runs when indicator parameters are present for two parameters, where
len
is a two-byte length,
name
is a parameter name,
ind_len
is the length of an indicator
parameter name, and
ind_name
is an indicator parameter name. Each instance of
ind_ptr
points to the length field for the corresponding indicator parameter name.
Like input parameter and output variable names, indicator variable names are blank
padded to even lengths.
When you are reading through the names buffer to prompt the user for parameter
names, you might need to be aware of the indicator fields and perform tasks like the
following:
1. Check the
null_info
field.
2. If
null_info
is -1, read the length field for the indicator.
3. Add this length field to the pointer or index to skip to the next name in the names
buffer.
Dynamic Allocation of Memory
A C program can dynamically allocate memory for input parameters and output
variables at run time by following these steps:
1. Make sure that your program uses the large memory module (which is the default).
The
XMEM
pragma causes the C compiler to use the large-memory model.
2. Declare a template for the SQLDA structure and names buffer using the INCLUDE
SQLDA directive. Use a value of 1 for the SQLDA and names buffer sizes and
Figure 10-1. DESCRIBE INPUT’s Effect on Names Buffer
VAR-PTR of
SQLVAR(1)
IND-PTR of
SQLVAR(1)
VAR-PTR of
SQLVAR(2)
IND-PTR of
SQLVAR(2)
len1 name1
ind-len-1 ind-name-1
len2 name2
ind-len-2 ind-name-2
VST008.vsd
Содержание NonStop SQL/MP
Страница 4: ......
Страница 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Страница 34: ...Introduction HP NonStop SQL MP Programming Manual for C 429847 008 1 8 SQL MP Version Management ...
Страница 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Страница 68: ...SQL MP Statements and Directives HP NonStop SQL MP Programming Manual for C 429847 008 3 8 Finding Information ...
Страница 156: ...Explicit Program Compilation HP NonStop SQL MP Programming Manual for C 429847 008 6 40 SQL Program Files ...
Страница 264: ...Dynamic SQL Operations HP NonStop SQL MP Programming Manual for C 429847 008 10 66 Detailed Dynamic SQL Program ...
Страница 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...
Страница 300: ...Memory Considerations HP NonStop SQL MP Programming Manual for C 429847 008 B 6 Avoiding Memory Stack Overflows ...
Страница 304: ...Maximizing Local Autonomy HP NonStop SQL MP Programming Manual for C 429847 008 C 4 Skipping Unavailable Partitions ...