SQL/MP to SQL/MX Database and Application Migration Guide

Converting SQL/MP Applications to SQL/MX
Applications
HP NonStop SQL/MP to NonStop SQL/MX Database and Application Migration Guide666211-001
4-48
Dynamic SQL
Descriptor Area
NonStop SQL/MP provides a descriptor area (SQLDA) that enables a dynamic SQL
application to exchange information with the database about input parameters and
output columns. You can use the INCLUDE SQLDA directive to declare the descriptor
area.
NonStop SQL/MX does not provide the SQLDA nor the INCLUDE SQLDA directive as
NonStop SQL/MP does. However, NonStop SQL/MX does provide a SQL descriptor
area for dynamic SQL, which consists of multiple item descriptor areas, together with a
count of the number of those item descriptor areas.
In NonStop SQL/MX, you must use the ALLOCATE DESCRIPTOR and DEALLOCATE
DESCRIPTOR statements to allocate and deallocate input and output SQL descriptor
areas. After the parameters are described (using the DESCRIBE statement as in
NonStop SQL/MP), you can only use the SET DESCRIPTOR and GET DESCRIPTOR
statements, respectively, to modify and retrieve information from the descriptor areas.
If you have dynamic input parameters in a prepared SQL statement, you must code the
appropriate 3GL statements and use SET DESCRIPTOR to set the values in the
descriptor area. If you have more than one dynamic input parameter, you can identify
the values by their position in the prepared SQL statement.
In NonStop SQL/MX, use the CAST specification to give input parameters a defined
data type provided in the descriptor area. The CAST specification might improve the
efficiency of the generated query plan. The CAST specification is not needed for MXCI
parameters or for parameters used in dynamic cursors in embedded SQL programs.
For examples that use dynamic SQL statements, see the
SQL/MX Reference Manual.
PREPARE Prepares (compiles) a dynamic SQL statement for
subsequent execution by an EXECUTE statement.
DEALLOCATE PREPARE Deallocates a prepared statement and returns the
system resources used by the statement; also
allows you to reuse the name of the statement.
DESCRIBE [OUTPUT] Stores in the output descriptor area information
about output values (usually SELECT columns)
from a prepared statement.
DESCRIBE INPUT Stores in the input descriptor area information
about dynamic input parameters for a prepared
statement.
EXECUTE Executes a prepared dynamic SQL statement.
EXECUTE IMMEDIATE Prepares (compiles) and executes a dynamic SQL
statement.