Commit 375e2eec authored by Marek Szuba's avatar Marek Szuba
Browse files

Try to make some SQL statements more readable

parent 41d65f6b
......@@ -432,12 +432,11 @@ sub _list_dbIDs {
if($self->is_multispecies()) {
$column ||= "${table}_id";
my $sql = <<"SQL";
select `rp`.`${column}`
from rnaproduct rp
join transcript t using (transcript_id)
join seq_region sr using (seq_region_id)
join coord_system cs using (coord_system_id)
where cs.species_id = ?
SELECT `rp`.`${column}` FROM rnaproduct rp
JOIN transcript t USING (transcript_id)
JOIN seq_region sr USING (seq_region_id)
JOIN coord_system cs USING (coord_system_id)
WHERE cs.species_id = ?
SQL
return $self->dbc()->sql_helper()->execute_simple(-SQL => $sql, -PARAMS => [$self->species_id()]);
}
......@@ -472,14 +471,16 @@ sub _fetch_direct_query {
my $rp_modified_date =
$self->db()->dbc()->from_date_to_seconds('modified_date');
my $sql =
sprintf("SELECT rp.rnaproduct_id, pt.code, rp.transcript_id, "
. "rp.seq_start, rp.start_exon_id, rp.seq_end, rp.end_exon_id, "
. "rp.stable_id, rp.version, %s, %s "
. "FROM rnaproduct rp JOIN rnaproduct_type pt "
. "ON rp.rnaproduct_type_id = pt.rnaproduct_type_id "
. "WHERE %s = ?",
$rp_created_date, $rp_modified_date, $where_args->[0]);
my $sql_template = <<'SQL';
SELECT rp.rnaproduct_id, pt.code, rp.transcript_id, rp.seq_start,
rp.start_exon_id, rp.seq_end, rp.end_exon_id, rp.stable_id, rp.version,
%s, %s
FROM rnaproduct rp
JOIN rnaproduct_type pt ON rp.rnaproduct_type_id = pt.rnaproduct_type_id
WHERE %s = ?
SQL
my $sql = sprintf( $sql_template,
$rp_created_date, $rp_modified_date, $where_args->[0] );
my $sth = $self->prepare($sql);
$sth->bind_param(1, $where_args->[1], $where_args->[2]);
$sth->execute();
......
......@@ -271,8 +271,9 @@ sub fetch_by_rnaproduct_id {
throw("dbID argument is required") unless defined($p_dbID);
my $sth =
$self->prepare("SELECT transcript_id FROM rnaproduct WHERE rnaproduct_id = ?");
my $sth = $self->prepare(
"SELECT transcript_id FROM rnaproduct WHERE rnaproduct_id = ?"
);
$sth->bind_param(1, $p_dbID, SQL_INTEGER);
$sth->execute();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment