Class: PLSQL::OCIConnection::Cursor
Overview
Constant Summary
collapse
- @@open_cursors =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#fetch_all, #fetch_hash, #fetch_hash_all
Constructor Details
#initialize(conn, raw_cursor) ⇒ Cursor
Returns a new instance of Cursor.
66
67
68
69
70
|
# File 'lib/plsql/oci_connection.rb', line 66
def initialize(conn, raw_cursor)
@connection = conn
@raw_cursor = raw_cursor
@@open_cursors.push self
end
|
Instance Attribute Details
#raw_cursor ⇒ Object
Returns the value of attribute raw_cursor.
64
65
66
|
# File 'lib/plsql/oci_connection.rb', line 64
def raw_cursor
@raw_cursor
end
|
Class Method Details
.new_from_parse(conn, sql) ⇒ Object
72
73
74
75
|
# File 'lib/plsql/oci_connection.rb', line 72
def self.new_from_parse(conn, sql)
raw_cursor = conn.raw_connection.parse(sql)
self.new(conn, raw_cursor)
end
|
.new_from_query(conn, sql, bindvars = [], options = {}) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/plsql/oci_connection.rb', line 77
def self.new_from_query(conn, sql, bindvars=[], options={})
cursor = new_from_parse(conn, sql)
if prefetch_rows = options[:prefetch_rows]
cursor.prefetch_rows = prefetch_rows
end
cursor.exec(*bindvars)
cursor
end
|
Instance Method Details
#[](key) ⇒ Object
100
101
102
|
# File 'lib/plsql/oci_connection.rb', line 100
def [](key)
@connection.ora_value_to_ruby_value(@raw_cursor[key])
end
|
#bind_param(arg, value, metadata) ⇒ Object
90
91
92
93
94
|
# File 'lib/plsql/oci_connection.rb', line 90
def bind_param(arg, value, metadata)
type, length = @connection.plsql_to_ruby_data_type(metadata)
ora_value = @connection.ruby_value_to_ora_value(value, type)
@raw_cursor.bind_param(arg, ora_value, type, length)
end
|
#close ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/plsql/oci_connection.rb', line 117
def close
while (open_cursor = @@open_cursors.pop) && !open_cursor.equal?(self)
open_cursor.close_raw_cursor
end
close_raw_cursor
end
|
#close_raw_cursor ⇒ Object
113
114
115
|
# File 'lib/plsql/oci_connection.rb', line 113
def close_raw_cursor
@raw_cursor.close
end
|
#exec(*bindvars) ⇒ Object
96
97
98
|
# File 'lib/plsql/oci_connection.rb', line 96
def exec(*bindvars)
@raw_cursor.exec(*bindvars)
end
|
#fetch ⇒ Object
104
105
106
107
|
# File 'lib/plsql/oci_connection.rb', line 104
def fetch
row = @raw_cursor.fetch
row && row.map{|v| @connection.ora_value_to_ruby_value(v)}
end
|
#fields ⇒ Object
109
110
111
|
# File 'lib/plsql/oci_connection.rb', line 109
def fields
@fields ||= @raw_cursor.get_col_names.map{|c| c.downcase.to_sym}
end
|
#prefetch_rows=(value) ⇒ Object
86
87
88
|
# File 'lib/plsql/oci_connection.rb', line 86
def prefetch_rows=(value)
@raw_cursor.prefetch_rows = value
end
|