class SQLRCursor

Public Class Methods

new(connection) click to toggle source

Creates a cursor to run queries and fetch result sets using connection “connection”

static VALUE sqlrcur_new(VALUE self, VALUE connection) {
        sqlrconnection *sqlrcon;
        Data_Get_Struct(connection,sqlrconnection,sqlrcon);
        sqlrcursor     *sqlrcur=new sqlrcursor(sqlrcon,true);
        sqlrcursordata *curdata=new sqlrcursordata;
        curdata->cur=sqlrcur;
        curdata->con=connection;
        return Data_Wrap_Struct(self,sqlrcur_mark,sqlrcur_free,(void *)curdata);
}

Public Instance Methods

affectedRows() click to toggle source

Returns the number of rows that were updated, inserted or deleted by the query. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

static VALUE sqlrcur_affectedRows(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u64r,sqlrcurdata->cur,affectedRows);
        return INT2NUM(result);
}
cacheOff() click to toggle source

Sets query caching off.

static VALUE sqlrcur_cacheOff(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,cacheOff);
        return Qnil;
}
cacheToFile(filename) click to toggle source

Sets query caching on. Future queries will be cached to the file “filename”.

A default time-to-live of 10 minutes is also set.

Note that once cacheToFile() is called, the result sets of all future queries will be cached to that file until another call to cacheToFile() changes which file to cache to or a call to cacheOff() turns off caching.

static VALUE sqlrcur_cacheToFile(VALUE self, VALUE filename) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,cacheToFile,filename);
        return Qnil;
}
clearBinds() click to toggle source

Clears all bind variables.

static VALUE sqlrcur_clearBinds(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,clearBinds);
        return Qnil;
}
closeResultSet() click to toggle source

Closes the current result set, if one is open. Data that has been fetched already is still available but no more data may be fetched. Server side resources for the result set are freed as well.

static VALUE sqlrcur_closeResultSet(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,closeResultSet);
        return Qnil;
}
colCount() click to toggle source

Returns the number of columns in the current result set.

static VALUE sqlrcur_colCount(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint32_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u32r,sqlrcurdata->cur,colCount);
        return INT2NUM(result);
}
countBindVariables() click to toggle source

Parses the previously prepared query, counts the number of bind variables defined in it and returns that number.

static VALUE sqlrcur_countBindVariables(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint16_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u16r,sqlrcurdata->cur,countBindVariables);
        return INT2NUM(result);
}
defineOuptutBindBlob(variable) click to toggle source

Defines a binary lob output bind variable

static VALUE sqlrcur_defineOutputBindBlob(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,defineOutputBindBlob,variable);
        return Qnil;
}
defineOutputBindClob(variable) click to toggle source

Defines a character lob output bind variable

static VALUE sqlrcur_defineOutputBindClob(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,defineOutputBindClob,variable);
        return Qnil;
}
defineOutputBindCursor(variable) click to toggle source

Defines a cursor output bind variable

static VALUE sqlrcur_defineOutputBindCursor(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,defineOutputBindCursor,variable);
        return Qnil;
}
defineOutputBindDouble(variable) click to toggle source

Defines an decimal output bind variable.

static VALUE sqlrcur_defineOutputBindDouble(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,defineOutputBindDouble,variable);
        return Qnil;
}
defineOutputBindInteger(variable) click to toggle source

Defines an integer output bind variable.

static VALUE sqlrcur_defineOutputBindInteger(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,defineOutputBindInteger,variable);
        return Qnil;
}
defineOutputBindString(variable,length) click to toggle source

Defines a string output bind variable. “length” bytes will be reserved to store the value.

static VALUE sqlrcur_defineOutputBindString(VALUE self, VALUE variable,
                                                        VALUE bufferlength) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR2(sqlrcurdata->cur,defineOutputBindString,variable,bufferlength);
        return Qnil;
}
dontGetColumnInfo() click to toggle source

Tells the server not to send any column info (names, types, sizes). If you don't need that info, you should call this function to improve performance.

static VALUE sqlrcur_dontGetColumnInfo(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,dontGetColumnInfo);
        return Qnil;
}
endOfResultSet() click to toggle source

Returns 0 if part of the result set is still pending on the server and 1 if not. This function can only return 0 if setResultSetBufferSize() has been called with a parameter other than 0.

static VALUE sqlrcur_endOfResultSet(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,br,sqlrcurdata->cur,endOfResultSet);
        return INT2NUM(result);
}
errorMessage() click to toggle source

