Class: Sequel::DB2::Dataset

Inherits:
Sequel::Dataset show all
Includes:
DatasetMethods
Defined in:
lib/sequel/adapters/db2.rb

Constant Summary collapse

MAX_COL_SIZE =
256

Constants included from DatasetMethods

Sequel::DB2::DatasetMethods::BITWISE_METHOD_MAP, Sequel::DB2::DatasetMethods::BLOB_CLOSE, Sequel::DB2::DatasetMethods::BLOB_OPEN, Sequel::DB2::DatasetMethods::BOOL_FALSE, Sequel::DB2::DatasetMethods::BOOL_TRUE, Sequel::DB2::DatasetMethods::CAST_STRING_CLOSE, Sequel::DB2::DatasetMethods::CAST_STRING_OPEN, Sequel::DB2::DatasetMethods::EMPTY_FROM_TABLE, Sequel::DB2::DatasetMethods::EMULATED_FUNCTION_MAP, Sequel::DB2::DatasetMethods::FETCH_FIRST, Sequel::DB2::DatasetMethods::FETCH_FIRST_ROW_ONLY, Sequel::DB2::DatasetMethods::HSTAR, Sequel::DB2::DatasetMethods::PAREN_CLOSE, Sequel::DB2::DatasetMethods::PAREN_OPEN, Sequel::DB2::DatasetMethods::ROWS_ONLY

Constants inherited from Sequel::Dataset

Sequel::Dataset::ACTION_METHODS, Sequel::Dataset::ALL, Sequel::Dataset::AND_SEPARATOR, Sequel::Dataset::APOS, Sequel::Dataset::APOS_RE, Sequel::Dataset::ARG_BLOCK_ERROR_MSG, Sequel::Dataset::ARRAY_ACCESS_ERROR_MSG, Sequel::Dataset::ARRAY_EMPTY, Sequel::Dataset::AS, Sequel::Dataset::ASC, Sequel::Dataset::BACKSLASH, Sequel::Dataset::BITCOMP_CLOSE, Sequel::Dataset::BITCOMP_OPEN, Sequel::Dataset::BITWISE_METHOD_MAP, Sequel::Dataset::BOOL_FALSE, Sequel::Dataset::BOOL_TRUE, Sequel::Dataset::BRACKET_CLOSE, Sequel::Dataset::BRACKET_OPEN, Sequel::Dataset::CASE_ELSE, Sequel::Dataset::CASE_END, Sequel::Dataset::CASE_OPEN, Sequel::Dataset::CASE_THEN, Sequel::Dataset::CASE_WHEN, Sequel::Dataset::CAST_OPEN, Sequel::Dataset::COLON, Sequel::Dataset::COLUMN_CHANGE_OPTS, Sequel::Dataset::COLUMN_REF_RE1, Sequel::Dataset::COLUMN_REF_RE2, Sequel::Dataset::COLUMN_REF_RE3, Sequel::Dataset::COMMA, Sequel::Dataset::COMMA_SEPARATOR, Sequel::Dataset::CONDITIONED_JOIN_TYPES, Sequel::Dataset::CONDITION_FALSE, Sequel::Dataset::CONDITION_TRUE, Sequel::Dataset::COUNT_FROM_SELF_OPTS, Sequel::Dataset::COUNT_OF_ALL_AS_COUNT, Sequel::Dataset::DATASET_ALIAS_BASE_NAME, Sequel::Dataset::DATETIME_SECFRACTION_ARG, Sequel::Dataset::DEFAULT, Sequel::Dataset::DEFAULT_VALUES, Sequel::Dataset::DELETE, Sequel::Dataset::DESC, Sequel::Dataset::DISTINCT, Sequel::Dataset::DOT, Sequel::Dataset::DOUBLE_APOS, Sequel::Dataset::DOUBLE_QUOTE, Sequel::Dataset::EMULATED_FUNCTION_MAP, Sequel::Dataset::EQUAL, Sequel::Dataset::ESCAPE, Sequel::Dataset::EXISTS, Sequel::Dataset::EXTENSIONS, Sequel::Dataset::EXTRACT, Sequel::Dataset::FILTER, Sequel::Dataset::FORMAT_DATE, Sequel::Dataset::FORMAT_DATE_STANDARD, Sequel::Dataset::FORMAT_OFFSET, Sequel::Dataset::FORMAT_TIMESTAMP_RE, Sequel::Dataset::FORMAT_USEC, Sequel::Dataset::FOR_UPDATE, Sequel::Dataset::FRAME_ALL, Sequel::Dataset::FRAME_ROWS, Sequel::Dataset::FROM, Sequel::Dataset::FUNCTION_DISTINCT, Sequel::Dataset::GROUP_BY, Sequel::Dataset::HAVING, Sequel::Dataset::IMPORT_ERROR_MSG, Sequel::Dataset::INSERT, Sequel::Dataset::INTO, Sequel::Dataset::IS_LITERALS, Sequel::Dataset::IS_OPERATORS, Sequel::Dataset::JOIN_METHODS, Sequel::Dataset::LATERAL, Sequel::Dataset::LIKE_OPERATORS, Sequel::Dataset::LIMIT, Sequel::Dataset::MUTATION_METHODS, Sequel::Dataset::NON_SQL_OPTIONS, Sequel::Dataset::NOTIMPL_MSG, Sequel::Dataset::NOT_SPACE, Sequel::Dataset::NULL, Sequel::Dataset::NULLS_FIRST, Sequel::Dataset::NULLS_LAST, Sequel::Dataset::N_ARITY_OPERATORS, Sequel::Dataset::OFFSET, Sequel::Dataset::ON, Sequel::Dataset::ON_PAREN, Sequel::Dataset::OPTS, Sequel::Dataset::ORDER_BY, Sequel::Dataset::ORDER_BY_NS, Sequel::Dataset::OVER, Sequel::Dataset::PAREN_CLOSE, Sequel::Dataset::PAREN_OPEN, Sequel::Dataset::PAREN_SPACE_OPEN, Sequel::Dataset::PARTITION_BY, Sequel::Dataset::PREPARED_ARG_PLACEHOLDER, Sequel::Dataset::QUALIFY_KEYS, Sequel::Dataset::QUERY_METHODS, Sequel::Dataset::QUESTION_MARK, Sequel::Dataset::QUESTION_MARK_RE, Sequel::Dataset::QUOTE, Sequel::Dataset::QUOTE_RE, Sequel::Dataset::REGEXP_OPERATORS, Sequel::Dataset::RETURNING, Sequel::Dataset::SELECT, Sequel::Dataset::SET, Sequel::Dataset::SPACE, Sequel::Dataset::SPACE_WITH, Sequel::Dataset::SQL_WITH, Sequel::Dataset::STANDARD_TIMESTAMP_FORMAT, Sequel::Dataset::TILDE, Sequel::Dataset::TIMESTAMP_FORMAT, Sequel::Dataset::TWO_ARITY_OPERATORS, Sequel::Dataset::UNCONDITIONED_JOIN_TYPES, Sequel::Dataset::UNDERSCORE, Sequel::Dataset::UNION_ALL_SELECT, Sequel::Dataset::UPDATE, Sequel::Dataset::USING, Sequel::Dataset::VALUES, Sequel::Dataset::WHERE, Sequel::Dataset::WILDCARD, Sequel::Dataset::WITHIN_GROUP, Sequel::Dataset::WITH_ORDINALITY

