Class: JDBCHelper::ProcedureWrapper

Inherits:
ObjectWrapper show all
Defined in:
lib/jdbc-helper/wrapper/procedure_wrapper.rb

Overview

conn.procedure(:my_procedure).call(1, [“a”, String], Fixnum)

Instance Attribute Summary

Attributes inherited from ObjectWrapper

#connection, #name

Instance Method Summary collapse

Constructor Details

#initialize(conn, name) ⇒ ProcedureWrapper

Returns a new instance of ProcedureWrapper.



14
15
16
17
# File 'lib/jdbc-helper/wrapper/procedure_wrapper.rb', line 14

def initialize conn, name
  super conn, name
  @cols = nil
end

Instance Method Details

#call(*args) ⇒ Hash

Executes the procedure and returns the values of INOUT & OUT parameters in Hash

Returns:

  • (Hash)


21
22
23
24
25
26
27
28
29
# File 'lib/jdbc-helper/wrapper/procedure_wrapper.rb', line 21

def call(*args)
  params = build_params args
  cstmt = @connection.prepare_call "{call #{name}(#{Array.new(@cols.length){'?'}.join ', '})}"
  begin
    process_result( args, cstmt.call(*params) )
  ensure
    cstmt.close
  end
end

#refreshJDBCHelper::ProcedureWrapper

Reloads procedure metadata. Metadata is cached for performance. However, if you have modified the procedure, you need to reload the metadata with this method.



35
36
37
38
# File 'lib/jdbc-helper/wrapper/procedure_wrapper.rb', line 35

def refresh
  @cols = @defaults = nil
  self
end