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.



71
72
73
74
75
76
77
78
# File 'lib/plsql/jdbc_connection.rb', line 71

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



100
101
102
# File 'lib/plsql/jdbc_connection.rb', line 100

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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/plsql/jdbc_connection.rb', line 80

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','REF CURSOR'].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



104
105
106
# File 'lib/plsql/jdbc_connection.rb', line 104

def close
  @statement.close
end

#execObject



96
97
98
# File 'lib/plsql/jdbc_connection.rb', line 96

def exec
  @statement.execute
end