275: def fetch_hash
276: raise InterfaceError, "Statement was already closed!" if @handle.nil?
277: raise InterfaceError, "Statement must first be executed" unless @fetchable
278:
279: cols = column_names
280:
281: if block_given?
282: while (row = @handle.fetch) != nil
283: hash = {}
284: row.each_with_index {|v,i| hash[cols[i]] = v}
285: yield hash
286: end
287: @handle.cancel
288: @fetchable = false
289: return nil
290: else
291: row = @handle.fetch
292: if row.nil?
293: @handle.cancel
294: @fetchable = false
295: return nil
296: else
297: hash = {}
298: row.each_with_index {|v,i| hash[cols[i]] = v}
299: return hash
300: end
301: end
302: end