Class: Avmtrf1::Oracle::Connection::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/oracle/connection/base.rb

Constant Summary collapse

DEFAULT_PORT =
1521

Instance Method Summary collapse

Constructor Details

#initialize(connection_string) ⇒ Base

Returns a new instance of Base.



14
15
16
# File 'lib/avmtrf1/oracle/connection/base.rb', line 14

def initialize(connection_string)
  @connection = OCI8.new(connection_string)
end

Instance Method Details

#first_row(sql) ⇒ Object



18
19
20
21
# File 'lib/avmtrf1/oracle/connection/base.rb', line 18

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

#first_row_hash(sql) ⇒ Object



23
24
25
26
# File 'lib/avmtrf1/oracle/connection/base.rb', line 23

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

#objectsObject



40
41
42
# File 'lib/avmtrf1/oracle/connection/base.rb', line 40

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

#query(sql, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/avmtrf1/oracle/connection/base.rb', line 32

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

#unique_value(sql) ⇒ Object



28
29
30
# File 'lib/avmtrf1/oracle/connection/base.rb', line 28

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