142: def fetch_rows(sql)
143: db = @db
144: cps = db.conversion_procs
145: api = db.api
146: execute(sql) do |rs|
147: convert = convert_smallint_to_bool
148: col_infos = []
149: api.sqlany_num_cols(rs).times do |i|
150: _, _, name, _, type = api.sqlany_get_column_info(rs, i)
151: cp = if type == 500
152: cps[500] if convert
153: else
154: cps[type]
155: end
156: col_infos << [i, output_identifier(name), cp]
157: end
158:
159: self.columns = col_infos.map{|a| a[1]}
160:
161: if rs
162: while api.sqlany_fetch_next(rs) == 1
163: h = {}
164: col_infos.each do |i, name, cp|
165: _, v = api.sqlany_get_column(rs, i)
166: h[name] = cp && v ? cp[v] : v
167: end
168: yield h
169: end
170: end
171: end
172: self
173: end