开发者

Using Perl to select 1 from@db_link where db_link comes from each entries of a lookup table

I want to read a table in Oracle which contains database links for checking availability of each database link and return only the bad results for each database link and error message.

I want to fetch this lookup table into an array, and pass the entries of db_link to a s开发者_如何转开发elect from dualQdb_link, test all the entries of lookup to test for success or failure. This seems very hard to achieve in perl.

Any ideas?


Seems pretty straightforward, something like this:

# Or whatever the column is really named ;)
my $dblinks = $dbh->selectcol_arrayref("select dbname from db_link");

for my $dblink (@$dblinks) {
  my $success = eval {
    my ($ret) = $dbh->selectrow_array("select 1 from "
      . $dbh->quote_identifier($dblink, undef, "dual") );
    $ret;
  };

  if ($success) {
    say "$dblink is up";
  } else {
    say "$dblink is down";
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