Class: MintPress::OracleUtils::SQLSessionImpl

Inherits:
Object
  • Object
show all
Includes:
MintLogger, Mixins::Properties
Defined in:
src/oracle-utils/lib/oracle-utils/sql-session.rb

Properties (Read/Write)

  • #host ⇒ MintPress::Infrastructure::Host
    Host on which to run the sqlplus commands - this host must have an available SQLplus available to connect_user

    Property Attributes
    • no_backreftrue
    • paralleltrue
    • disposition:requires
    
    
    138
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 138
    
    property :host, type: MintPress::Infrastructure::Host, no_backref: true, parallel: true, disposition: :requires
  • #oracle_home ⇒ Pathname (Default Value: Proc.new { self.find_oracle_home })
    'Oracle Home location for the client installation. If this is not specified, it will attempt to find it using oraenv'

    Property Attributes
    • defaultProc.new { self.find_oracle_home }
    
    
    140
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 140
    
    property :oracle_home, type: Pathname, description: 'Oracle Home location for the client installation.  If this is not specified, it will attempt to find it using oraenv', default: Proc.new { self.find_oracle_home }
  • #db_username ⇒ String
    'Database username'

    Property Attributes
    
    
    142
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 142
    
    property :db_username, type: String, description: 'Database username'
  • #db_password ⇒ Mint::Secret
    'Password credential for database user'

    Property Attributes
    • fromString
    
    
    144
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 144
    
    property :db_password, type: Mint::Secret, from: String, description: 'Password credential for database user'
  • #db_role ⇒ String
    'User role'

    Property Attributes
    
    
    146
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 146
    
    property :db_role, type: String, description: 'User role'
  • #db_host ⇒ String
    'Database connection host'

    Property Attributes
    
    
    148
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 148
    
    property :db_host, type: String, description: 'Database connection host'
  • #db_port ⇒ Integer
    'Database connection port'

    Property Attributes
    
    
    149
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 149
    
    property :db_port, type: Integer, description: 'Database connection port'
  • #db_service_name ⇒ String (Default Value: Proc.new { self.get_property(:oracle_sid, disable_proc: true) })
    'Database connection service name'

    Property Attributes
    • defaultProc.new { self.get_property(:oracle_sid, disable_proc: true) }
    
    
    151
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 151
    
    property :db_service_name, type: String, description: 'Database connection service name', default: Proc.new { self.get_property(:oracle_sid, disable_proc: true) }
  • #oracle_sid ⇒ String (Default Value: Proc.new { self.get_property(:db_service_name, disable_proc: true) })
    'Database SID'

    Property Attributes
    • defaultProc.new { self.get_property(:db_service_name, disable_proc: true) }
    
    
    152
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 152
    
    property :oracle_sid, type: String, description: 'Database SID', default: Proc.new { self.get_property(:db_service_name, disable_proc: true) }
  • #db_connect_descriptor ⇒ String (Default Value: Proc.new { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=#{self.get_property(:db_host)})(PORT=#{self.get_property(:db_port)})))(CONNECT_DATA=(SERVICE_NAME=#{self.get_property(:db_service_name, disable_proc: true)})))" })
    'Database connect descriptor that will override with advanced DB connect string such as failover and other advanced settings'

    Property Attributes
    • defaultProc.new { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=#{self.get_property(:db_host)})(PORT=#{self.get_property(:db_port)})))(CONNECT_DATA=(SERVICE_NAME=#{self.get_property(:db_service_name, disable_proc: true)})))" }
    
    
    154
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 154
    
    property :db_connect_descriptor, type: String, description: 'Database connect descriptor that will override with advanced DB connect string such as failover and other advanced settings', default: Proc.new { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=#{self.get_property(:db_host)})(PORT=#{self.get_property(:db_port)})))(CONNECT_DATA=(SERVICE_NAME=#{self.get_property(:db_service_name, disable_proc: true)})))" }
  • #local ⇒ [TrueClass, FalseClass] (Default Value: false)
    'Connection type'

    Property Attributes
    • defaultfalse
    
    
    156
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 156
    
    property :local, type: [TrueClass, FalseClass], default: false,  description: 'Connection type'
  • #connected ⇒ [TrueClass, FalseClass] (Default Value: false)
    'Connection state of the session'

    Property Attributes
    • defaultfalse
    
    
    158
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 158
    
    property :connected, type: [TrueClass, FalseClass], default: false, description: 'Connection state of the session'
  • #state ⇒ String (Default Value: 'UNKNOWN')
    'Database state'

    Property Attributes
    • default'UNKNOWN'
    
    
    160
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 160
    
    property :state, type: String, default: 'UNKNOWN', description: 'Database state'
  • #use_tnsnames ⇒ [TrueClass, FalseClass] (Default Value: false)

    Property Attributes
    • defaultfalse
    • deprecatedtrue
    
    
    162
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 162
    
    property :use_tnsnames, type: [TrueClass, FalseClass], default: false, deprecated: true
  • #connect_timeout ⇒ Integer (Default Value: 30)
    'Connection timeout'

    Property Attributes
    • default30
    
    
    164
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 164
    
    property :connect_timeout, type: Integer, default: 30, description: 'Connection timeout'
  • #timeout ⇒ Integer (Default Value: 36000)
    'Session timeout'

    Property Attributes
    • default36000
    
    
    166
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 166
    
    property :timeout, type: Integer, default: 36000, description: 'Session timeout'
  • #environment_variables ⇒ Hash of ⇒ String (Default Value: {})
    "Environment variables to be set when calling sqlplus. These will be in addition to ORACLE_HOME, LD_LIBRARY_PATH and ORACLE_SID that we set by default. Passing those variables again will override the default ones. Any new variable will be appended."

    Property Attributes
    • default{}
    
    
    174
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 174
    
    property :environment_variables, type: String, hash: true, default: {}, description: "Environment variables to be set when calling sqlplus. These will be in addition to ORACLE_HOME, LD_LIBRARY_PATH and ORACLE_SID that we set by default. Passing those variables again will override the default ones. Any new variable will be appended."
  • #default_directory ⇒ String
    "If set, we will set the PWD to this directory before executing sqlplus, e.g. if this value is set to '/tmp/mysql-scripts', MintPress will do a 'cd /tmp/mysql-scripts' and then run sqlplus. This comes in handy with SQLPATH environment variable which you can set with the environment_variables property. If the directory does not exists, MintPress will create it."

    Property Attributes
    
    
    176
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 176
    
    property :default_directory, type: String, description: "If set, we will set the PWD to this directory before executing sqlplus, e.g. if this value is set to '/tmp/mysql-scripts', MintPress will do a 'cd /tmp/mysql-scripts' and then run sqlplus. This comes in handy with SQLPATH environment variable which you can set with the environment_variables property. If the directory does not exists, MintPress will create it."
  • #sql_properties ⇒ Hash of ⇒ [String,Integer,TrueClass,FalseClass] (Default Value: { })
    "This property allows you to set SQL properties inside the SQLPLUS session, e.g. setting this value to {'feedback' => 'off', 'verify' => 'on'} will set these two properties before running the SQL file/commands. MintPress also sets up some default properties as defined by the 'default_sql_props' property viz. [ 'feedback' => 'off', 'heading' => 'off', 'verify' => 'off', 'pagesize' => 0, 'linesize' => 2000, 'trimspool' => 'on', 'echo' => 'off']. Passing those properties again will override the default ones. Any new property will be appended."

    Property Attributes
    • default{ }
    
    
    180
    # File 'src/oracle-utils/lib/oracle-utils/sql-session.rb', line 180
    
    property :sql_properties, type: [String,Integer,TrueClass,FalseClass], hash: true, default:{ }, description: "This property allows you to set SQL properties inside the SQLPLUS session, e.g. setting this value to {'feedback' => 'off', 'verify' => 'on'} will set these two properties before running the SQL file/commands. MintPress also sets up some default properties as defined by the 'default_sql_props' property viz. [ 'feedback' => 'off', 'heading' => 'off', 'verify' => 'off', 'pagesize' => 0, 'linesize' => 2000, 'trimspool' => 'on', 'echo' => 'off']. Passing those properties again will override the default ones. Any new property will be appended."

Properties (Read Only)

Constant Summary

Constants included from MintLogger

MintLogger::DEBUG, MintLogger::ERROR, MintLogger::FATAL, MintLogger::INFO, MintLogger::UNKNOWN, MintLogger::VERBOSE, MintLogger::WARN

Instance Attribute Summary

Attributes included from Mixins::Properties

#autopush_set_cache, #dynamic_create, #harvest_on_access, #harvest_undefined_only, #harvested, #tree_root

Instance Method Summary collapse

Methods included from Mixins::Properties

#[], #[]=, #add_validate_report_result, #armour_set_property, #array_contains?, #array_is_a?, #check_autopush, #check_stack_overflow, #clone_property_object, #cloner_handle_single_property, #coerce_single, #contains_as_string?, #display_validate_report_result, #double_initialize?, #dump_to_hash, #find_parent, #find_parent_by_identity, #generate_accessor_functions, #get_canonical_renamed, #get_from_opts, #get_my_name, #get_property, #get_property_item, #has?, included, #initialize_validate_report, #inspect, #is_cloned_object?, #is_mintpress_object?, #is_probably_canonical?, #is_set?, #local_debug, #local_info, #local_verbose, #mintpress_property_definitions, #place_object_by_identity, #process_properties, #prop_set?, #property, #property_definitions, #property_details, #property_is_simple_object?, #push_root!, #require_property, #require_update, #retrieve_docstring, #sanitize, #set_map_dirty, #set_property, #set_property_item, #show_short_array, #strip_defaults!, #synchronize, #uncloned_property_definitions, #update_map, #validate, #validate_generic, #validate_properties, #validate_property, #validate_required, #version_allowed?, #weakref

Methods included from MintLogger::Utils::Common

#boolean_val, #has_value?, #no_value?, #nvl, #path_as_symbol, #ruby_level_to_send

Constructor Details

#initialize(opts = {}) ⇒ SQLSessionImpl

When SQL*Plus starts, and after CONNECT commands, the site profile (e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile (e.g. login.sql in the working directory) are run. The files may contain SQL*Plus commands.

Instance Method Details

#abort_databaseObject

#archivelogObject

#check_error(stdout, pattern:) ⇒ Object

#check_errors(stdout) ⇒ Object

#closeObject

#connectObject

where proxy has the syntax: proxyuser[username][/password][@connect_identifier] NOTE: Brackets around username in proxy are required syntax

#connect_admin(role: "sysdba") ⇒ Object

#connected?Boolean

Returns:

  • (Boolean)

#execute(sql, ignore_failure: false, ignore_regex: nil, props: {}, wait_for_exit: true, assume_quit: false) ⇒ Object

#find_binary(oracle_home) ⇒ Object

Find SQL*Plus executable

#find_oracle_homeObject

#flashbackObject

#flashback?Boolean

Returns:

  • (Boolean)

#force_loggingObject

#force_logging?Boolean

Returns:

  • (Boolean)

#log_mode?Boolean

Returns:

  • (Boolean)

#mount_databaseObject

#no_force_loggingObject

#noarchivelogObject

#nomount_databaseObject

#open_databaseObject

#reinitObject

#restart_databaseObject

#shutdown_databaseObject

#sql_file(sql_file, ignore_failure: false, ignore_regex: nil, properties: {}) ⇒ Object

#state?Boolean

Returns:

  • (Boolean)