If a query failed and generated an error, the error message is available here. If the query succeeded then this function returns a nil.

static VALUE sqlrcur_errorMessage(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,ccpr,sqlrcurdata->cur,curErrorMessage);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
errorNumber() click to toggle source

If a query failed and generated an error, the error number is available here. If there is no error then this method returns 0.

static VALUE sqlrcur_errorNumber(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u64r,sqlrcurdata->cur,curErrorNumber);
        return INT2NUM(result);
}
executeQuery() click to toggle source

Execute the query that was previously prepared and bound.

static VALUE sqlrcur_executeQuery(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,br,sqlrcurdata->cur,executeQuery);
        return INT2NUM(result);
}
fetchFromBindCursor() click to toggle source

Fetch from a cursor that was returned as an output bind variable.

static VALUE sqlrcur_fetchFromBindCursor(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,br,sqlrcurdata->cur,fetchFromBindCursor);
        return INT2NUM(result);
}
firstRowIndex() click to toggle source

Returns the index of the first buffered row. This is useful when buffering only part of the result set at a time.

static VALUE sqlrcur_firstRowIndex(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u64r,sqlrcurdata->cur,firstRowIndex);
        return INT2NUM(result);
}
getCacheFileName() click to toggle source

Returns the name of the file containing the most recently cached result set.

static VALUE sqlrcur_getCacheFileName(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,ccpr,sqlrcurdata->cur,getCacheFileName);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getColumnInfo() click to toggle source

Tells the server to send column info.

static VALUE sqlrcur_getColumnInfo(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,getColumnInfo);
        return Qnil;
}
getColumnIsAutoIncrement(col) click to toggle source

Returns 1 if the specified column auto-increments and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsAutoIncrement(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsAutoIncrementStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsAutoIncrementInt,col);
        }
        return INT2NUM(result);
}
getColumnIsBinary(col) click to toggle source

Returns 1 if the specified column contains binary data and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsBinary(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsBinaryStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsBinaryInt,col);
        }
        return INT2NUM(result);
}
getColumnIsNullable(col) click to toggle source

Returns 1 if the specified column can contain nulls and 0 otherwise. “col” may be specified as the colum name or number.

static VALUE sqlrcur_getColumnIsNullable(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsNullableStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsNullableInt,col);
        }
        return INT2NUM(result);
}
getColumnIsPartOfKey(col) click to toggle source

Returns 1 if the specified column is part of a composite key and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsPartOfKey(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsPartOfKeyStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsPartOfKeyInt,col);
        }
        return INT2NUM(result);
}
getColumnIsPrimaryKey(col) click to toggle source

Returns 1 if the specified column is a primary key and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsPrimaryKey(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsPrimaryKeyStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsPrimaryKeyInt,col);
        }
        return INT2NUM(result);
}
getColumnIsUnique(col) click to toggle source

Returns 1 if the specified column is unique and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsUnique(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsUniqueStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsUniqueInt,col);
        }
        return INT2NUM(result);
}
getColumnIsUnsigned(col) click to toggle source

Returns 1 if the specified column is an unsigned number and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsUnsigned(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsUnsignedStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsUnsignedInt,col);
        }
        return INT2NUM(result);
}
getColumnIsZeroFilled(col) click to toggle source

Returns 1 if the specified column was created with the zero-fill flag and 0 otherwise. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnIsZeroFilled(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsZeroFilledStr,col);
        } else {
                RCUR1(result,br,sqlrcurdata->cur,getColumnIsZeroFilledInt,col);
        }
        return INT2NUM(result);
}
getColumnLength(col) click to toggle source

Returns the length of the specified column. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnLength(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        uint32_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,u32r,sqlrcurdata->cur,getColumnLengthStr,col);
        } else {
                RCUR1(result,u32r,sqlrcurdata->cur,getColumnLengthInt,col);
        }
        return INT2NUM(result);
}
getColumnList(table,wild) click to toggle source

Sends a query that returns a list of columns in the table specified by the “table” parameter matching “wild”. If wild is empty or nil then a list of all columns will be returned.

static VALUE sqlrcur_getColumnList(VALUE self, VALUE table, VALUE wild) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR2(result,br,sqlrcurdata->cur,getColumnList,table,wild);
        return INT2NUM(result);
}
getColumnName(col) click to toggle source

Returns the name of the specified column.

