■PERL-DBI テストスクリプト
use DBI;
$dsn = 'DBI:Oracle:ossdb';
$user = 'chescom';
$password = 'mocsehc';
# サーバー側の今日のシステム日付を取得します
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
$mon++;
$today = sprintf("%02d%02d%02d%02d%02d", $mon, $mday, $hour, $min, $sec); # yyyymmdd
# connect to db --------------------------
$dbh = DBI->connect($dsn, $user, $password,
{ RaiseError => 1, AutoCommit => 0 });
if ( ! $dbh ){
print "rfr(qzqe $dbh->err $dbh->errstr\n";
}
#----------------------------------------------
eval {
# sql
$sth = $dbh->do(
"insert into ganko values('$today','d')"
);
$dbh->commit; # ここまできたらコミットする。
print "コミットしました。$aaa\n";
};
if ($@) {
warn "Transaction aborted because $@";
$dbh->rollback; # undo the incomplete changes
print "ロールバックしました。\n";
}
#---- select ----------------------
my $sth = $dbh->prepare(
"select * from ganko"
);
$sth->execute;
while(@row = $sth->fetchrow_array) {
print "@row\n";
}
#-----------------------------------
$dbh->disconnect;
| 固定リンク
| コメント (0)
| トラックバック (0)
最近のコメント