eval 捕获dbi错误
[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.
eval 捕获dbi错误的更多相关文章
- eval 捕获错误
eval 捕获错误: [root@dr-mysql01 ~]# cat t1.pl use DBI; my $dbUser='zabbix'; my $user="root"; m ...
- 捕获JS 错误日志
最近在做项目的过程中,发现很多JS报错没有引起重视,我就想想把JS错误捕获了,然后展示在我们一个平台上 具体实现代码: window.onerror = function(message, url, ...
- C/C++捕获段错误,打印出错的具体位置(精确到哪一行)
修订:2013-02-16 其实还可以使用 glibc 的 backtrace_symbols 函数,把栈帧各返回地址里面的数字地址翻译成符号描述的 修订:2011-06-11 背景知识: · 在li ...
- C/C++捕获段错误,打印出错的具体位置(精确到哪一行)_转
转自:C/C++捕获段错误,打印出错的具体位置(精确到哪一行) 修订:2013-02-16 其实还可以使用 glibc 的 backtrace_symbols 函数,把栈帧各返回地址里面的数字地址翻译 ...
- struts2完全捕获404错误的方法
目前在做一个网络应用程序,struts2 + spring + hibernate,服务器是tomcat.希望用户在IE地址栏乱敲的时候,所敲入的所有未定义的URL都能被程序捕捉到,然后转到一个自制的 ...
- 使用Application_Error捕获站点错误并写日志
Global.ascx页面使用以下方法即可捕获应用层没有try cath的错误 protected void Application_Error(Object sender, EventArgs e) ...
- 利用Backtrace来捕获段错误堆栈信息
具体参考文档:https://blog.csdn.net/gatieme/article/details/84189280 测试Demo: #include <execinfo.h> #i ...
- Travis CI eval ./gradlew assemble 错误
问题 在进行 Travis CI 进行集成编译的时候出现错误. <-------------> 0% WAITINGThe command "eval ./gradlew ass ...
- 使用flow捕获js错误提高代码质量
本文将介绍Flow及其主特性.下面分别从如何安装设置,如何添加类型注释,如何在运行时自动去掉注释等方面来介绍. 安装 目前Flow兼容的操作系统有Mac OS X,Linux(64位),Windows ...
随机推荐
- ZOJ 2967 Colorful Rainbows 【Stack】
解决此题方法类似于凸包,先把所有直线按照斜率a由小到大排序 斜率相同取b较大的,扔掉b小的 (可以在遍历的时候忽视).于是所有直线斜率不同. 准备一个栈 (手动模拟), 栈里面存放上一次能看到的“最上 ...
- 数据结构C语言版 弗洛伊德算法实现
/* 数据结构C语言版 弗洛伊德算法 P191 编译环境:Dev-C++ 4.9.9.2 */ #include <stdio.h>#include <limits.h> # ...
- 带OpenSSL和MySQL的静态编译版本~
http://www.npcglib.org/~stathis/blog/precompiled-qt4-qt5/ http://www.npcglib.org/~stathis/blog/preco ...
- Android 代码设置密码输入框内容的显示/隐藏
//内容可见 mEtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); //内容不可见 m ...
- poj 2356鸽笼原理水题
关于鸽笼原理的知识看我写的另一篇博客 http://blog.csdn.net/u011026968/article/details/11564841 (需要说明的是,我写的代码在有答案时就输出结果了 ...
- hdu2243之AC自动机+矩阵乘法
考研路茫茫——单词情结 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- oracle expdp和impdp使用例子
情景: 由于生产需求,需要把rmtel用户的数据完全复制一份给rmtel_xzy,但排除rmtel用户 ('CAB_JJXPORT_TAB','T_SERVICEXX','TB_CROSSCONNEC ...
- Linux下arp用法
[功能] 管理系统的arp缓存. [描述] 用来管理系统的arp缓存,常用的命令包括: arp: 显示所有的表项. arp -d address: 删除一个arp表项. arp -s addre ...
- @(报错)could not find the main class, Program will exit(已解决)
原文 @(报错)could not find the main class, Program will exit(已解决) (很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以 ...
- Windows Phone 8初学者开发—第22部分:用演示图板创建卷盘的动画
原文 Windows Phone 8初学者开发—第22部分:用演示图板创建卷盘的动画 第22部分: 用演示图板创建卷盘的动画 原文地址:http://channel9.msdn.com/Series/ ...