On Thursday, December 19, 2002, at 06:33 AM, David M. Lloyd wrote:

On 19 Dec 2002, chad kellerman wrote:

  I sure it has got to be something so simply that I am just over
looking.  It just seems that what I am doing now is just too much work
to grab a variable:

 $sth = $dbh->prepare( q{
		SELECT dailypath, hostname FROM tblProcess
		WHERE hostId = ?
		       } );
        $sth->execute ( 543 );
	$sth->bind_columns( \$dailypath, \$hostname  );
        while ( $sth->fetchrow_array () ) {
                push @dailypath, $dailypath;
		push @hostname, $hostname;
        }
        $sth->finish ();
Try this:

my $sth = $dbh->prepare('select dailypath, hostname from tblProcess where hostId = ?');
$sth->execute(543);
my ($dailypath, $hostname) = $sth->fetchrow_array();

You may have to add $sth->finish() if hostId doesn't refer to a unique
column and you don't reuse $sth for a while in your program.
Also try:

$sth->bind_columns(\$dailypath, \$hostname);
while ($sth->fetch)
{
...Magic already happened...
}

$sth->fetch is a synonym for fetchrow_array, but it seems more appropriate with bound output variables where you ignore the array that is returned (for the most part).


Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED]) #include <disclaimer.h>
"I don't suffer from insanity -- I enjoy every minute of it"
Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/

Reply via email to