Included Modules

Class Index [+]

Quicksearch

Sequel::DB2::Dataset

Constants

DatasetClass
MAX_COL_SIZE

Attributes

convert_smallint_to_bool[W]

Override the default DB2.convert_smallint_to_bool setting for this dataset.

Public Instance Methods

convert_smallint_to_bool() click to toggle source

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

     # File lib/sequel/adapters/db2.rb, line 171
171:       def convert_smallint_to_bool
172:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = DB2.convert_smallint_to_bool)
173:       end
fetch_rows(sql) click to toggle source
     # File lib/sequel/adapters/db2.rb, line 178
178:       def fetch_rows(sql)
179:         execute(sql) do |sth|
180:           offset = @opts[:offset]
181:           db = @db
182:           i = 1
183:           column_info = get_column_info(sth)
184:           cols = column_info.map{|c| c.at(1)}
185:           cols.delete(row_number_column) if offset
186:           @columns = cols
187:           errors = [DB2CLI::SQL_NO_DATA_FOUND, DB2CLI::SQL_ERROR]
188:           until errors.include?(rc = DB2CLI.SQLFetch(sth))
189:             db.check_error(rc, "Could not fetch row")
190:             row = {}
191:             column_info.each do |i, c, t, s, pr|
192:               v, _ = db.checked_error("Could not get data"){DB2CLI.SQLGetData(sth, i, t, s)}
193:               row[c] = if v == DB2CLI::Null
194:                 nil
195:               elsif pr
196:                 pr.call(v)
197:               else
198:                 v
199:               end
200:             end
201:             row.delete(row_number_column) if offset
202:             yield row
203:           end
204:         end
205:         self
206:       end

Private Instance Methods

get_column_info(sth) click to toggle source
     # File lib/sequel/adapters/db2.rb, line 210
210:       def get_column_info(sth)
211:         db = @db
212:         column_count = db.checked_error("Could not get number of result columns"){DB2CLI.SQLNumResultCols(sth)}
213:         convert = convert_smallint_to_bool
214:         cps = db.conversion_procs
215: 
216:         (1..column_count).map do |i| 
217:           name, buflen, datatype, size, digits, nullable = db.checked_error("Could not describe column"){DB2CLI.SQLDescribeCol(sth, i, MAX_COL_SIZE)}
218:           pr = if datatype == DB2CLI::SQL_SMALLINT && convert && size <= 5 && digits <= 1
219:             cps[:boolean]
220:           else
221:             cps[datatype]
222:           end
223:           [i, output_identifier(name), datatype, size, pr]
224:         end 
225:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.