static VALUE sqlrcur_getColumnName(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,ccpr,sqlrcurdata->cur,getColumnName,col);
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getColumnNames() click to toggle source

Returns an array of the column names of the current result set.

static VALUE sqlrcur_getColumnNames(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        sqlrcursor     *sqlrcur;
        const char * const *result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcur=sqlrcurdata->cur;
        RCUR(result,ccpcpr,sqlrcur,getColumnNames);
        if (!result) {
                return Qnil;
        }
        VALUE  nameary=rb_ary_new2(sqlrcur->colCount());
        for (uint32_t i=0; i<sqlrcur->colCount(); i++) {
                if (result[i]) {
                        rb_ary_store(nameary,i,rb_str_new2(result[i]));
                } else {
                        rb_ary_store(nameary,i,Qnil);
                }
        }
        return nameary;
}
getColumnPrecision(col) click to toggle source

Returns the precision of the specified column. Precision is the total number of digits in a number. eg: 123.45 has a precision of 5. For non-numeric types, it's the number of characters in the string. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnPrecision(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        uint32_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,u32r,sqlrcurdata->cur,getColumnPrecisionStr,col);
        } else {
                RCUR1(result,u32r,sqlrcurdata->cur,getColumnPrecisionInt,col);
        }
        return INT2NUM(result);
}
getColumnScale(col) click to toggle source

Returns the scale of the specified column. Scale is the total number of digits to the right of the decimal point in a number. eg: 123.45 has a scale of 2. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnScale(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        uint32_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,u64r,sqlrcurdata->cur,getColumnScaleStr,col);
        } else {
                RCUR1(result,u64r,sqlrcurdata->cur,getColumnScaleInt,col);
        }
        return INT2NUM(result);
}
getColumnType(col) click to toggle source

Returns the type of the specified column. “col” may be specified as the column name or number.

static VALUE sqlrcur_getColumnType(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        const char     *result;
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,ccpr,sqlrcurdata->cur,getColumnTypeStr,col);
        } else {
                RCUR1(result,ccpr,sqlrcurdata->cur,getColumnTypeInt,col);
        }
        if (result) {
                return rb_str_new2(result);
        } else {
                return Qnil;
        }
}
getDatabaseList(wild) click to toggle source

Sends a query that returns a list of databases/schemas matching “wild”. If wild is empty or nil then a list of all databases/schemas will be returned.

static VALUE sqlrcur_getDatabaseList(VALUE self, VALUE wild) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,getDatabaseList,wild);
        return INT2NUM(result);
}
getField(row,col) click to toggle source

Returns the specified field as a string. “col” may be specified as the column name or number.

static VALUE sqlrcur_getField(VALUE self, VALUE row, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        uint64_t       length;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR2(result,ccpr,sqlrcurdata->cur,getFieldStr,row,col);
                RCUR2(length,u64r,sqlrcurdata->cur,getFieldLengthStr,row,col);
        } else {
                RCUR2(result,ccpr,sqlrcurdata->cur,getFieldInt,row,col);
                RCUR2(length,u64r,sqlrcurdata->cur,getFieldLengthInt,row,col);
        }
        if (result) {
                return rb_str_new(result,length);
        } else {
                return Qnil;
        }
}
getFieldAsDouble(row,col) click to toggle source

Returns the specified field as an decimal. “col” may be specified as the column name or number.

static VALUE sqlrcur_getFieldAsDouble(VALUE self, VALUE row, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        double result;
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR2(result,dr,sqlrcurdata->cur,getFieldAsDoubleStr,row,col);
        } else {
                RCUR2(result,dr,sqlrcurdata->cur,getFieldAsDoubleInt,row,col);
        }
        return rb_float_new(result);
}
getFieldAsInteger(row,col) click to toggle source

Returns the specified field as an integer. “col” may be specified as the column name or number.

static VALUE sqlrcur_getFieldAsInteger(VALUE self, VALUE row, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        int64_t        result;
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR2(result,i64r,sqlrcurdata->cur,getFieldAsIntegerStr,row,col);
        } else {
                RCUR2(result,i64r,sqlrcurdata->cur,getFieldAsIntegerInt,row,col);
        }
        return INT2NUM(result);
}
getFieldLength(row,col) click to toggle source

Returns the length of the specified row and column. “col” may be specified as the column name or number.

