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.



95
96
97
98
99
100
101
102
# File 'lib/plsql/jdbc_connection.rb', line 95

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



124
125
126
# File 'lib/plsql/jdbc_connection.rb', line 124

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



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/plsql/jdbc_connection.rb', line 104

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'].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



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

def close
  @statement.close
end

#execObject



120
121
122
# File 'lib/plsql/jdbc_connection.rb', line 120

def exec
  @statement.execute
end