#!perl ################################################################## # getLatestValidSet # ================= # Execute a query to get the latest valid set corresponding to # a given process name. # # Usage : # ------- # # perl getLatestValidSet # # Where : # ------- # # : process name. # : database name. # : database username. # : database password. # # # Person Date Modifications # ---------------------------------------------------------------- # Dave Waters 18.01.2005 Original implementation. # ################################################################## use DBI; use strict; my $debug = 0; my $process_name = $ARGV[0]; if ($debug) {print "process name = $process_name \n";} my $dbname = $ARGV[1]; if ($debug) {print "database name = $dbname \n";} my $user = $ARGV[2]; if ($debug) {print "username = $user \n";} my $password = $ARGV[3]; if ($debug) {print "password = $password \n";} # Connect to the trigger database : my ($dbh) = DBI->connect("dbi:Oracle:$dbname",$user,$password) || die "Error connecting $DBI::errstr\n"; my ($handle); # Fine the existing tag information : ($handle) = $dbh->prepare("SELECT JOBSET FROM VALID_SETS WHERE PROCESS_NAME='${process_name}' ORDER BY JOBSET DESC"); if ($DBI::err){print "$DBI::errstr\n";} $handle->execute(); if ($DBI::err){print "$DBI::errstr\n";} my @all_info; my $row_count=0; while ((@all_info = $handle->fetchrow) && ($row_count == 0)) { my $latestvalidset = ""; if ($all_info[0]) {$latestvalidset = $all_info[0];} $row_count++; print $latestvalidset; } if ($row_count != 1) { print "ERROR from getLatestValidSet : NO LATEST VALIDSET FOUND \n"; } $handle->finish; $dbh->disconnect;