Class: RDBI::Driver::ODBC::Statement
- Inherits:
-
Statement
- Object
- Statement
- RDBI::Driver::ODBC::Statement
- Defined in:
- lib/rdbi/driver/odbc.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
Returns the value of attribute handle.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(query, dbh) ⇒ Statement
constructor
A new instance of Statement.
- #new_execution(*binds) ⇒ Object
Constructor Details
#initialize(query, dbh) ⇒ Statement
Returns a new instance of Statement.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/rdbi/driver/odbc.rb', line 180 def initialize(query, dbh) super @handle = @dbh.handle.prepare(query) @output_type_map = RDBI::Type.create_type_hash(RDBI::Type::Out) @output_type_map[:date] = [ TypeLib::Filter.new( proc{|obj| obj.is_a?(::ODBC::Date)}, proc{|obj| Date.parse(obj.to_s)} ) ] @output_type_map[:time] = [ TypeLib::Filter.new( proc{|obj| obj.is_a?(::ODBC::Time)}, proc{|obj| Time.parse(obj.to_s)} ) ] @output_type_map[:timestamp] = [ TypeLib::Filter.new( proc{|obj| obj.is_a?(::ODBC::TimeStamp)}, proc{|obj| DateTime.parse(obj.to_s)} ) ] end |
Instance Attribute Details
#handle ⇒ Object
Returns the value of attribute handle.
178 179 180 |
# File 'lib/rdbi/driver/odbc.rb', line 178 def handle @handle end |
Instance Method Details
#finish ⇒ Object
226 227 228 229 |
# File 'lib/rdbi/driver/odbc.rb', line 226 def finish @handle.drop super end |
#new_execution(*binds) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/rdbi/driver/odbc.rb', line 208 def new_execution(*binds) @handle.execute(*binds) columns = @handle.columns(true).collect do |col| newcol = RDBI::Column.new newcol.name = col.name.to_sym newcol.type = SQL_TYPES[col.type][:type] newcol.ruby_type = SQL_TYPES[col.type][:ruby_type] newcol.precision = col.precision newcol.scale = col.scale newcol.nullable = col.nullable newcol.table = col.table newcol end return Cursor.new(@handle), RDBI::Schema.new(columns), @output_type_map end |