$myvar="location.location_code = '${l}' " #### my $dbh = DBI->connect('DBI:Oracle:','user', 'pass', { RaiseError => 1 }) or die "Could not connect to Oracle backend: $DBI::errstr"; my $query = "select bib_mfhd.bib_id from mfhd_master, bib_mfhd, bib_location, location where ( $myvar ) and bib_mfhd.mfhd_id = mfhd_master.mfhd_id and bib_location.location_id = location.location_id and bib_mfhd.bib_id = bib_location.bib_id and mfhd_master.suppress_in_opac='N' and display_call_no is not null order by bib_id asc"; print "$query\n" if ($ARGV[0] eq "-d"); my $sth = $dbh->prepare($query) || die "Failed preparing the query. WTF?"; my $retcode = $sth->execute;