Calling the ct_cmd_alloc() method of a CS_CONNECTION object will create a CS_COMMAND object. When the CS_COMMAND object is deallocated the Sybase ct_cmd_drop() function will be called for the command.
CS_COMMAND objects have the following interface:
char
columns. The default value is inherited from the parent connection
when the command is created.
stderr
.
The default value is inherited from the parent connection when the
command is created.
See the description of the ct_describe() method for an example.
NULL
CS_CONNECTION
, the wrapped CS_COMMAND
pointer and the
integer type argument and returns the Sybase result code.
This method will be automatically called when the CS_COMMAND object is deleted. Applications do not need to call the method.
None
is returned as the CS_DATAFMT object
when the result code is not CS_SUCCEED
.
def row_bind(cmd, count = 1): status, num_cols = cmd.ct_res_info(CS_NUMDATA) if status != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_res_info')) bufs = [] for i in range(num_cols): status, fmt = cmd.ct_describe(i + 1) if status != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_describe')) fmt.count = count status, buf = cmd.ct_bind(i + 1, fmt) if status != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_bind')) bufs.append(buf) return bufs
if cmd.ct_command(CS_LANG_CMD, 'select * from pubs..titles') != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_command')) if cmd.ct_send() != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_send')) while 1: status, result = cmd.ct_results() if status == CS_END_RESULTS: break elif status != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_results')) if result in (CS_COMPUTE_RESULT, CS_CURSOR_RESULT, CS_PARAM_RESULT, CS_ROW_RESULT, CS_STATUS_RESULT): bufs = row_bind(cmd, 16) fetch_logical_result(bufs) elif result not in (CS_CMD_DONE, CS_CMD_SUCCEED): raise StandardError(build_ct_exception(con, 'ct_results'))
status, cmd = con.ct_cmd_alloc() if status != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_cmd_alloc')) if cmd.ct_command(CS_LANG_CMD, 'select * from pubs..titles') != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_command')) if cmd.ct_send() != CS_SUCCEED: raise StandardError(build_ct_exception(con, 'ct_send'))