Handling an unknown column list
For an INSERT statement, the values in the VALUES clause
identify the column values to be inserted into the new row. If the
data types and number of the values that the program inserts
are not known at compile time, you cannot simply use host variables
to hold the data being inserted. Instead, your program must perform
the following tasks:
- Define a dynamic-management structure to serve as storage for
the unknown column definitions. This structure can be either a system-descriptor
area or an sqlda structure.
Use of the system-descriptor area conforms to X/Open standards.
- Use the DESCRIBE statement to examine the column list of the prepared INSERT statement and describe the columns.
- Specify the dynamic-management structure as the location of the data to be inserted when the INSERT statement executes.
Important: Use a dynamic-management structure only
if you do not know the number and data types of the column-list columns
at compile time. For information about how to execute an INSERT if
you do know the number and data types of column-list columns, see Execute non-SELECT statements.
For information about how to identify columns in the VALUES column list of an INSERT statement with a system-descriptor area, see Handling an unknown column list. To use an sqlda structure, see Handling an unknown column list.