index

SybResult

Included Modules

  • SybConstant

  • Class Method

    new(restype, rowset=nil)
    Rreturns a newly created result set object.

    Parameters:

    Methods

    restype
    Returns result type (CS_ROW_RESULT, CS_CMD_FAIL etc. ).

    rows
    Returns row results as Array of Array.

    If the result type is neither CS_ROW_RESULT,CS_PARAM_RESULT, CS_STATUS_RESULT nor CS_COMPUTE_RESULT, then it returns nil

    columns
    Returns an array of column names

    If the result type is neither CS_ROW_RESULT nor CS_PARAM_RESULT, then it returns nil

    nthrow( nth, clm=nil )
    Examples
      ## exec sp_who ##
      query.sql("sp_who")
      
      ## gets the first row result ##
      res=query.top_row_result  # res is a SybResult object 
    
      ## print column names. ##
      print res.columns.join(','),"\n"
       -->
         spid,status,loginame,hostname,blk,dbname,cmd
    
      ## print row data ##
      res.rows.each{|r| print r.join(','), "\n"}
       -->
        1,running     ,sa          ,          ,0    ,master    ,SELECT          
        2,sleeping    ,,          ,0    ,master    ,NETWORK HANDLER 
        3,sleeping    ,,          ,0    ,master    ,DEADLOCK TUNE   
        4,sleeping    ,,          ,0    ,master    ,MIRROR HANDLER  
        5,sleeping    ,,          ,0    ,master    ,HOUSEKEEPER     
        6,sleeping    ,,          ,0    ,master    ,CHECKPOINT SLEEP
    
      ## using column number ##
      print res.nthrow(0,1),"\n"
       -->
        "running     "
    
      ## Using column name ##
      print res.nthrow(5,"cmd"),"\n"
       -->
        "CHECKPOINT SLEEP"
    
    tran_state
    Returns the current server transaction state.

    Returns:

    row_count
    Returns the number of rows affected by the command.