Class: Oraora::OCI

Inherits:
OCI8
  • Object
show all
Defined in:
lib/oraora/oci.rb

Overview

Wrapper around OCI8 to add some extra stuff

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ OCI

Wrapped in a separate thread as OCI8 seems to ignore interrupts



5
6
7
8
9
10
# File 'lib/oraora/oci.rb', line 5

def initialize(*args)
  ret = nil
  thread = Thread.new { ret = super }
  thread.join
  ret
end

Instance Method Details

#exec(sql, *bindvars, &block) ⇒ Object

Wrapped in a separate thread with Interrupt handling



21
22
23
24
25
26
27
28
29
# File 'lib/oraora/oci.rb', line 21

def exec(sql, *bindvars, &block)
  ret = nil
  thread = Thread.new { ret = super }
  thread.join
  ret
rescue Interrupt
  self.break
  raise
end

#logoffObject

Wrapped in a separate thread as OCI8 seems to ignore interrupts



13
14
15
16
17
18
# File 'lib/oraora/oci.rb', line 13

def logoff
  ret = nil
  thread = Thread.new { ret = super }
  thread.join
  ret
end

#pluck(sql, *bindvars) ⇒ Object

Returns the query result as an array of arrays



43
44
45
46
47
# File 'lib/oraora/oci.rb', line 43

def pluck(sql, *bindvars)
  result = []
  exec(sql, *bindvars) { |row| result << row }
  result
end

#pluck_one(sql, *bindvars) ⇒ Object

Returns first column of a query as an array



50
51
52
53
54
# File 'lib/oraora/oci.rb', line 50

def pluck_one(sql, *bindvars)
  result = []
  exec(sql, *bindvars) { |row| result << row.first }
  result
end

#select_one(sql, *bindvars) ⇒ Object

Wrapped in a separate thread with Interrupt handling



32
33
34
35
36
37
38
39
40
# File 'lib/oraora/oci.rb', line 32

def select_one(sql, *bindvars)
  ret = nil
  thread = Thread.new { ret = super }
  thread.join
  ret
rescue Interrupt
  self.break
  raise
end