Class: Sneaql::Core::Commands::SneaqlExecuteIf

Inherits:
SneaqlCommand show all
Defined in:
lib/sneaql_lib/core.rb

Overview

executes a sql statement if the condition evaluates to true

Instance Method Summary collapse

Methods inherited from SneaqlCommand

#initialize, #valid_expression?, #valid_operator?, #valid_recordset?, #valid_symbol?, #valid_variable?, #validate_args

Constructor Details

This class inherits a constructor from Sneaql::Core::SneaqlCommand

Instance Method Details

#action(left_value, operator, right_value) ⇒ Object

Parameters:

  • left_value (String)

    expression as left operand

  • operator (String)

    comparison operator supported by expression handler

  • right_value (String)

    expression as right operand



110
111
112
113
114
115
116
117
118
119
# File 'lib/sneaql_lib/core.rb', line 110

def action(left_value, operator, right_value)
  if @expression_handler.compare_expressions(operator, left_value, right_value)
    @expression_handler.set_session_variable(
      'last_statement_rows_affected',
      rows_affected
    )
  end
rescue => e
  @exception_manager.pending_error = e
end

#arg_definitionObject

argument types



122
123
124
# File 'lib/sneaql_lib/core.rb', line 122

def arg_definition
  [:expression, :operator, :expression]
end

#rows_affectedFixnum

Returns rows affected by SQL statement.

Returns:

  • (Fixnum)

    rows affected by SQL statement



127
128
129
130
131
132
133
# File 'lib/sneaql_lib/core.rb', line 127

def rows_affected
  JDBCHelpers::Execute.new(
    @jdbc_connection,
    @statement,
    @logger
  ).rows_affected
end