Thread: Pg module and several result objects

Pg module and several result objects

From
"Timur V. Irmatov"
Date:
Hello, People!

I'm using Pg module to access PostgreSQL from my perl scripts.  I have
a question which is not clarified by reading man page..

Suppose I have one query:
my $res = $conn->exec(...);
and then I perfrom seconf one:
my $res2 = $conn->exec(...);

Thus, I use two different result objects and perform fetchrow on them
in turn.  I think it is OK, and I have checked that on practice.  But
to be sure, I'd like to hear it from people who know the truth ;-)

Sincerely Yours,
Timur
mailto:itvthor@sdf.lonestar.org


Re: Pg module and several result objects

From
Martijn van Oosterhout
Date:
On Fri, Oct 11, 2002 at 05:10:28PM +0500, Timur V. Irmatov wrote:
> Hello, People!
>
> I'm using Pg module to access PostgreSQL from my perl scripts.  I have
> a question which is not clarified by reading man page..
>
> Suppose I have one query:
> my $res = $conn->exec(...);
> and then I perfrom seconf one:
> my $res2 = $conn->exec(...);
>
> Thus, I use two different result objects and perform fetchrow on them
> in turn.  I think it is OK, and I have checked that on practice.  But
> to be sure, I'd like to hear it from people who know the truth ;-)

Yes, you can do this. When you do the query, the entire result is shipped to
the client before it returns. So it works. It also means that if you have a
really large resultset, you'll need to use cursors to manage it.

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.