class PLSQL::Connection

Constants

RUBY_TEMP_TABLE_PREFIX

Attributes

activerecord_class[R]
raw_driver[R]

Public Instance Methods

autocommit=(value) click to toggle source

Set autocommit mode (true or false)

# File lib/plsql/connection.rb, line 91
def autocommit=(value)
  raise NoMethodError, "Not implemented for this raw driver"
end
autocommit?() click to toggle source

Current autocommit mode (true or false)

# File lib/plsql/connection.rb, line 86
def autocommit?
  raise NoMethodError, "Not implemented for this raw driver"
end
database_version() click to toggle source

Returns array with major and minor version of database (e.g. [10, 2])

# File lib/plsql/connection.rb, line 191
def database_version
  raise NoMethodError, "Not implemented for this raw driver"
end
drop_all_ruby_temporary_tables() click to toggle source

Drop all ruby temporary tables that are used for calling packages with table parameter types defined in packages

# File lib/plsql/connection.rb, line 214
def drop_all_ruby_temporary_tables
  select_all("SELECT table_name FROM user_tables WHERE temporary='Y' AND table_name LIKE :table_name",
              RUBY_TEMP_TABLE_PREFIX.upcase+'%').each do |row|
    exec "TRUNCATE TABLE #{row[0]}"
    exec "DROP TABLE #{row[0]}"
  end
end
drop_session_ruby_temporary_tables() click to toggle source

Drop ruby temporary tables created in current session that are used for calling packages with table parameter types defined in packages

# File lib/plsql/connection.rb, line 223
def drop_session_ruby_temporary_tables
  select_all("SELECT table_name FROM user_tables WHERE temporary='Y' AND table_name LIKE :table_name",
              RUBY_TEMP_TABLE_PREFIX.upcase+"#{session_id}_%").each do |row|
    exec "TRUNCATE TABLE #{row[0]}"
    exec "DROP TABLE #{row[0]}"
  end
end
jdbc?() click to toggle source

Is it JDBC connection

# File lib/plsql/connection.rb, line 66
def jdbc?
  @raw_driver == :jdbc
end
oci?() click to toggle source

Is it OCI8 connection

# File lib/plsql/connection.rb, line 61
def oci?
  @raw_driver == :oci
end
prefetch_rows=(value) click to toggle source

Set number of rows to be prefetched. This can reduce the number of network round trips when fetching many rows. The default value is one. (If ActiveRecord oracle_enhanced connection is used then default is 100)

# File lib/plsql/connection.rb, line 97
def prefetch_rows=(value)
  raise NoMethodError, "Not implemented for this raw driver"
end
raw_connection() click to toggle source

Returns OCI8 or JDBC connection

# File lib/plsql/connection.rb, line 52
def raw_connection
  if @activerecord_class
    @activerecord_class.connection.raw_connection
  else
    @raw_connection
  end
end
session_id() click to toggle source

Returns session ID

# File lib/plsql/connection.rb, line 196
def session_id
  @session_id ||= select_first("SELECT TO_NUMBER(USERENV('SESSIONID')) FROM dual")[0]
end
set_time_zone(time_zone=nil) click to toggle source

Set time zone (default taken from TZ environment variable)

# File lib/plsql/connection.rb, line 201
def set_time_zone(time_zone=nil)
  time_zone ||= ENV['TZ']
  exec("alter session set time_zone = '#{time_zone}'") if time_zone
end
time_zone() click to toggle source

Returns session time zone

# File lib/plsql/connection.rb, line 207
def time_zone
  select_first("SELECT SESSIONTIMEZONE FROM dual")[0]
end