Dynamic SQL overview

Dynamic SQL is the process of generating, preparing, and executing SQL statements at run time using commands initiated by Client-Library’s ct_dynamic routine.

Dynamic SQL is primarily useful for precompiler support, but it can also be used by interactive applications.

Client-Library and Adaptive Server Enterprise allow two methods of dynamic SQL command execution:

With the prepare-and-execute method, the client application sends a ct_dynamic(CS_PREPARE) command to the server to create a prepared statement. A prepared statement is similar to an Adaptive Server Enterprise stored procedure. When either is created, the server checks the SQL statement syntax, builds an optimized query plan, and stores the query plan in preparation for later execution. The key differences are as follows: