You have two $host variables, the one passed as the parameter will be overwritten by the SOX function which returns the DB host name used for connection. In the Update query that would remain constant for whatever database you connected to. I'm guessing the problem is that you want separate variables for the remote host and the database host. If that's not the case and the code is written as intended the problem is most likely still the SQL WHERE predicate, and you may want to try doing a SELECT to ensure that records are being returned, perhaps also returning the variable passed as a literal so it can be directly compared to the database field.
kapil.V wrote: > Hi, > I used the code: > sub set_min{ > > $host = shift; > $date = shift; > print "The host is $host and the date is $date\nIn the function > set_min\n"; > $host = SOX::get_db_host(); > $user = SOX::get_db_user(); > $passwd = SOX::get_db_passwd(); > > $db = DBI-> connect ( $host, $user, $passwd, {'AutoCommit' => > 0, 'PrintError' => (not $debug), 'RaiseError' => $debug } ); > my $insert_query = qq{ > UPDATE hosts SET last_checked = '$date' WHERE hostname > = '$host'; > }; > $sth = $db -> prepare($insert_query) > or die "Could not prepare the statement: ".$db -> errstr;; > $sth -> execute or die "Could not execute query\n"; > $sth -> finish; > $db -> commit(); > $db -> disconnect(); > > } > > The code runs without any warnings/errors, but the database is not > touched. > What is wrong? > > Thanks. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/