Coding an execute-immediate command

To execute a dynamic SQL statement using the execute-immediate method, code your application to:

  1. Store the text of the dynamic SQL statement in a character string host variable.

  2. Call ct_dynamic with type as CS_EXEC_IMMEDIATE to initiate a command to execute the statement, buffer as the address of the string containing the SQL statement, and id as NULL.

  3. Call ct_send to send the command to the server.

  4. Call ct_results in a standard loop, as described in “Structure of the basic loop”. The value of the *result_type parameter indicates whether the command succeeded (CS_CMD_SUCCEED) or failed (CS_CMD_FAIL).