エラー処理

エラー判定

 $sth = $dbh->prepare('update t12 set num = 1 where num > 0');
 if (!$sth->execute()){
    print $sth->err,"\n";    #=> 7
    print $sth->errstr,"\n"; #=> ERROR:  relation "t12" does not exist
 }

エラーメッセージ表示(PrintError)

 $dbh->{ShowErrorStatement} = 1;
 $dbh->{PrintError} = 1;

例外発生(RaiseError)

 $dbh->{RaiseError} = 1;
 eval {
   $sth->execute(time); # ERR!
 };
 die "ERR: $@\n" if $@;

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2007-03-28 (水) 19:10:30