class Avmtrf1::Oracle::Connection::Base

def first_row(sql)

def first_row(sql)
  connection.exec(sql) { |row| return row }
  nil
end

def first_row_hash(sql)

def first_row_hash(sql)
  connection.exec(sql).fetch_hash { |row| return row }
  nil
end

def initialize(connection_string)

def initialize(connection_string)
  ::Avmtrf1::Oracle::Oci8.require_lib
  @connection = OCI8.new(connection_string)
end

def objects

def objects
  @objects ||= ::Avmtrf1::Oracle::Objects.new(self)
end

def query(sql, &block)

def query(sql, &block)
  if block
    query_with_block(sql, block)
  else
    query_without_block(sql)
  end
end

def query_with_block(sql, block)

def query_with_block(sql, block)
  cursor = query_without_block(sql)
  begin
    while (row = cursor.fetch_hash)
      block.call(row)
    end
  ensure
    cursor.close
  end
end

def query_without_block(sql)

def query_without_block(sql)
  connection.exec(sql)
end

def unique_value(sql)

def unique_value(sql)
  first_row(sql).if_present(&:first)
end