EasyManua.ls Logo

HP NonStop SQL/MP User Manual

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #216 background imageLoading...
Page #216 background image
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

Table of Contents

Question and Answer IconNeed help?

Do you have a question about the HP NonStop SQL/MP and is the answer not in the manual?

HP NonStop SQL/MP Specifications

General IconGeneral
PlatformHP NonStop Servers
Data ModelRelational
SQL StandardANSI SQL
Concurrency ControlMulti-Version Concurrency Control (MVCC)
Fault ToleranceYes
High AvailabilityYes
CategoryDatabase Software
Initial Release1980s
Operating SystemHP NonStop OS
LicenseProprietary
TypeRelational Database Management System
Transaction ManagementACID Compliance
DeveloperHewlett Packard Enterprise

Summary

1. Introduction

Developing a C Program

Outlines the process of creating C programs with embedded SQL statements.

Dynamic SQL

Describes how to construct, compile, and run SQL statements at runtime.

2. Host Variables

3. SQL/MP Statements and Directives

4. Data Retrieval and Modification

Single-Row SELECT Statement

Retrieves a single row of data from tables or views into host variables.

Multirow SELECT Statement

Returns multiple rows from tables or views, one row at a time, using cursors.

INSERT Statement

Inserts one or more rows into a table or protection view using host variables.

Using SQL Cursors

Explains how to use named pointers to access sets of rows one at a time.

5. SQL/MP System Procedures

6. Explicit Program Compilation

Explicit Program Compilation

Outlines the general steps for compiling C programs with embedded SQL.

Developing a C Program in the Guardian Environment

Details C program development within the Guardian environment.

7. Program Execution

Required Access Authority

Specifies the access permissions needed to run NonStop SQL program files.

8. Program Invalidation and Automatic SQL Recompilation

Program Invalidation

Explains how SQL program files can become invalid due to changes or errors.

Automatic SQL Recompilation

Describes the run-time recompilation process invoked by the SQL executor.

9. Error and Status Reporting

10. Dynamic SQL Operations

Uses for Dynamic SQL

Identifies scenarios where dynamic SQL programs are beneficial.

Dynamic SQL Statements

Summarizes dynamic SQL statements usable in a C program.

11. Character Processing Rules (CPRL) Procedures

Appendix B: Memory Considerations

Avoiding Memory Stack Overflows

Provides guidelines to prevent stack overflows for SQL statements.

Related product manuals