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.



11
12
13
14
# File 'lib/avmtrf1/oracle/connection/base.rb', line 11

def initialize(connection_string)
  ENV['NLS_LANG'] = 'BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1'
  @connection = OCI8.new(connection_string)
end

Instance Method Details

#query(sql, &block) ⇒ Object



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

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

#unique_value(sql) ⇒ Object



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

def unique_value(sql)
  connection.exec(sql) do |row|
    return row.first
  end
end