Class: PLSQL::JDBCConnection::Cursor

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

Instance Method Summary collapse

Constructor Details

#initialize(sql, conn) ⇒ Cursor

Returns a new instance of Cursor.



287
288
289
290
291
292
293
294
# File 'lib/plsql/connection.rb', line 287

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

Instance Method Details

#[](key) ⇒ Object



309
310
311
# File 'lib/plsql/connection.rb', line 309

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

#bind_param(key, value, type = nil, length = nil, in_out = 'IN') ⇒ Object



296
297
298
299
300
301
302
303
# File 'lib/plsql/connection.rb', line 296

def bind_param(key, value, type=nil, length=nil, in_out='IN')
  @connection.set_bind_variable(@statement, key, value, type, length)
  if in_out =~ /OUT/
    @out_types[key] = type || value.class
    @out_index[key] = bind_param_index(key)
    @statement.registerOutParameter(@out_index[key],@connection.get_java_sql_type(value,type))
  end
end

#closeObject



313
314
315
# File 'lib/plsql/connection.rb', line 313

def close
  @statement.close
end

#execObject



305
306
307
# File 'lib/plsql/connection.rb', line 305

def exec
  @statement.execute
end