Class: PLSQL::JDBCConnection::CallableStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/plsql/jdbc_connection.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(conn, sql) ⇒ CallableStatement

Returns a new instance of CallableStatement.



142
143
144
145
146
147
148
149
# File 'lib/plsql/jdbc_connection.rb', line 142

def initialize(conn, sql)
  @sql = sql
  @connection = conn
  @params = sql.scan(/\:\w+/)
  @out_types = {}
  @out_index = {}
  @statement = @connection.prepare_call(sql)
end

Instance Method Details

#[](key) ⇒ Object



171
172
173
# File 'lib/plsql/jdbc_connection.rb', line 171

def [](key)
  @connection.ora_value_to_ruby_value(@connection.get_bind_variable(@statement, @out_index[key], @out_types[key]))
end

#bind_param(arg, value, metadata) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/plsql/jdbc_connection.rb', line 151

def bind_param(arg, value, )
  type, length = @connection.plsql_to_ruby_data_type()
  ora_value = @connection.ruby_value_to_ora_value(value, type, )
  @connection.set_bind_variable(@statement, arg, ora_value, type, length, )
  if [:in_out] =~ /OUT/
    @out_types[arg] = type || ora_value.class
    @out_index[arg] = bind_param_index(arg)
    if ["TABLE", "VARRAY", "OBJECT", "XMLTYPE"].include?([:data_type])
      @statement.registerOutParameter(@out_index[arg], @connection.get_java_sql_type(ora_value, type),
        [:sql_type_name])
    else
      @statement.registerOutParameter(@out_index[arg], @connection.get_java_sql_type(ora_value, type))
    end
  end
end

#closeObject



175
176
177
# File 'lib/plsql/jdbc_connection.rb', line 175

def close
  @statement.close
end

#execObject



167
168
169
# File 'lib/plsql/jdbc_connection.rb', line 167

def exec
  @statement.execute
end