Class: DBI::DBD::ADO::Statement
Instance Method Summary
collapse
#quote
#bind, #tokens
#[], #[]=, #bind_params, #cancel, #fetch_all, #fetch_many
Constructor Details
#initialize(handle, statement, db) ⇒ Statement
Returns a new instance of Statement.
109
110
111
112
113
114
|
# File 'lib/dbd/ADO.rb', line 109
def initialize(handle, statement, db)
@handle = handle
@statement = statement
@params = []
@db = db
end
|
Instance Method Details
#bind_param(param, value, attribs) ⇒ Object
116
117
118
119
120
|
# File 'lib/dbd/ADO.rb', line 116
def bind_param(param, value, attribs)
raise InterfaceError, "only ? parameters supported" unless param.is_a? Fixnum
@params[param-1] = value
end
|
#column_info ⇒ Object
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/dbd/ADO.rb', line 187
def column_info
num_cols = @res_handle.Fields().Count()
retval = Array.new(num_cols)
for i in 0...num_cols do
retval[i] = {'name' => @res_handle.Fields(i).Name()}
end
retval
rescue RuntimeError => err
raise DBI::DatabaseError.new(err.message)
end
|
#execute ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/dbd/ADO.rb', line 122
def execute
sql = bind(self, @statement, @params)
@res_handle = @handle.Execute(sql)
if @db['AutoCommit'] == true and not SQL.query?(@statement) then
@db.commit
end
rescue RuntimeError => err
raise DBI::DatabaseError.new(err.message)
end
|
#fetch ⇒ Object
148
149
150
151
152
153
154
|
# File 'lib/dbd/ADO.rb', line 148
def fetch
retval = fetch_currentrow
@res_handle.MoveNext() unless retval.nil?
retval
rescue RuntimeError => err
raise DBI::DatabaseError.new(err.message)
end
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/dbd/ADO.rb', line 158
def fetch_scroll(direction, offset)
case direction
when DBI::SQL_FETCH_NEXT
return fetch
when DBI::SQL_FETCH_PRIOR
@res_handle.MovePrevious()
return fetch_currentrow
when DBI::SQL_FETCH_FIRST
@res_handle.MoveFirst()
return fetch_currentrow
when DBI::SQL_FETCH_LAST
@res_handle.MoveLast()
return fetch_currentrow
when DBI::SQL_FETCH_RELATIVE
@res_handle.Move(offset)
return fetch_currentrow
when DBI::SQL_FETCH_ABSOLUTE
ap = @res_handle.AbsolutePositon()
@res_handle.Move(offset-ap)
return fetch_currentrow
else
raise DBI::InterfaceError
end
rescue RuntimeError => err
raise DBI::DatabaseError.new(err.message)
end
|
#finish ⇒ Object
138
139
140
141
142
143
144
145
146
|
# File 'lib/dbd/ADO.rb', line 138
def finish
if @res_handle.Fields.Count() != 0 then
@res_handle.Close()
end
rescue RuntimeError => err
raise DBI::DatabaseError.new(err.message)
end
|
#rows ⇒ Object
200
201
202
203
|
# File 'lib/dbd/ADO.rb', line 200
def rows
nil
end
|