Writing a DSQL Application
Go Up to Using Dynamic SQL
Write a DSQL application when any of the following are not known until run time:
- The text of the SQL statement
- The number of host variables
- The data types of host variables
- References to database objects
Writing a DSQL application is usually more complex than programming with regular SQL because for most DSQL operations, the application needs explicitly to allocate and process an extended SQL descriptor area (XSQLDA) data structure to pass data to and from the database.
To use DSQL to process a SQL statement, follow these basic steps:
- Determine if DSQL can process the SQL statement.
- Represent the SQL statement as a character string in the application.
- If necessary, allocate one or more XSQLDA for input parameters and return values.
- Use an appropriate DSQL programming method to process the SQL statement.