257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/sequel/adapters/jdbc.rb', line 257
def execute(sql, opts=OPTS, &block)
return call_sproc(sql, opts, &block) if opts[:sproc]
return execute_prepared_statement(sql, opts, &block) if [Symbol, Dataset].any?{|c| sql.is_a?(c)}
synchronize(opts[:server]) do |conn|
statement(conn) do |stmt|
if block
if size = fetch_size
stmt.setFetchSize(size)
end
yield log_connection_yield(sql, conn){stmt.executeQuery(sql)}
else
case opts[:type]
when :ddl
log_connection_yield(sql, conn){stmt.execute(sql)}
when :insert
log_connection_yield(sql, conn){execute_statement_insert(stmt, sql)}
opts = Hash[opts]
opts[:stmt] = stmt
last_insert_id(conn, opts)
else
log_connection_yield(sql, conn){stmt.executeUpdate(sql)}
end
end
end
end
end
|