From: [EMAIL PROTECTED]
> Hello all:
> I am pretty new in this matter.
> My code looks like this:
> $sth2=$dbh->prepare("Select job.joid,
> job_name,command,owner,machine,std_out_file,std_err_file,box_joid,time
> zone from job, job2 where job.joid = job2.joid"); $sth2->execute;
> while (my $info = $sth2->fetchrow_hasref) { calls a different
> subroutine to validate each argument like:
> check_job_name($instance,$box_name,$info->{job_name},$info->{machine})
> ;
>
> }
>
> My question is... in my while loop am I quring the database every time
> when I say $sth2-> fetchrow_hasref ?
Not really. Basicaly when you execute the query the server
prepares a resultset (most probably it'll return the first row before it
has found&prepared the last one), then each fetch just tells the
server to send the next row. There is some caching going on and
the driver might even fetch all the data from the server before giving
you the first row, but this is nothing YOU should care about.
(It definitely is not anything I would care about. )
> Is there any way I can call the
> fetchrow one time and store it in a hash.
You could use fetchall_arrayref(), but I would not recomend doing
that unless you are really sure the resultset is small enough. That
would slurp all the data to memory of YOUR process with quite
some overhead.
Stop worrying and fetch the data row after row :-)
Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]