关闭

eval 捕获错误

126人阅读 评论(0) 收藏 举报
分类:
eval 捕获错误:
[root@dr-mysql01 ~]# cat t1.pl 
use DBI;
my $dbUser='zabbix';
my $user="root";
my $passwd="1234567";
my $dbh  = DBI->connect("dbi:mysql:database=zabbix;host=192.168.32.55;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
eval {
#alter table trends drop partition p20160425;
my $sql="alter table history  drop partition p20160501;";
print "\$sql is $sql\n";
$dbh->do("$sql");
    };
      print $@;
[root@dr-mysql01 ~]# perl t1.pl 
$sql is alter table history  drop partition p20160501;


[root@dr-mysql01 ~]# cat t1.pl 
use DBI;
my $dbUser='zabbix';
my $user="root";
my $passwd="1234567";
my $dbh  = DBI->connect("dbi:mysql:database=zabbix;host=192.168.32.55;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
eval {
#alter table trends drop partition p20160425;
my $sql="alter table history  drop partition p20160401;";
print "\$sql is $sql\n";
$dbh->do("$sql");
    };
      print $@;
[root@dr-mysql01 ~]# perl t1.pl 
$sql is alter table history  drop partition p20160401;
DBD::mysql::db do failed: Error in list of partitions to DROP at t1.pl line 10.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1186878次
    • 积分:38755
    • 等级:
    • 排名:第101名
    • 原创:2823篇
    • 转载:14篇
    • 译文:0篇
    • 评论:46条
    文章分类
    最新评论