Responding to client dynamic SQL commands

Table 2-19 summarizes the valid exchange of dynamic SQL requests and responses between the client and the Open Server application. The forward arrow (→) indicates that cmd is set to CS_GET—the Open Server application retrieves information from the client. The backward arrow (←) indicates that cmd is set to CS_SET—the Open Server application sends information to the client.

Table 2-19: Valid dynamic SQL requests and responses

Client action

Open Server application response

Issues a prepare request (Operation type is CS_PREPARE)

→ Retrieves the operation type. (srv_dynamic) → Retrieves the statement ID length. (srv_dynamic) → Retrieves the statement ID. (srv_dynamic) → Retrieves the statement length. (srv_dynamic) → Retrieves the statement. (srv_dynamic) ← Acknowledges the client command. (srv_dynamic) ← Sends the statement ID length. (srv_dynamic) ← Sends the statement ID. (srv_dynamic) ← Sends a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)

Requests a description of the statement’s input parameters (Operation type is CS_DESCRIBE_INPUT)

→ Retrieves the operation type. (srv_dynamic) → Retrieves the statement ID length. (srv_dynamic) → Retrieves the statement ID. (srv_dynamic) ← Acknowledges the client command. (srv_dynamic) ← Sends the statement ID length. (srv_dynamic)

← Sends the statement ID. (srv_dynamic) ← Sends the format of the input parameters. (srv_descfmt and srv_xferdata with type argument set to SRV_DYNDATA. There is no need to call srv_bind, as the application sends formats but no actual data. The status field of the CS_DATAFMT structure must be OR’d with CS_DESCIN prior to calling srv_descfmt) ← Send a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)

Requests a description of the statement’s output parameters

(Operation type is CS_DESCRIBE_OUTPUT)

→ Retrieves the operation type. (srv_dynamic)

→ Retrieves the statement ID length. (srv_dynamic)

→ Retrieves the statement ID. (srv_dynamic) ← Acknowledges the client command. (srv_dynamic) ← Sends the statement ID length. (srv_dynamic) ← Sends the statement ID. (srv_dynamic) ← Sends the result row formats. (srv_descfmt and srv_xferdata with type argument set to SRV_DYNDATA. There is no need to call srv_bind, as the application sends formats but no actual data. The status field of the CS_DATAFMT structure must be OR’d with CS_DESCOUT prior to calling srv_descfmt) ← Sends a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)

Client issues an execute request (Operation type is CS_EXECUTE)

→ Retrieves the operation type. (srv_dynamic) → Retrieves the statement ID length. (srv_dynamic) → Retrieves the statement ID. (srv_dynamic) → Retrieves the number of dynamic parameters. (srv_numparams) → Retrieves the input parameter values. (srv_descfmt, srv_bind, srv_xferdata with type argument set to SRV_DYNDATA) ← Acknowledges the client command. (srv_dynamic) ← Sends the statement ID length. (srv_dynamic) ← Sends the statement ID. (srv_dynamic) ← Sends result rows. (srv_descfmt, srv_bind, srv_xferdata, with type argument set to SRV_ROWDATA) ← Sends a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)

Issues an execute-immediate request (Operation type is CS_EXEC_IMMEDIATE)

→ Retrieves the operation type. (srv_dynamic) → Retrieves the statement ID length—t should be 0. (srv_dynamic) → Retrieves the statement length. (srv_dynamic) → Retrieves the statement. (srv_dynamic) ← Acknowledges the client command. (srv_dynamic) ← Sends a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)

Issues a deallocation request

(Operation type is CS_DEALLOC)

→ Retrieves the operation type. (srv_dynamic) → Retrieves the statement ID length. (srv_dynamic) → Retrieves the statement ID. (srv_dynamic) ← Acknowledges the client command. (srv_dynamic)

← Sends the statement ID length. (srv_dynamic) ← Sends the statement ID. (srv_dynamic) ← Sends a DONE packet. (srv_senddone with status argument set to SRV_DONE_FINAL)