in reply to simple MySQL prob

As jeffa suggests, you need to break your process into 2 actions. And as I refer to here, you might consider loading all of your values into hash keys at the beginning of your script. Handling the comparison in the hash will increase your performance, although some might argue that this doesn't scale as well. I beg to differ... my particular DBI script went from a runtime of minutes (allowing the database to handle the logic) to just under 7 seconds (loading the keys and then performing the logic in the hash). Here's an example...
my $session = shift; # value we want to query for my $dbh = DBI->connect("DBI:mysql:$database:$server","$username","$pas +sword"); &extract_hash; unless ($session_hash{$session}) { &inject; } $dbh->disconnect(); sub extract_hash { my $select_query = "SELECT session FROM stats"; my $sth0 = $dbh->prepare($select_query); $sth0->execute(); while (@data = $sth0->fetchrow_array) { $session_hash{$data[0]} = 1; } } sub inject { my $insert_stmt = "INSERT INTO stats (date, time, user, session, action, type, zone) VALUES (?,?,?,?, +?,?,?)"; my $sth2 = $dbh->prepare($insert_stmt); $sth2->execute($date,$time,$user,$session,$action,$type,$zone) +; }
UPDATE: As Tardis alludes to below, you might need to worry about transactions, depending on your usage. I ass-u-me'd that you'd be performing this in a similar context to mine, where I run it in an isolated environment via cron. That may or may not be the case.

-fuzzyping