Instance Attribute Summary collapse

Attributes inherited from Sequel::Dataset

#db, #opts, #row_proc

Instance Method Summary collapse

Methods included from DatasetMethods

#cast_sql_append, #complex_expression_sql_append, #supports_cte?, #supports_group_cube?, #supports_group_rollup?, #supports_is_true?, #supports_lateral_subqueries?, #supports_multiple_column_in?, #supports_select_all_and_column?, #supports_timestamp_usecs?, #supports_where_true?, #supports_window_functions?

Methods included from EmulateOffsetWithRowNumber

#empty?, #select_sql, #supports_offsets_in_correlated_subqueries?

Methods inherited from Sequel::Dataset

#<<, #==, #[], #add_graph_aliases, #aliased_expression_sql_append, #all, #and, #array_sql_append, #avg, #bind, #boolean_constant_sql_append, #call, #case_expression_sql_append, #cast_sql_append, clause_methods, #clone, #column_all_sql_append, #columns, #columns!, #complex_expression_sql_append, #constant_sql_append, #count, #current_datetime, def_mutation_method, def_sql_method, #delayed_evaluation_sql_append, #delete, #distinct, #dup, #each, #each_server, #empty?, #eql?, #escape_like, #except, #exclude, #exclude_having, #exclude_where, #exists, #extension, #extension!, #filter, #first, #first!, #first_source, #first_source_alias, #first_source_table, #for_update, #freeze, #from, #from_self, #from_self!, #frozen?, #function_sql_append, #get, #graph, #grep, #group, #group_and_count, #group_by, #group_cube, #group_rollup, #hash, #having, #identifier_input_method, #identifier_input_method=, #identifier_output_method, #identifier_output_method=, #import, #initialize, #insert, #insert_sql, #inspect, #intersect, #interval, #invert, #join, #join_clause_sql_append, #join_on_clause_sql_append, #join_table, #join_using_clause_sql_append, #joined_dataset?, #last, #lateral, #limit, #literal_append, #lock_style, #map, #max, #min, #multi_insert, #multi_insert_sql, #naked, #naked!, #negative_boolean_constant_sql_append, #offset, #or, #order, #order_append, #order_by, #order_more, #order_prepend, #ordered_expression_sql_append, #paged_each, #placeholder_literal_string_sql_append, #prepare, #provides_accurate_rows_matched?, #qualified_identifier_sql_append, #qualify, #quote_identifier_append, #quote_identifiers=, #quote_identifiers?, #quote_schema_table_append, #quoted_identifier_append, #range, #recursive_cte_requires_column_aliases?, register_extension, #requires_placeholder_type_specifiers?, #requires_sql_standard_datetimes?, #returning, #reverse, #reverse_order, #row_number_column, #schema_and_table, #select, #select_all, #select_append, #select_group, #select_hash, #select_hash_groups, #select_map, #select_more, #select_order_map, #server, #server?, #set_graph_aliases, #single_record, #single_value, #split_alias, #split_qualifiers, #sql, #subscript_sql_append, #sum, #supports_cte?, #supports_cte_in_subqueries?, #supports_derived_column_lists?, #supports_distinct_on?, #supports_group_cube?, #supports_group_rollup?, #supports_insert_select?, #supports_intersect_except?, #supports_intersect_except_all?, #supports_is_true?, #supports_join_using?, #supports_lateral_subqueries?, #supports_limits_in_correlated_subqueries?, #supports_modifying_joins?, #supports_multiple_column_in?, #supports_offsets_in_correlated_subqueries?, #supports_ordered_distinct_on?, #supports_regexp?, #supports_replace?, #supports_returning?, #supports_select_all_and_column?, #supports_timestamp_timezones?, #supports_timestamp_usecs?, #supports_where_true?, #supports_window_functions?, #to_hash, #to_hash_groups, #truncate, #truncate_sql, #unbind, #unfiltered, #ungraphed, #ungrouped, #union, #unlimited, #unordered, #unqualified_column_for, #unused_table_alias, #update, #update_sql, #where, #window_sql_append, #with, #with_recursive, #with_sql, #with_sql_all, #with_sql_delete, #with_sql_each, #with_sql_first, #with_sql_insert, #with_sql_single_value

Methods included from Metaprogramming

#meta_def

Methods included from SQL::StringMethods

#ilike, #like

Methods included from SQL::OrderMethods

#asc, #desc

Methods included from SQL::NumericMethods

#+

Methods included from SQL::ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from SQL::CastMethods

#cast, #cast_numeric, #cast_string

Methods included from SQL::BooleanMethods

#~

Methods included from SQL::AliasMethods

#as

Constructor Details

This class inherits a constructor from Sequel::Dataset

Instance Attribute Details

#convert_smallint_to_boolObject

Whether to convert smallint to boolean arguments for this dataset. Defaults to the DB2 module setting.



173
174
175
# File 'lib/sequel/adapters/db2.rb', line 173

def convert_smallint_to_bool
  defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = DB2.convert_smallint_to_bool)
end

Instance Method Details

#fetch_rows(sql) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/sequel/adapters/db2.rb', line 180

def fetch_rows(sql)
  execute(sql) do |sth|
    db = @db
    column_info = get_column_info(sth)
    cols = column_info.map{|c| c.at(1)}
    @columns = cols
    errors = [DB2CLI::SQL_NO_DATA_FOUND, DB2CLI::SQL_ERROR]
    until errors.include?(rc = DB2CLI.SQLFetch(sth))
      db.check_error(rc, "Could not fetch row")
      row = {}
      column_info.each do |i, c, t, s, pr|
        v, _ = db.checked_error("Could not get data"){DB2CLI.SQLGetData(sth, i, t, s)}
        row[c] = if v == DB2CLI::Null
          nil
        elsif pr
          pr.call(v)
        else
          v
        end
      end
      yield row
    end
  end
  self
end