static VALUE sqlrcur_getFieldLength(VALUE self, VALUE row, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR2(result,u64r,sqlrcurdata->cur,getFieldLengthStr,row,col);
        } else {
                RCUR2(result,u64r,sqlrcurdata->cur,getFieldLengthInt,row,col);
        }
        return INT2NUM(result);
}
getLongest(col) click to toggle source

Returns the length of the longest field in the specified column. “col” may be specified as the column name or number.

static VALUE sqlrcur_getLongest(VALUE self, VALUE col) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(col,rb_cString)==Qtrue) {
                RCUR1(result,u64r,sqlrcurdata->cur,getLongestStr,col);
        } else {
                RCUR1(result,u64r,sqlrcurdata->cur,getLongestInt,col);
        }
        return INT2NUM(result);
}
getNullsAsEmptyStrings() click to toggle source

Tells the connection to return NULL fields and output bind variables as empty strings. This is the default.

static VALUE sqlrcur_getNullsAsEmptyStrings(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,getNullsAsEmptyStrings);
        return Qnil;
}
getNullsAsNils() click to toggle source

Tells the connection to return NULL fields and output bind variables as nil's.

static VALUE sqlrcur_getNullsAsNils(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,getNullsAsNulls);
        return Qnil;
}
getOutputBindBlob(variable) click to toggle source

Get the value stored in a previously defined binary lob output bind variable.

static VALUE sqlrcur_getOutputBindBlob(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        uint64_t       length;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,ccpr,sqlrcurdata->cur,getOutputBindBlob,variable);
        RCUR1(length,u64r,sqlrcurdata->cur,getOutputBindLength,variable);
        if (result) {
                return rb_str_new(result,length);
        } else {
                return Qnil;
        }
}
getOutputBindClob(variable) click to toggle source

Get the value stored in a previously defined character lob output bind variable.

static VALUE sqlrcur_getOutputBindClob(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        long           length;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,ccpr,sqlrcurdata->cur,getOutputBindClob,variable);
        RCUR1(length,u64r,sqlrcurdata->cur,getOutputBindLength,variable);
        if (result) {
                return rb_str_new(result,length);
        } else {
                return Qnil;
        }
}
getOutputBindCursor(variable) click to toggle source

Get the cursor associated with a previously defined output bind variable.

static VALUE sqlrcur_getOutputBindCursor(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcursor     *result;
        RCUR1(result,scr,sqlrcurdata->cur,getOutputBindCursor,variable);
        sqlrcursordata *resultdata=new sqlrcursordata;
        resultdata->con=sqlrcurdata->con;
        resultdata->cur=result;
        return Data_Wrap_Struct(csqlrcursor,sqlrcur_mark,sqlrcur_free,
                                                        (void *)resultdata);
}
getOutputBindDouble(variable) click to toggle source

Get the value stored in a previously defined decimal output bind variable.

static VALUE sqlrcur_getOutputBindDouble(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        double         result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,dr,sqlrcurdata->cur,getOutputBindDouble,variable);
        return rb_float_new(result);
}
getOutputBindInteger(variable) click to toggle source

Get the value stored in a previously defined integer output bind variable.

static VALUE sqlrcur_getOutputBindInteger(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        int64_t                result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,i64r,sqlrcurdata->cur,getOutputBindInteger,variable);
        return INT2NUM(result);
}
getOutputBindLength(variable) click to toggle source

Get the length of the value stored in a previously defined output bind variable.

static VALUE sqlrcur_getOutputBindLength(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,u64r,sqlrcurdata->cur,getOutputBindLength,variable);
        return INT2NUM(result);
}
getOutputBindString(variable) click to toggle source

Get the value stored in a previously defined string output bind variable.

static VALUE sqlrcur_getOutputBindString(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        const char     *result;
        uint64_t       length;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,ccpr,sqlrcurdata->cur,getOutputBindString,variable);
        RCUR1(length,u64r,sqlrcurdata->cur,getOutputBindLength,variable);
        if (result) {
                return rb_str_new(result,length);
        } else {
                return Qnil;
        }
}
getResultSetBufferSize() click to toggle source

Returns the number of result set rows that will be buffered at a time or 0 for the entire result set.

static VALUE sqlrcur_getResultSetBufferSize(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u64r,sqlrcurdata->cur,getResultSetBufferSize);
        return INT2NUM(result);
}
getResultSetId() click to toggle source

Returns the internal ID of this result set. This parameter may be passed to another statement for use in the resumeResultSet() function. Note: The value this function returns is only valid after a call to suspendResultSet().

