index

SybCommand

Class Method

new ( con, cmd, type=CS_LANG_CMD )
Initiate a command.
(This method corresponds to ct_command of Sybase Client Library.)

Parameters:

If error has occurred, then it raise a RuntimeError exception.

cursor_new ( con, csrname, langcmd, opt=CS_UNUSED )
Initiates a command, and declares a cursor.
This method corresponds to ct_cmd_alloc() + ct_cursor( CS_CURSOR_DECLARE) of Sybase Client Library.

Parameters:

If error has occurred, then it raise a RuntimeError exception.

The cursor is available until a delete method is called or Ruby's garbage collector finds this.

Methods

send
Send a command to the server
(This method corresponds to ct_send of Sybase Client Library.)

Returns TRUE if it was successful, or FALSE if not

delete
Deallocate a command.
If the command has a Client-Library cursor that was assigned with cursor_new, then the cursor will be deallocated too.

Returns TRUE if it was deleted successfully.

results
Set up results data to be processed, and returns a results type as follows.

CS_CMD_SUCCEED The success of a command that returns no data
CS_CMD_DONE The results of a command have been completely processed.
CS_CMD_FAIL The server encountered an error while executing a command
CS_ROW_RESULT Regular row results
CS_PARAM_RESULT Parameter results
CS_STATUS_RESULT Stored procedure return status results.
CS_COMPUTE_RESULT Compute row results

bind_columns ( maxcolumns=nil )
This method calls ct_bind of SyBase Client Library, and binds server results to Ruby's variables.
It returns an array of columns name.

Parameters:

fetch ( strip=true )
Retrieves one result data.
This method corresponds to ct_fetch of Sybase Client Library.

Parameters

Returns:
Returns the status and an array of result row.
(status, row ) = cmdobj.fetch()
The status has the following values.
  • false -- Initialization error
  • SybConstant::CS_END_DATA
  • SybConstant::CS_SUCCEED
  • SybConstant::CS_ROW_FAIL
  • SybConstant::CS_FAIL
  • SybConstant::CS_CANCELED
  • fetchloop ( maxrows=0, strip=true, bcol=nil, rproc=nil)

    Retrieves all result data.

    Returns an array of two elements, the first element is array of column names , the second element is row datas as an array of array.
    --> [ [column-name ...] [ [row-data-1] [row-data-2] .... ] ]

    If error has occurred, then it returns FALSE.

    Parameters

    cancel ( type=SybConstant::CS_CANCEL_CURRENT )
    Cancel a command.
    This method corresponds to ct_cancel of Sybase Client Library.

    Returns TRUE if it was successful

    Parameters:

    setprop ( proptype, val )
    Sets Client-Library properties at the command structure levels.
    This method corresponds to ct_cmd_props(CS_SET) of Sybase Client Library.

    The proptype parameter must be a constant that is defined in SybConstant module.

    Returns TRUE if it was successful, or FALSE if not

    getprop ( proptype )
    Retrieves Client-Library properties at the command structure levels.
    This method corresponds to ct_cmd_props(CS_GET) of Sybase Client Library.

    The value of proptype must be a constant that is defined in SybConstant module.

    res_info ( type )
    Retrieves current result set or command information.
    This method corresponds to ct_res_info of Sybase Client Library.

    The value of type must be a constant that is defined in SybConstant module.

    get_iodesc ( item )
    Retrieves a data I/O descriptor.

    Parameters:

    Returns a SybIODesc object if it was successful.
    If error has occurred, then it returns SybConstant::CS_FAIL.

    (Please see the Sybase OpenClient manual pages on ct_data_info for further details.)

    set_iodesc ( iodesc )
    Define a data I/O descriptor.

    Parameters:

    Returns a SybConstant::CS_SUCCEED if it was successful.
    If error has occurred, then it returns SybConstant::CS_FAIL.

    (Please see the Sybase OpenClient manual pages on ct_data_info for further details.)

    get_data ( item, fetchsize )
    Reads a chunk of data from the server

    Parameters:

    Returns

    (Please see the Sybase OpenClient manual pages on ct_get_data for further details.)

    send_data ( data )
    Sends a chunk of TEXT/IMAGE data to the server

    Parameters:

    Returns

    (Please see the Sybase OpenClient manual pages on ct_send_data for further details.)

    cursor_state ()
    Gets current cursor's status
    (This method corresponds to ct_cmd_props( cmd, CS_GET, CS_CUR_STATUS ) of Sybase Client Library.)

    Returns :

    If no cursor exists, then it returns SybConstant::CS_CURSTAT_NONE.
    If return value is not CS_CURSTAT_NONE, the application determines the cursor status by applying the bitmask values listed in the following.

    cursor_rows ( rows )
    This method corresponds to ct_cursor ( CS_CURSOR_ROWS ) of Sybase Client Library.

    Parameters:

    cursor_open ()
    This method corresponds to ct_cursor( CS_CURSOR_OPEN ) of Sybase Client Library.

    cursor_option( opt )
    This method corresponds to ct_cursor( CS_CURSOR_OPTION ) of Sybase Client Library.

    Parameters

    cursor_update ( table, sql )
    This method corresponds to ct_cursor( CS_CURSOR_UPDATE ) of Sybase Client Library.

    Parameters

    cursor_delete( table )
    This method corresponds to ct_cursor( CS_CURSOR_DELETE) of Sybase Client Library.

    Parameters

    cursor_close()
    This method corresponds to ct_cursor( CS_CURSOR_CLOSE) of Sybase Client Library.