![]() | ![]() |
Home |
|
|
Open ServerConnect Programmer's Reference for COBOL |
|
| Chapter 2: Topics |
|
| Dynamic SQL Support |
Dynamic SQL allows a client application to execute SQL statements containing variables with values that are determined at run time. It is primarily useful for precompiler support. A client application prepares a dynamic SQL statement by associating a SQL statement containing placeholders with an identifier and sending the statement to an Open ServerConnect application so that the statement becomes a prepared statement.
When a client application is ready to execute a prepared statement, it defines values to substitute for the SQL statement placeholders and sends a command to execute the statement. These values become the command input parameters. After the statement executes the desired number of times, the client application deallocates the statement.
Dynamic SQL permits a client application to act interactively, passing different information at different times to the Open ServerConnect application, as it gets that information from the user. The Open ServerConnect application can then fill in the missing pieces in the SQL query with the data the user provides.
In Open ServerConnect, this process must occur as a long-running transaction. When a client issues a dynamic SQL command, Open ServerConnect indicates a TDS-DYNAMIC event through TDINFPGM or TDGETREQ. The server application retrieves the type of command through a TDYNAMIC call and then satisfies the client request.
Table 2-11 defines the valid Open ServerConnect responses for various client requests.
Client Action | Open ServerConnect Application Response |
|---|---|
Client issues a prepare command (TD-PREPARE) | 1. Get operation type (TDS-GET) |
Client requests an input parameter description (CS-DESCRIBE-INPUT) | 1. Get operation type (TDS-GET) |
Client requests an output parameter description (CS-DESCRIBE-OUTPUT) | 1. Get operation type (TDS-GET) |
Client issues an execute request (TD-EXECUTE) | 1. Get operation type (TDS-GET) |
Client issues an execute immediate request (TD-EXECUTE-IMMEDIATE) | 1. Get operation type (TDS-GET) |
Client issues a deallocation request (TD-DEALLOC) | 1. Get operation type (TDS-GET) |
|
|