SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-2
Using Dynamic SQL
Developing a Dynamic SQL Application on page 10-9
Constructing a Server that Interfaces With Pathway on page 10-35
Sample Dynamic SQL Program on page 10-37
Using Dynamic SQL
Figure 10-1 shows part of a COBOL program (top) that contains an embedded static
SQL statement and a part of another COBOL program (bottom) that accepts a request
from a user to execute a dynamic SQL statement. The steps used for the dynamic SQL
statements are:
1. Define a character string host variable to hold the dynamic SQL statement.
2. Display a prompt to the user, requesting the SQL statement.
3. Accept the SQL statement into the host variable and determine its length.
4. Execute the SQL statement using an EXECUTE IMMEDIATE statement.