# fetch_r.rb: Fetch in a more ruby-like way
require 'config.rb'
# Create a connection to Oracle
conn = OCI8.new(DB_USER, DB_PASSWORD, DB_SERVER)
# Fetch and display the rows in a block
nrow = conn.exec("select * from regions") do |r|
puts r.join(",")
end
# Display count of rows
puts ' '*30 + nrow.to_s + " rows were fetched."
conn.logoff
puts '-'*80
|