Class: Rubyfb::ResultSet
Overview
This class represents the results of a SQL query executed against a database. The viable lifespan of a ResultSet object is limited by the transaction that was used in it’s creation. Once this transaction has been committed or rolled back all related ResultSet object are invalidated and can no longer be used.
Instance Method Summary collapse
-
#close ⇒ Object
This method releases the database resources associated with a ResultSet object and should be explicitly called when a ResultSet object is of no further use.
-
#column_alias(column) ⇒ Object
This method fetches the alias associated with a specified column for a ResultSet object.
-
#column_count ⇒ Object
This method fetches a count of the number of columns in a row of data that the ResultSet can fetch.
-
#column_name(column) ⇒ Object
This method fetches the name associated with a specified column for a ResultSet object.
-
#column_scale(column) ⇒ Object
This method fetches the scale associated with a specified column for a ResultSet object.
-
#column_table(column) ⇒ Object
This method fetches the table name associated with a specified column for a ResultSet object.
-
#connection ⇒ Object
This is the accessor for the connection attribute.
-
#dialect ⇒ Object
This is the accessor for the dialect attribute.
-
#each(&block) ⇒ Object
This method provides an iterator for the (remaining) rows contained in a ResultSet object.
-
#exhausted? ⇒ Boolean
This method is used to determine if all of the rows have been retrieved from a ResultSet object.
-
#fetch ⇒ Object
This method fetches a single rows worth of data from the ResultSet object.
-
#get_base_type(index) ⇒ Object
This method retrieves the base SQL type for a column of data within a ResultSet object.
-
#initialize(statement, transaction) ⇒ ResultSet
constructor
This is the constructor for the ResultSet object.
-
#row_count ⇒ Object
This method fetches a count of the total number of rows retrieved from a result set.
-
#sql ⇒ Object
This is the accessor for the sql attribute.
-
#statement ⇒ Object
This is the accessor for the statement attribute.
-
#transaction ⇒ Object
This is the accessor for the transaction attribute.
Constructor Details
#initialize(statement, transaction) ⇒ ResultSet
This is the constructor for the ResultSet object.
Parameters
- statement
-
A reference to the Statement object.
- transaction
-
A reference to the Transaction object that will be used in executing the SQL query.
Exceptions
- FireRubyException
-
Generated whenever a non-query SQL statement is specified, an invalid connection or transaction is provided or a problem occurs executing the SQL against the database.
742 743 |
# File 'lib/src.rb', line 742 def initialize(statement, transaction) end |
Instance Method Details
#close ⇒ Object
This method releases the database resources associated with a ResultSet object and should be explicitly called when a ResultSet object is of no further use. The method is implicitly called if the rows available from a ResultSet are exhausted but calling this method at that time will not cause an error.
Exceptions
- FireRubyError
-
Generated whenever a problem occurs closing the result set object.
897 898 |
# File 'lib/src.rb', line 897 def close end |
#column_alias(column) ⇒ Object
This method fetches the alias associated with a specified column for a ResultSet object.
Parameters
- column
-
A reference to the column number to fetch the details for. Column numbers start at zero.
807 808 |
# File 'lib/src.rb', line 807 def column_alias(column) end |
#column_count ⇒ Object
This method fetches a count of the number of columns in a row of data that the ResultSet can fetch.
783 784 |
# File 'lib/src.rb', line 783 def column_count end |
#column_name(column) ⇒ Object
This method fetches the name associated with a specified column for a ResultSet object.
Parameters
- column
-
A reference to the column number to fetch the details for. Column numbers start at zero.
795 796 |
# File 'lib/src.rb', line 795 def column_name(column) end |
#column_scale(column) ⇒ Object
This method fetches the scale associated with a specified column for a ResultSet object. Firebird implements some floating point types with integral storage and a negative scale. For example, depending on your platform
SELECT 1.003 FROM RDB$DATABASE
may return a ResultSet, the first and only column of which has a base type of :BIGINT but a scale of -3. (Fetches of the actual value will correctly return a ruby Float.)
Parameters
- column
-
A reference to the column number to fetch the details for. Column numbers start at zero.
827 828 |
# File 'lib/src.rb', line 827 def column_scale(column) end |
#column_table(column) ⇒ Object
This method fetches the table name associated with a specified column for a ResultSet object.
Parameters
- column
-
A reference to the column number to fetch the details for. Column numbers start at zero.
839 840 |
# File 'lib/src.rb', line 839 def column_table(column) end |
#connection ⇒ Object
This is the accessor for the connection attribute.
749 750 |
# File 'lib/src.rb', line 749 def connection end |
#dialect ⇒ Object
This is the accessor for the dialect attribute.
775 776 |
# File 'lib/src.rb', line 775 def dialect end |
#each(&block) ⇒ Object
This method provides an iterator for the (remaining) rows contained in a ResultSet object.
Parameters
- block
-
A block that takes a single parameter. This will be called for and passed each remaining row (as per the fetch method) from the ResultSet.
882 883 |
# File 'lib/src.rb', line 882 def each(&block) end |
#exhausted? ⇒ Boolean
This method is used to determine if all of the rows have been retrieved from a ResultSet object. This method will always return false until the fetch method has been called at least once so it cannot be used to detect a result set that returns no rows.
861 862 |
# File 'lib/src.rb', line 861 def exhausted? end |
#fetch ⇒ Object
This method fetches a single rows worth of data from the ResultSet object. If the set contains more rows then an array containing the row data will be retrieved. If the ResultSet is exhausted (i.e. all rows have been fetched) then nil is returned. Translation of the row data into an appropriate Ruby type is performed on the row data that is extracted.
851 852 |
# File 'lib/src.rb', line 851 def fetch end |
#get_base_type(index) ⇒ Object
This method retrieves the base SQL type for a column of data within a ResultSet object. The method returns one of the base types defined in the SQLType class but does not return an actual SQLType object.
Parameters
- index
-
The offset from the ResultSet first column of the column to return the type information for.
909 910 |
# File 'lib/src.rb', line 909 def get_base_type(index) end |
#row_count ⇒ Object
This method fetches a count of the total number of rows retrieved from a result set.
869 870 |
# File 'lib/src.rb', line 869 def row_count end |
#sql ⇒ Object
This is the accessor for the sql attribute.
768 769 |
# File 'lib/src.rb', line 768 def sql end |
#statement ⇒ Object
This is the accessor for the statement attribute.
762 763 |
# File 'lib/src.rb', line 762 def statement end |
#transaction ⇒ Object
This is the accessor for the transaction attribute.
756 757 |
# File 'lib/src.rb', line 756 def transaction end |