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.



102
103
104
105
106
107
108
109
# File 'lib/plsql/jdbc_connection.rb', line 102

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



131
132
133
# File 'lib/plsql/jdbc_connection.rb', line 131

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



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/plsql/jdbc_connection.rb', line 111

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



135
136
137
# File 'lib/plsql/jdbc_connection.rb', line 135

def close
  @statement.close
end

#execObject



127
128
129
# File 'lib/plsql/jdbc_connection.rb', line 127

def exec
  @statement.execute
end