ruby program for sql query

  • Thread starter Ronald Reichard
  • Start date
R

Ronald Reichard

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
 
P

Phillip Gawlowski

-----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 Gawlowski
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-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top