Ruby program for sql query

Hi everybody,

I am currently working on a database system that utilizes ruby on rails
with a oracle database. Here’s the situation:
the ruby on rails web application is up and running;
my oracle database is full of tables that are populated with data;
there is a successful connection between rails and my oracle database;
however, what isn’t finished is I currently have data mining queries in
sql (eg. find minimum time someone has been employed = “Select
min(time) from table…etc”) and what I need to do is write one ruby
program for each of my sql queries so that the ruby program:

  1. connects to the oracle database each time the query is called
  2. runs the sql query on the oracle database
  3. takes the results from the query and returns them in an array or
    something of that nature (so that I can use the results in an html file
    on the ruby on rails web application).

I have some experience writing ruby, although it’s been a couple years,
but if someone could give me example code of what this would look like
(using different sql queries) I would really appreciate that. I’m
keeping my fingers crossed,
Thanks

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ronald Reichard wrote:
| Hi everybody,
|
| I am currently working on a database system that utilizes ruby on rails
| with a oracle database. Here’s the situation:
| the ruby on rails web application is up and running;
| my oracle database is full of tables that are populated with data;
| there is a successful connection between rails and my oracle database;
| however, what isn’t finished is I currently have data mining queries in
| sql (eg. find minimum time someone has been employed = “Select
| min(time) from table…etc”) and what I need to do is write one ruby
| program for each of my sql queries so that the ruby program:
| 1) connects to the oracle database each time the query is called
| 2) runs the sql query on the oracle database
| 3) takes the results from the query and returns them in an array or
| something of that nature (so that I can use the results in an html file
| on the ruby on rails web application).
|
| I have some experience writing ruby, although it’s been a couple years,
| but if someone could give me example code of what this would look like
| (using different sql queries) I would really appreciate that. I’m
| keeping my fingers crossed,
| Thanks

ActiveRecord comes with a #find and #find_by_sql method:
http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000344

All you need to do is generate the appropriate controllers and views for
these controllers to display the data you need.

Also, it is better to ask the Rails community questions regarding Rails:

rubyonrails.com/community


Phillip G.
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

~ Calvin: Sometimes when I’m talking, my words can’t keep up with my
thoughts. I wonder why we think faster than we speak.
~ Hobbes: Probably so we can think twice.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgZSWgACgkQbtAgaoJTgL/MFQCeKPZew2bSZYD/A4+j0vH0Qeya
R9YAoJivjqG2zXLJnWpzHYQMtF6fPLiM
=D3gv
-----END PGP SIGNATURE-----

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs