my $statement="SELECT data FROM table WHERE conditions = x"; my $sth=$sql->prepare("$statement"); $sth->execute(); #...(etc) print STDOUT "$statement";