Class: Sneaql::Core::Commands::SneaqlAssignResult

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

Overview

assigns a session variable to a value returned from a sql query

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(target_var_name) ⇒ Object

run the query… then assign the result to a session variable

Parameters:

  • target_var_name (String)


46
47
48
49
50
51
52
53
# File 'lib/sneaql_lib/core.rb', line 46

def action(target_var_name)
  @expression_handler.set_session_variable(
    target_var_name,
    sql_result
  )
rescue => e
  @exception_manager.pending_error = e
end

#arg_definitionObject

argument types



56
57
58
# File 'lib/sneaql_lib/core.rb', line 56

def arg_definition
  [:variable]
end

#sql_resultObject

returns value at first row/field in result set



61
62
63
64
65
66
67
# File 'lib/sneaql_lib/core.rb', line 61

def sql_result
  JDBCHelpers::SingleValueFromQuery.new(
    @jdbc_connection,
    @statement,
    @logger
  ).result
end