Dynamic SQL is the process of generating, preparing, and executing SQL statements at runtime using commands initiated by the Client-Library™ ct_dynamic routine.
These dynamic SQL statements are supported in OpenSwitch:
CS_PREPARE – OpenSwitch stores prepared statements in an internal list. If the connected Adaptive Server fails, OpenSwitch fails over to the next Adaptive Server in the pool and re-prepares any existing prepared statements. If CS_DEALLOC is used for a particular statement, that statement is removed from the list and is not failed over.
CS_EXECUTE, CS_EXECUTE_IMMEDIATE, CS_DESCRIBE_INPUT, CS_DESCRIBE_OUTPUT – if a failover occurs while these statements are active, a 1205 error is returned to the client, and the client must reissue these statements.
CS_CURSOR_DECLARE – if a dynamic cursor is active during a failover, the cursor is redeclared to the new server and the cursor is positioned to the point of the last successful fetch. A 1205 error is issued to the client, and the client must reissue the last fetch.
See Chapter 7, “Using Dynamic SQL Commands” in the Open Client Client-Library/C Programmer’s Guide for more information.
There are two methods of executing dynamic SQL commands—execute-immediate, and prepare-and-execute.