static VALUE sqlrcur_getResultSetId(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint16_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u16r,sqlrcurdata->cur,getResultSetId);
        return INT2NUM(result);
}
getRow(row) click to toggle source

Returns an array of the values of the fields in the specified row.

static VALUE sqlrcur_getRow(VALUE self, VALUE row) {
        sqlrcursordata *sqlrcurdata;
        sqlrcursor     *sqlrcur;
        const char * const *result;
        uint32_t       *length;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcur=sqlrcurdata->cur;
        VALUE  fieldary=rb_ary_new2(sqlrcur->colCount());
        RCUR1(result,ccpcpr,sqlrcur,getRow,row);
        RCUR1(length,u32pr,sqlrcur,getRowLengths,row);
        for (uint32_t i=0; i<sqlrcur->colCount(); i++) {
                if (result[i]) {
                        rb_ary_store(fieldary,i,rb_str_new(result[i],
                                                                length[i]));
                } else {
                        rb_ary_store(fieldary,i,Qnil);
                }
        }
        return fieldary;
}
getRowHash(row) click to toggle source

Returns a hash of the values of the fields in the specified row.

static VALUE sqlrcur_getRowHash(VALUE self, VALUE row) {
        sqlrcursordata *sqlrcurdata;
        sqlrcursor     *sqlrcur;
        const char * const *result;
        uint32_t       *length;
        const char     *name;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcur=sqlrcurdata->cur;
        RCUR1(result,ccpcpr,sqlrcur,getRow,row);
        RCUR1(length,u32pr,sqlrcur,getRowLengths,row);
        VALUE  fieldhash=rb_hash_new();
        for (uint32_t i=0; i<sqlrcur->colCount(); i++) {
                RCUR1(name,ccpr,sqlrcur,getColumnName,INT2NUM(i));
                if (result[i]) {
                        rb_hash_aset(fieldhash,
                                        rb_str_new2(name),
                                        rb_str_new(result[i],length[i]));
                } else {
                        rb_hash_aset(fieldhash,
                                        rb_str_new2(name),
                                        Qnil);
                }
        }
        return fieldhash;
}
getRowLengths(row) click to toggle source

Returns an array of the lengths of the fields in the specified row.

static VALUE sqlrcur_getRowLengths(VALUE self, VALUE row) {
        sqlrcursordata *sqlrcurdata;
        sqlrcursor     *sqlrcur;
        uint32_t       *result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcur=sqlrcurdata->cur;
        RCUR1(result,u32pr,sqlrcur,getRowLengths,row);
        if (!result) {
                return Qnil;
        }
        VALUE  lengthary=rb_ary_new2(sqlrcur->colCount());
        for (uint32_t i=0; i<sqlrcur->colCount(); i++) {
                rb_ary_store(lengthary,i,INT2NUM(result[i]));
        }
        return lengthary;
}
getRowLengthsHash(row) click to toggle source

Returns a hash of the lengths of the fields in the specified row.

static VALUE sqlrcur_getRowLengthsHash(VALUE self, VALUE row) {
        sqlrcursordata *sqlrcurdata;
        sqlrcursor     *sqlrcur;
        uint32_t       *result;
        const char     *name;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        sqlrcur=sqlrcurdata->cur;
        RCUR1(result,u32pr,sqlrcur,getRowLengths,row);
        VALUE  lengthhash=rb_hash_new();
        for (uint32_t i=0; i<sqlrcur->colCount(); i++) {
                RCUR1(name,ccpr,sqlrcur,getColumnName,INT2NUM(i));
                rb_hash_aset(lengthhash,
                                rb_str_new2(name),
                                INT2NUM(result[i]));
        }
        return lengthhash;
}
getTableList(wild) click to toggle source

Sends a query that returns a list of tables matching “wild”. If wild is empty or nil then a list of all tables will be returned.

static VALUE sqlrcur_getTableList(VALUE self, VALUE wild) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,getTableList,wild);
        return INT2NUM(result);
}
inputBind(variable,value,(precision),(scale)) click to toggle source

Defines am input bind variable. The value may be a string, integer or decimal. If it is a decimal then the precision and scale may be specified. If you don't have the precision and scale then set them both to 0. However in that case you may get unexpected rounding behavior if the server is faking binds.

