Thanks!

Never knew you could do it that way. That's of great help. :)

Thanks again,
Helge Elvik

-----Original Message-----
From: Lugovoi Nikolai [mailto:meadow.nnick / gmail.com] 
Sent: 4. august 2006 13:16
To: ruby-talk ML
Subject: Re: [postgres] Is there a way to avoid having the library
slurp-read the whole result-set?

2006/8/4, Helge Elvik <helge.elvik / gispartner.no>:
> I've looked for things like that, but it doesn't seem like they've
been
> exposed in the Ruby API. If I try to make a DBI prepared statement, it
> will just slurp-read the first time I call execute on it. The native
> PostgreSQL-extension doesn't seem to have any classes for cursors or
> prepared statements, and neither does the pure Ruby version.
>

Hm, I wonder why would you need special API for that?
PGconn.exec should be sufficient:

require 'postgres'
c = PGconn.new
c.exec("BEGIN")
c.exec("DECLARE my_curs CURSOR FOR SELECT * FROM
generate_series(1,20000)")
while (rs  =  c.exec("FETCH FORWARD 1000 FROM my_curs"))  &&
rs.num_tuples > 0
    rs.each { |r| print r[0], "," }
    rs.close
end
c.exec("CLOSE my_curs")
c.exec("COMMIT")

> Does anyone know if ActiveRecord might be a solution? Does it have
it's
> own implementation of a PostgreSQL connector?
>

ActiveRecord just uses ruby-postgres or postgres-pr libs