国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Perl > 正文

perl 學習資料整理篇第1/4頁

2020-06-04 20:28:01
字體:
來源:轉載
供稿:網友
NULL值的判斷
$t{type1id} = $$pref{dbh}->selectrow_array("SELECT type1id FROM enq1 WHERE id =
3");
if ( $t{type1id} == 0 ) {
print "Type1id is NULL/n";
}
==>不是數值項的話,這個語句有問題。數值項專用。
if ( length($t{type1id}) == 0 ) {
print "Type1id is NULL/n";
}
==>如果Null的話,這個語句有問題
如果@rec含有NULL的話,下面的操作要出錯誤信息
$t{line1} = join(' ',@rec);

($t{old1},$t{new1p},$t{new1q}) = $self->dbh->selectrow_array("SELECT
type1id,partsid,QTY FROM enq1 WHERE id = $t{enq1_id}");
91==> if ( $t{old1} == 0 ) {
--------------------------------------------------
[error] [client 127.0.0.1] Use of uninitialized value in numeric eq (==) at
./pro/mscenq1.pl line 91, <CONFIG> line 11.,
--------------------------------------------------
如何判斷一個項目的值是否是NULL(未解決)
解決!第一次INSERT時,放一個常數(比如"B")
起源==>
637==> $t{Nu1} = $self->dbh->selectrow_array("select parts_Unit from parts_nu
where id = $t{Nuid1}");
--------------------------------------------------
[Wed May 14 17:27:51 2008] [error] [client 127.0.0.1] DBD::mysql::db
selectrow_array failed: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near
'' at line 1 at ./pro/mscenq1.pl line 637, <CONFIG> line 11., referer:
--------------------------------------------------
要考慮$t{Nuid1}不存在的情況

考慮id=C的情況
591==>
@{ $t{p1} } = $self->dbh->selectrow_array("SELECT * FROM $t{ptable}
WHERE id = $t{pid1}");
--------------------------------------------------
[error] [client 127.0.0.1] DBD::mysql::db selectrow_array failed: Unknown
column 'C' in 'where clause' at ./pro/mscenq1.pl line 591, <CONFIG> line 11.,
referer:
--------------------------------------------------
要考慮$t{pid1}='C'的情況
if ( $#{ $t{pid_list} } == 0 && $t{pid_list}[0] eq 'C' ) {
next;
}
COPY一個項目的subroutine
use strict;
use DBI;
# 連接數據庫
my(%t,$n,@fld,@rec,$pref);
print "This is test3.pl./n";
# 連接數據庫
$$pref{dsn} = "DBI:mysql:host=localhost;database=cookbook";
$$pref{dbh} = DBI->connect($$pref{dsn}, "cbuser", "cbpass") or die "Cannot
connect to server/n";
$$pref{dbh}->do("SET NAMES utf8");
if(!$$pref{dbh}){
print "SQL read ERROR!/n";
exit;
}
$$pref{table} = 'enq2';
$$pref{oldid} = 4;
($pref) = copy_one($pref);
# 關閉數據庫
$$pref{dbh}->disconnect;
# COPY一個項目
sub copy_one {
my($pref) = @_;
my(%t,@rec,$n);

# 取出COLUMNS
$t{sth} = $$pref{dbh}->prepare("SHOW COLUMNS FROM $$pref{table}");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
push(@{ $t{columns} },$rec[0]);
}
$t{sth}->finish;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜平县| 石台县| 南康市| 都江堰市| 嵩明县| 错那县| 怀宁县| 延庆县| 青阳县| 武乡县| 泰宁县| 安图县| 德江县| 浙江省| 乐山市| 齐河县| 航空| 长宁县| 登封市| 卓资县| 澄迈县| 静宁县| 宜川县| 高碑店市| 得荣县| 商都县| 融水| 留坝县| 商丘市| 搜索| 长治市| 洪湖市| 石棉县| 扶绥县| 新田县| 高雄县| 瓮安县| 冕宁县| 进贤县| 奎屯市| 徐州市|