static VALUE sqlrcur_inputBind(int argc, VALUE *argv, VALUE self) {
        sqlrcursordata *sqlrcurdata;
        VALUE  variable;
        VALUE  value;
        VALUE  precision;
        VALUE  scale;
        bool   success=true;
        rb_scan_args(argc,argv,"22",&variable,&value,&precision,&scale);
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                if ((rb_obj_is_instance_of(precision,rb_cBignum)==Qtrue ||
                        rb_obj_is_instance_of(precision,rb_cFixnum)==Qtrue ||
                        rb_obj_is_instance_of(precision,rb_cInteger)==Qtrue ||
                        rb_obj_is_instance_of(precision,rb_cNumeric)==Qtrue) && 
                        NUM2INT(precision)>0) {
                        // in this case, the precision parameter is actually
                        // the string length
                        CUR3(sqlrcurdata->cur,inputBindStrLen,variable,value,precision);
                } else {
                        CUR2(sqlrcurdata->cur,inputBindStr,variable,value);
                }
        } else if (rb_obj_is_instance_of(value,rb_cBignum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cFixnum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cInteger)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cNumeric)==Qtrue) {
                CUR2(sqlrcurdata->cur,inputBindInt,variable,value);
        } else if (rb_obj_is_instance_of(value,rb_cFloat)==Qtrue) {
                CUR4(sqlrcurdata->cur,inputBindDbl,variable,value,precision,scale);
        } else if (rb_obj_is_instance_of(value,rb_cNilClass)==Qtrue) {
                CUR1(sqlrcurdata->cur,inputBindNull,variable);
        } else {
                success=false;
        }
        return INT2NUM(success);
}
inputBindBlob(variable,value,size) click to toggle source

Defines a binary lob input bind variable.

static VALUE sqlrcur_inputBindBlob(VALUE self, VALUE variable,
                                        VALUE value, VALUE size) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        bool   success=true;
        if (value==Qnil) {
                CUR2(sqlrcurdata->cur,inputBindBlobNull,variable,size);
        } else if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                CUR3(sqlrcurdata->cur,inputBindBlob,variable,value,size);
        } else {
                success=false;
        }
        return INT2NUM(success);
}
inputBindClob(variable,value,size) click to toggle source

Defines a character lob input bind variable.

static VALUE sqlrcur_inputBindClob(VALUE self, VALUE variable,
                                        VALUE value, VALUE size) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        bool   success=true;
        if (value==Qnil) {
                CUR2(sqlrcurdata->cur,inputBindClobNull,variable,size);
        } else if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                CUR3(sqlrcurdata->cur,inputBindClob,variable,value,size);
        } else {
                success=false;
        }
        return INT2NUM(success);
}
inputBinds(variables,values,(precisions),(scales)) click to toggle source

Defines an array of input bind variables. The values may be strings, integers or decimals. If they are decimals then the precisions and scales may also be specified.

static VALUE sqlrcur_inputBinds(int argc, VALUE *argv, VALUE self) {
        sqlrcursordata *sqlrcurdata;
        VALUE  variables;
        VALUE  values;
        VALUE  precisions;
        VALUE  scales;
        int    argcount=rb_scan_args(argc,argv,"22",
                                &variables,&values,&precisions,&scales);
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (variables==Qnil || values==Qnil) {
                return Qnil;
        }
        VALUE  variable;
        VALUE  value;
        VALUE  precision=0;
        VALUE  scale=0;
        bool   success=true;
        for (;;) {
                variable=rb_ary_shift(variables);
                if (variable==Qnil) {
                        break;
                }
                value=rb_ary_shift(values);
                if (argcount==4) {
                        precision=rb_ary_shift(precisions);
                        scale=rb_ary_shift(scales);
                }
                if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                        CUR2(sqlrcurdata->cur,inputBindStr,variable,value);
                } else if (rb_obj_is_instance_of(value,rb_cBignum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cFixnum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cInteger)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cNumeric)==Qtrue) {
                        CUR2(sqlrcurdata->cur,inputBindInt,variable,value);
                } else if (rb_obj_is_instance_of(value,rb_cFloat)==Qtrue) {
                        CUR4(sqlrcurdata->cur,inputBindDbl,variable,
                                                value,precision,scale);
                } else if (rb_obj_is_instance_of(value,rb_cNilClass)==Qtrue) {
                        CUR1(sqlrcurdata->cur,inputBindNull,variable);
                } else {
                        success=false;
                }
        }
        return INT2NUM(success);
}
lowerCaseColumnNames() click to toggle source

