Class Sequel::DB2::Dataset
In: lib/sequel/adapters/db2.rb
Parent: Sequel::Dataset

Methods

Included Modules

DatasetMethods

Constants

DatasetClass = self
MAX_COL_SIZE = 256

Attributes

convert_smallint_to_bool  [W]  Override the default DB2.convert_smallint_to_bool setting for this dataset.

Public Instance methods

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

[Source]

     # File lib/sequel/adapters/db2.rb, line 178
178:       def convert_smallint_to_bool
179:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = DB2.convert_smallint_to_bool)
180:       end

[Source]

     # File lib/sequel/adapters/db2.rb, line 185
185:       def fetch_rows(sql)
186:         execute(sql) do |sth|
187:           db = @db
188:           i = 1
189:           column_info = get_column_info(sth)
190:           cols = column_info.map{|c| c.at(1)}
191:           @columns = cols
192:           errors = [DB2CLI::SQL_NO_DATA_FOUND, DB2CLI::SQL_ERROR]
193:           until errors.include?(rc = DB2CLI.SQLFetch(sth))
194:             db.check_error(rc, "Could not fetch row")
195:             row = {}
196:             column_info.each do |i, c, t, s, pr|
197:               v, _ = db.checked_error("Could not get data"){DB2CLI.SQLGetData(sth, i, t, s)}
198:               row[c] = if v == DB2CLI::Null
199:                 nil
200:               elsif pr
201:                 pr.call(v)
202:               else
203:                 v
204:               end
205:             end
206:             yield row
207:           end
208:         end
209:         self
210:       end

[Validate]