my $rv = $dbh->do(q|INSERT INTO ct_data (id_call, id_contest, id_class, id_club, id_station, qth, optime, summary, totalscore, soapbox) VALUES ((SELECT id FROM ct_call WHERE call = upper(?)), (SELECT id FROM ct_contest WHERE name = upper(?)), (SELECT id FROM ct_class WHERE name = upper(?)), (SELECT id FROM ct_club WHERE name = upper(?)), (SELECT id FROM ct_call WHERE call = upper(?)), ?, ?, ?, ?, ?);| ,$call, $contest, $class, $club, $call, $qth, $optime, $summ, $total, $soap); $sth->execute(); $sth->finish(); # we're done with this query