eval 捕获dbi错误
来源:互联网 发布:数据库实例 schema关系 编辑:程序博客网 时间:2024/05/19 20:41
[root@dr-mysql01 ~]# cat t2.pl use DBI;my $dbUser='zabbix';my $user="root";my $passwd="1234567";my $TABLE_NAME='history_uint';my $date='201605';my $dbh = DBI->connect("dbi:mysql:database=zabbix;host=192.168.32.55;port=3306",$user,$passwd,{RaiseError => 1}) or die "can't connect to database ". DBI-errstr;my $hostSql = qq{select TABLE_NAME,PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS where TABLE_NAME='$TABLE_NAME' and PARTITION_NAME like "p$date%";};print "\$hostSql is $hostSql\n";my ($a1, $a2);#if ($a1){my $selStmt = $dbh->prepare($hostSql);$selStmt->execute();$selStmt->bind_columns(undef, \$a1,\$a2);print "\$a1 is $a1\n";print "\$a2 is $a2\n";print $selStmt->fetch();print "\n"; eval {$selStmt->fetch()};print "\$@ is $@\n";;print "\n";[root@dr-mysql01 ~]# perl t2.pl $hostSql is select TABLE_NAME,PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS where TABLE_NAME='history_uint' and PARTITION_NAME like "p201605%";$a1 is $a2 is ARRAY(0x2324778)$@ is [root@dr-mysql01 ~]# cat t2.pl use DBI;my $dbUser='zabbix';my $user="root";my $passwd="1234567";my $TABLE_NAME='history_uint';my $date='201604';my $dbh = DBI->connect("dbi:mysql:database=zabbix;host=192.168.32.55;port=3306",$user,$passwd,{RaiseError => 1}) or die "can't connect to database ". DBI-errstr;my $hostSql = qq{select TABLE_NAME,PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS where TABLE_NAME='$TABLE_NAME' and PARTITION_NAME like "p$date%";};print "\$hostSql is $hostSql\n";my ($a1, $a2);#if ($a1){my $selStmt = $dbh->prepare($hostSql);$selStmt->execute();$selStmt->bind_columns(undef, \$a1,\$a2);print "\$a1 is $a1\n";print "\$a2 is $a2\n";print $selStmt->fetch();print "\n"; eval {$selStmt->fetch()};print "\$@ is $@\n";;print "\n";[root@dr-mysql01 ~]# perl t2.pl $hostSql is select TABLE_NAME,PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS where TABLE_NAME='history_uint' and PARTITION_NAME like "p201604%";$a1 is $a2 is DBD::mysql::st fetch failed: fetch() without execute() at t2.pl line 19.$@ is DBD::mysql::st fetch failed: fetch() without execute() at t2.pl line 19.
1 0
- eval 捕获dbi错误
- eval 捕获错误
- perl的异常处理die、warn、eval函数--DBI的RaiseError
- 捕获CONN错误
- 捕获参数错误异常
- struts2 捕获404错误
- 线程中捕获错误
- VS2008_C++捕获内存错误
- try捕获JS错误
- JQuery AJAX错误捕获
- JavaScript 捕获错误
- mvc中捕获错误
- WPF:捕获导航错误
- Android UncaughtExceptionHandler,捕获错误
- [.net]捕获错误机制
- UncaughtExceptionHandler,捕获错误
- register_shutdown_function捕获致命错误
- Windows PowerShell 捕获错误
- 百度地图zhang
- github常见操作和常见错误!错误提示:fatal: remote origin already exists.
- hdu1272 java 穷举法
- Android源代码编译
- poj 1845 Sumdiv(同余模公式)
- eval 捕获dbi错误
- Windows平台 破解starUML
- formatter
- Android Studio 使用技巧总结
- xUtils3下载图片
- Android标题透明沉浸式UI
- GDAL2.1.0在VS2013下的编译
- 【android】:android文件读写
- java源码分析(6)-StringBuffer