gpt4 book ai didi

perl - 如何使用perl将每个oracle错误消息的所有返回行转换为一个变量

转载 作者:行者123 更新时间:2023-12-03 07:51:36 25 4
gpt4 key购买 nike

如何将"$dblink is down"的所有行合并为一个$l_msg字符串?

理想情况下,我想获取失败时oracle返回的错误,并且我看不到解决此问题的方法。

my $dblinks = $l_dbh->selectcol_arrayref("select dbname from db_link"); 
for my $dblink (@$dblinks) {
my $l_results = eval {
my ($l_erg) = $l_dbh->selectrow_array("SELECT dummy||'OK' "
. $l_dbh->quote_identifier($dblink, undef, "dual") );
$l_erg;
};
while (@l_row = $l_results->fetchrow_array) {
$l_erg=$l_row[0];
if ($l_results !~ /XOK/) {
@l_errstr=();
l_msg="$dblink is down with @l_errstr"
# dblink45667 is down with ORA-12154"

} else {
say "$dblink is is up";
}
}
}

最佳答案

如何将它们串联到循环外的变量中:

my $dblinks = $l_dbh->selectcol_arrayref("select dbname from db_link"); 
my $l_msg = '';
for my $dblink (@$dblinks) {
my $l_results = eval {
my ($l_erg) = $l_dbh->selectrow_array("SELECT dummy||'OK' "
. $l_dbh->quote_identifier($dblink, undef, "dual") );
$l_erg;
};
while (@l_row = $l_results->fetchrow_array) {
$l_erg=$l_row[0];
if ($l_results !~ /XOK/) {
@l_errstr=();
l_msg .= "$dblink is down with @l_errstr"
# dblink45667 is down with ORA-12154"

} else {
say "$dblink is is up";
}
}
}

关于perl - 如何使用perl将每个oracle错误消息的所有返回行转换为一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2355887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com