Class: Avmtrf1::Tools::Runner::Oracle::SourceGet

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/tools/runner/oracle/source_get.rb

Constant Summary collapse

TABLE =
'all_source'

Instance Method Summary collapse

Instance Method Details

#found_countObject



31
32
33
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 31

def found_count
  connection.unique_value(sql(true)).to_i
end

#runObject



21
22
23
24
25
26
27
28
29
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 21

def run
  infov('Name', name)
  infov('Type', type)
  infov('Found', found_count)
  infov('Enconding', OCI8.encoding)
  connection.query(sql(false)) do |row|
    out(row['TEXT'].encode('UTF-8').to_s)
  end
end

#sql(count) ⇒ Object



35
36
37
38
39
40
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 35

def sql(count)
  projection = count ? 'count(*)' : '*'
  selection = "lower(name) = lower('#{name}')"
  selection += " and lower(type) = lower('#{type}')" if type.present?
  "select #{projection} from #{TABLE} where #{selection} order by line"
end