# File lib/dbi/dbi.rb, line 861
  def fetch_hash
    raise InterfaceError, "Statement was already closed!" if @handle.nil?
    raise InterfaceError, "Statement must first be executed" unless @fetchable

    cols = column_names

    if block_given? 
      while (row = @handle.fetch) != nil
        hash = {}
        row.each_with_index {|v,i| hash[cols[i]] = v} 
        yield hash
      end
      @handle.cancel
      @fetchable = false
      return nil
    else
      row = @handle.fetch
      if row.nil?
        @handle.cancel
        @fetchable = false
        return nil
      else
        hash = {}
        row.each_with_index {|v,i| hash[cols[i]] = v} 
        return hash
      end
    end
  end