在这里,我试图在上一个查询成功执行后依次执行多个查询 我试图将它们放在一起,但它不能满足需要,一旦sth1成功执行就执行sth2,如果sth1失败然后停止sth2,对不起,我仍然是perl的初学者
$dsh= "*****";
$csv_path = "/data/CSV";
$log_path= "/data/LOG";
my (undef,undef,undef,$mday,$mon,$year) = localtime;
$year = $year+1900;
$mon += 1;
if (length($mon) == 1) {$mon = "0$mon";}
if (length($mday) == 1) {$mday = "0$mday";}
my $today = "$mon$mday$year";
$csv_file="1_Missing_contract_type_2_$today.csv";
open (STDOUT, "| tee -ai ${log_path}/data_$today.log");
$dbh = DBI->connect($dsh,$login,$password,{ RaiseError => 1, AutoCommit => 0} ) or die "Database connection not made: $DBI::errstr";
unless($dbh){
warn "Unable to connect to Oracle ($DBI::errstr)\nTests skiped.\n";
print "1..0\n";
exit 0;}
$dbh->do("ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '.,'");
print localtime() ."..........Running..........\n\n";
$sth1 = $dbh->prepare("
create table t1
") or die "Couldn't prepare statement: " . $dbh->errstr;
$sth1->execute() or die "SQL Error: $DBI::errstr\n";
print localtime() ."..........Closed..........\n\n";
print localtime() ."..........Running..........\n\n";
$sth2 = $dbh->prepare("
insert into t1.....
") or die "Couldn't prepare statement: " . $dbh->errstr;
$sth2->execute() or die "SQL Error: $DBI::errstr\n";
print localtime() ."..........Closed..........\n\n";
close STDERR;
$dbh->commit;
$sth2->finish;
$dbh->disconnect;
exit;