Columns names are converted to lower case.

static VALUE sqlrcur_lowerCaseColumnNames(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,lowerCaseColumnNames);
        return Qnil;
}
mixedCaseColumnNames() click to toggle source

Columns names are returned in the same case as they are defined in the database. This is the default.

static VALUE sqlrcur_mixedCaseColumnNames(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,mixedCaseColumnNames);
        return Qnil;
}
openCachedResultSet(filename) click to toggle source

Opens a cached result set. Returns 1 on success and 0 on failure.

static VALUE sqlrcur_openCachedResultSet(VALUE self, VALUE filename) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,openCachedResultSet,filename);
        return INT2NUM(result);
}
prepareFileQuery(path,filename) click to toggle source

Prepare to execute the contents of “path”/“filename”.

static VALUE sqlrcur_prepareFileQuery(VALUE self, VALUE path, VALUE filename) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR2(result,br,sqlrcurdata->cur,prepareFileQuery,path,filename);
        return INT2NUM(result);
}
prepareQuery(query) click to toggle source

Prepare to execute “query”.

static VALUE sqlrcur_prepareQuery(VALUE self, VALUE query) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,prepareQuery,query);
        return Qnil;
}
prepareQuery(query,length) click to toggle source

Prepare to execute “query” with length “length”. This function must be used if the query contains binary data.

static VALUE sqlrcur_prepareQueryWithLength(VALUE self,
                                        VALUE query, VALUE length) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR2(sqlrcurdata->cur,prepareQueryWithLength,query,length);
        return Qnil;
}
resumeCachedResultSet(id,filename) click to toggle source

Resumes a result set previously left open using suspendSession() and continues caching the result set to “filename”. Returns 1 on success and 0 on failure.

static VALUE sqlrcur_resumeCachedResultSet(VALUE self, 
                                                VALUE id, VALUE filename) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR2(result,br,sqlrcurdata->cur,resumeCachedResultSet,id,filename);
        return INT2NUM(result);
}
resumeResultSet(id) click to toggle source

Resumes a result set previously left open using suspendSession(). Returns 1 on success and 0 on failure.

static VALUE sqlrcur_resumeResultSet(VALUE self, VALUE id) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,resumeResultSet,id);
        return INT2NUM(result);
}
rowCount() click to toggle source

Returns the number of rows in the current result set.

static VALUE sqlrcur_rowCount(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u32r,sqlrcurdata->cur,rowCount);
        return INT2NUM(result);
}
sendFileQuery(path,filename) click to toggle source

Sends the query in file “path”/“filename” and gets a result set.

static VALUE sqlrcur_sendFileQuery(VALUE self, VALUE path, VALUE filename) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR2(result,br,sqlrcurdata->cur,sendFileQuery,path,filename);
        return INT2NUM(result);
}
sendQuery(query) click to toggle source

Sends “query” directly and gets a result set.

static VALUE sqlrcur_sendQuery(VALUE self, VALUE query) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,sendQuery,query);
        return INT2NUM(result);
}
sendQueryWithLength(query,length) click to toggle source

Sends “query” with length “length” directly and gets a result set. This function must be used if the query contains binary data.

static VALUE sqlrcur_sendQueryWithLength(VALUE self,
                                        VALUE query, VALUE length) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR2(result,br,sqlrcurdata->cur,sendQueryWithLength,query,length);
        return INT2NUM(result);
}
setCacheTtl(ttl) click to toggle source

Sets the time-to-live for cached result sets. The sqlr-cachemanger will remove each cached result set “ttl” seconds after it's created, provided it's scanning the directory containing the cache files.

static VALUE sqlrcur_setCacheTtl(VALUE self, VALUE ttl) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,setCacheTtl,ttl);
        return Qnil;
}
setResultSetBufferSize(rows) click to toggle source

Sets the number of rows of the result set to buffer at a time. 0 (the default) means buffer the entire result set.

static VALUE sqlrcur_setResultSetBufferSize(VALUE self, VALUE rows) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR1(sqlrcurdata->cur,setResultSetBufferSize,rows);
        return Qnil;
}
substitution(variable,value,(precision),(scale)) click to toggle source

Defines a substitution variable. The value may be a string, integer or decimal. If it is a decimal then the precision and scale may be specified.

