Class: OraUtils::SqlplusCommand
- Inherits:
-
OraCommand
- Object
- OraCommand
- OraUtils::SqlplusCommand
- Includes:
- EasyType::Template
- Defined in:
- lib/orabase/utils/sqlplus_command.rb
Constant Summary collapse
- VALID_OPTIONS =
[ :sid, :os_user, :password, :timeout, :username, :failonsqlfail, # Don't fail if the sql fails :parse # Parse the output as cvs. We need this. This is default true ]
Constants inherited from OraCommand
OraCommand::ASM_OS_USER_NAME, OraCommand::DEFAULT_TIMEOUT, OraCommand::ORA_OS_USER_NAME
Instance Method Summary collapse
- #execute(arguments) ⇒ Object
- #execute_sql_command(command, output_file) ⇒ Object
-
#initialize(options = {}) ⇒ SqlplusCommand
constructor
A new instance of SqlplusCommand.
Methods inherited from OraCommand
Constructor Details
#initialize(options = {}) ⇒ SqlplusCommand
Returns a new instance of SqlplusCommand.
18 19 20 21 22 |
# File 'lib/orabase/utils/sqlplus_command.rb', line 18 def initialize( = {}) @failonsqlfail = .fetch(:failonsqlfail) { true} @parse = .fetch(:parse) { true} super('sqlplus -S /nolog ', , VALID_OPTIONS) end |
Instance Method Details
#execute(arguments) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/orabase/utils/sqlplus_command.rb', line 24 def execute(arguments) = {:failonfail => true} value = '' command = command_string(arguments) within_time(@timeout) do Puppet.debug "Executing #{@command} command: #{arguments} on #{@sid} as #{os_user}, connected as #{username}" value = Puppet::Util::Execution.execute(command, ) end value end |
#execute_sql_command(command, output_file) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/orabase/utils/sqlplus_command.rb', line 36 def execute_sql_command(command, output_file) Puppet.debug "Executing sql statement :\n #{command}" script = command_file( template('puppet:///modules/oracle/shared/execute.sql.erb', binding)) execute "@#{script}" @parse ? File.read(output_file) : '' end |