ODBC and Ruby

hello, I'm new in ruby, I've problems conneting ruby odbc with informix db, in tbles with thousand records my program always retruns no rows,

this is the test program:

sth=c.prepare("select * from anopta")

sth.execute
if sth.ncols == 0 then
     puts "Statement has no result set"
     printf "Number of rows affected: %d\n", sth.nrows
   else
     puts "Statement has a result set"
     sth.fetch_all
     printf "Number of rows: %d\n", sth.nrows
     printf "Number of columns: %d\n", sth.ncols
  end

this is the output

Statement has a result set
Number of rows: -1
Number of columns: 5

The table has 5 colums and 300 rows

I don't know if this problem is specific for informix databases

thank u very much

Hello Lorenzo,

···

On Nov 23, 2007 7:55 AM, lorenzo <me@me.it> wrote:

hello, I'm new in ruby, I've problems conneting ruby odbc with informix
db, in tbles with thousand records my program always retruns no rows,

this is the test program:

sth=c.prepare("select * from anopta")

sth.execute
if sth.ncols == 0 then
     puts "Statement has no result set"
     printf "Number of rows affected: %d\n", sth.nrows
   else
     puts "Statement has a result set"
     sth.fetch_all
     printf "Number of rows: %d\n", sth.nrows
     printf "Number of columns: %d\n", sth.ncols
  end

this is the output

Statement has a result set
Number of rows: -1
Number of columns: 5

The table has 5 colums and 300 rows

I don't know if this problem is specific for informix databases

thank u very much

May I suggest you to try the Informix extension instead?

http://ruby-informix.rubyforge.org

--
Gerardo Santana

Hello,
Is not so easy, I'm using Macosx and I don' have informix sdk for it
Have you any ideas?
Thank you :slight_smile:

···

On 2007-11-23 17:32:25 +0100, Gerardo Santana Gómez Garrido <gerardo.santana@gmail.com> said:

Hello Lorenzo,

On Nov 23, 2007 7:55 AM, lorenzo <me@me.it> wrote:

hello, I'm new in ruby, I've problems conneting ruby odbc with informix
db, in tbles with thousand records my program always retruns no rows,

this is the test program:

sth=c.prepare("select * from anopta")

sth.execute
if sth.ncols == 0 then
puts "Statement has no result set"
printf "Number of rows affected: %d\n", sth.nrows
else
puts "Statement has a result set"
sth.fetch_all
printf "Number of rows: %d\n", sth.nrows
printf "Number of columns: %d\n", sth.ncols
end

this is the output

Statement has a result set
Number of rows: -1
Number of columns: 5

The table has 5 colums and 300 rows

I don't know if this problem is specific for informix databases

thank u very much

May I suggest you to try the Informix extension instead?

http://ruby-informix.rubyforge.org

Hello,
Is not so easy, I'm using Macosx and I don' have informix sdk for it

I see.

Have you any ideas?
Thank you :slight_smile:

Yes. I have just remembered (I used to use ruby-odbc with Informix two
years ago) that nrows didn't return any useful value to me for
Informix. Ignore it. You can't know how many records a SELECT returns
in Informix before fetching them.

···

On Nov 23, 2007 11:20 AM, lorenzo <quadrilor@mac.com> wrote:

On 2007-11-23 17:32:25 +0100, Gerardo Santana Gómez Garrido > <gerardo.santana@gmail.com> said:

--
Gerardo Santana

Yes, but querying the table, the rs seems to be empty, ruby give me warning message for no methods for NilClass in each. So I supose the rs is empty, anywhere nrows doesn't work you are right.

···

On 2007-11-23 18:50:22 +0100, Gerardo Santana Gómez Garrido <gerardo.santana@gmail.com> said:

On Nov 23, 2007 11:20 AM, lorenzo <quadrilor@mac.com> wrote:

On 2007-11-23 17:32:25 +0100, Gerardo Santana Gómez Garrido >> <gerardo.santana@gmail.com> said:
Hello,
Is not so easy, I'm using Macosx and I don' have informix sdk for it

I see.

Have you any ideas?
Thank you :slight_smile:

Yes. I have just remembered (I used to use ruby-odbc with Informix two
years ago) that nrows didn't return any useful value to me for
Informix. Ignore it. You can't know how many records a SELECT returns
in Informix before fetching them.