eval 捕获错误

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.

阅读更多
个人分类: perl 大骆驼培训
上一篇一、ThinkPHP的介绍
下一篇eval 捕获dbi错误
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