Whatever your database driver accepts as a valid SQL statement is fine as far as the DBI is concerned. Thus, if Oracle accepts a query like "SELECT COUNT(*) from t1; SELECT COUNT(*) from t2;" so you can do it.
If that is not the case, you can force that behavior with some SQL features:
my $query = qq{
select "t1" as t, count(*) as c from table_one
UNION ALL
select "t2", count(*) from table_two
};
# Gives
# +----+---+
# | t | c |
# +----+---+
# | t1 | 4 |
# | t2 | 2 |
# +----+---+
my $table_status = $dbh->selectall_arrayref($query, {Slice => {}} );
# $table_status = [
# { t => 't1', c => 4 },
# { t => 't2', c => 2 }
# ];
Or:
my $query = qq{
SELECT
( select count(*) from table_one ) AS t1,
( select count(*) from table_two ) AS t2;
};
# Gives
# +----+----+
# | t1 | t2 |
# +----+----+
# | 4 | 2 |
# +----+----+
my @table_status = $dbh->selectrow_array($query);
# @table_status = ( 4, 2 );
I would personally recommend against this, since I prefer to have better control on my SQL statements. However, if you know what you're doing, it's up to you to decide.