Forum: Ruby IBM_DB select multiple rows

Posted by Bob Smyph (bobsmyph)
on 2013-02-22 20:26
I need to be able to select multiple rows in ruby.

I currently have the following code:
   dbh = IBM_DB::connect(databaseName, "", "")
   sql1 = "Select * from usernames"
   sth = IBM_DB::exec(@dbh, sql1)
   row1 = IBM_DB::fetch_array(sth)
   puts row1

but this only returns the info for the top row returned. any and all
help is welcomed.
Posted by tamouse mailing lists (Guest)
on 2013-02-23 05:13
(Received via mailing list)
On Fri, Feb 22, 2013 at 1:26 PM, Bob Smyph <lists@ruby-forum.com> wrote:
> help is welcomed.
>
> --
> Posted via http://www.ruby-forum.com/.
>

Not at all familiar with the IBM_DB module, but it looks so PHP-ish,
I'll give it a go.

This looks like it retrieves one row from the selection:
>    row1 = IBM_DB::fetch_array(sth)
Therefore, my guess is you have to put that in a loop until no more
rows are returned.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.