function call and fetchrow->array or fetchall->arrayref (newbie)
Vasquez, Mike
mike.vasquez at akamai.com
Mon Nov 27 17:41:57 CST 2000
~sdpm~
Not sure to which user group to ask this question.
Here's the scenerio:
I have 31 machines, each machine has a name ("machine 01", "machine 02",
etc.), each machine has an ip address.
All of this is in an oracle db.
I've connected to the db.
I call: sub{my (@num) = (0, 1, 5); &whatever(@num)}->(), #####This sub
will be called 6 times with different values
sub whatever{
$a = @_[0];
$b = @_[1];
$c = @_[2];
$location = dbh->quote("machine" . " " . $a . '%');
###my sql statement is so --
$sth = $dbh->prepare("
SELECT machine_name, ip_address
FROM machines
where machine_name like $location
order by machine_name
");
#### This will return machines 01-09
$sth->execute();
while(($macinename, $ip) = $sth->fetchrow_array){
$testname = $q->param('loc') . ' ' . $a . $b;
###$q->pram('loc') value is "machine"
if( $testname eq $encname && $b lt $c){
print $machinename . ' ' $ip . '<br>';
}
$b++;
}
}
This prints out ...
machine 01
machine 02
machine 03
machine 04
Problem that I am having is when I try to call this function again like
this:
sub{my (@num) = (0, 5, 9); &whatever(@num)}->(),
I get the first call returned and this function call returns nothing.
I'm getting the results from the first function call with the same values.
I want to be able to call the first function with specific values and then
call it again with another set of values So the print out result would be
like this:
machine 01
machine 02
machine 03
machine 04
machine 05
machine 06
machine 07
machine 08
Am I using $sth->fetchrow_array correctly or should I be using
fetchall->arrayref instead?
Any help would be appreciated.
Mike Vasquez
~sdpm~
The posting address is: san-diego-pm-list at hfb.pm.org
List requests should be sent to: majordomo at hfb.pm.org
If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:
unsubscribe san-diego-pm-list
If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.
More information about the San-Diego-pm
mailing list