static VALUE sqlrcur_substitution(int argc, VALUE *argv, VALUE self) {
        sqlrcursordata *sqlrcurdata;
        VALUE  variable;
        VALUE  value;
        VALUE  precision;
        VALUE  scale;
        bool   result=true;
        rb_scan_args(argc,argv,"22",&variable,&value,&precision,&scale);
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                CUR2(sqlrcurdata->cur,substitutionStr,variable,value);
        } else if (rb_obj_is_instance_of(value,rb_cBignum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cFixnum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cInteger)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cNumeric)==Qtrue) {
                CUR2(sqlrcurdata->cur,substitutionInt,variable,value);
        } else if (rb_obj_is_instance_of(value,rb_cFloat)==Qtrue) {
                CUR4(sqlrcurdata->cur,substitutionDbl,variable,value,precision,scale);
        } else if (rb_obj_is_instance_of(value,rb_cNilClass)==Qtrue) {
                CUR1(sqlrcurdata->cur,substitutionNull,variable);
        } else {
                result=false;
        }
        return INT2NUM(result);
}
substitutions(variables,values,(precisions),(scales)) click to toggle source

Defines an array of substitution variables. The values may be strings, integers or decimals. If they are decimals then the precisions and scales may also be specified.

static VALUE sqlrcur_substitutions(int argc, VALUE *argv, VALUE self) {
        sqlrcursordata *sqlrcurdata;
        VALUE  variables;
        VALUE  values;
        VALUE  precisions;
        VALUE  scales;
        int    argcount=rb_scan_args(argc,argv,"22",
                                        &variables,&values,&precisions,&scales);
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        if (variables==Qnil || values==Qnil) {
                return Qnil;
        }
        VALUE  variable;
        VALUE  value;
        VALUE  precision=0;
        VALUE  scale=0;
        bool   success=true;
        for (;;) {
                variable=rb_ary_shift(variables);
                if (variable==Qnil) {
                        break;
                }
                value=rb_ary_shift(values);
                if (argcount==4) {
                        precision=rb_ary_shift(precisions);
                        scale=rb_ary_shift(scales);
                }
                if (rb_obj_is_instance_of(value,rb_cString)==Qtrue) {
                        CUR2(sqlrcurdata->cur,substitutionStr,variable,value);
                } else if (rb_obj_is_instance_of(value,rb_cBignum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cFixnum)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cInteger)==Qtrue ||
                        rb_obj_is_instance_of(value,rb_cNumeric)==Qtrue) {
                        CUR2(sqlrcurdata->cur,substitutionInt,variable,value);
                } else if (rb_obj_is_instance_of(value,rb_cFloat)==Qtrue) {
                        CUR4(sqlrcurdata->cur,substitutionDbl,variable,
                                                value,precision,scale);
                } else if (rb_obj_is_instance_of(value,rb_cNilClass)==Qtrue) {
                        CUR1(sqlrcurdata->cur,substitutionNull,variable);
                } else {
                        success=false;
                }
        }
        return INT2NUM(success);
}
suspendResultSet() click to toggle source

Tells the server to leave this result set open when the connection calls suspendSession() so that another connection can connect to it using resumeResultSet() after it calls resumeSession().

static VALUE sqlrcur_suspendResultSet(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,suspendResultSet);
        return Qnil;
}
totalRows() click to toggle source

Returns the total number of rows that will be returned in the result set. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

static VALUE sqlrcur_totalRows(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        uint64_t       result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR(result,u64r,sqlrcurdata->cur,totalRows);
        return INT2NUM(result);
}
upperCaseColumnNames() click to toggle source

Columns names are converted to upper case.

static VALUE sqlrcur_upperCaseColumnNames(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,upperCaseColumnNames);
        return Qnil;
}
validBind(variable) click to toggle source

Returns true if “variable” was a valid bind variable of the query.

static VALUE sqlrcur_validBind(VALUE self, VALUE variable) {
        sqlrcursordata *sqlrcurdata;
        bool           result;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        RCUR1(result,br,sqlrcurdata->cur,validBind,variable);
        return INT2NUM(result);
}
validateBinds() click to toggle source

If you are binding to any variables that might not actually be in your query, call this to ensure that the database won't try to bind them unless they really are in the query. There is a performance penalty for calling this function

static VALUE sqlrcur_validateBinds(VALUE self) {
        sqlrcursordata *sqlrcurdata;
        Data_Get_Struct(self,sqlrcursordata,sqlrcurdata);
        CUR(sqlrcurdata->cur,validateBinds);
        return Qnil;
}