Legal | Privacy
#fetch.rb: Fetch data from database
require 'config.rb'

# Create a connection to Oracle
conn = OCI8.new(DB_USER, DB_PASSWORD, DB_SERVER)

# parse and exec the statement
cursor = conn.parse("select * from regions")
cursor.exec

# output column names
puts cursor.getColNames.join(",")

# output rows
while r = cursor.fetch 
	puts r.join(",")
end

# close the cursor and logoff
cursor.close
conn.logoff
puts '-'*80
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy