Batch-Batchrun
view release on metacpan or search on metacpan
lib/Batch/Batchrun/Dbfunctions.pm view on Meta::CPAN
# 2. Check to see if the error file has any size to it. If it's size is greater
# than zero then there was an error. If ignore_errors is not true, then fail
# If it is true then exit with a warning.
#----------------------------------------------------------------------------
if ($errors_found)
{
$Batch::Batchrun::Msg = 'BCP Error found in log file!';
return $Batch::Batchrun::ErrorCode;
}
elsif ( -s $error_file and ($ignore_errors !~ /yes|true/i))
{
$Batch::Batchrun::Msg = 'BCP Error found in log file or Error file';
return $Batch::Batchrun::ErrorCode;
}
elsif ( -s $error_file and ($ignore_errors =~ /yes|true/i))
{
$Batch::Batchrun::Msg = 'BCP Error found in log file or Error file';
return $Batch::Batchrun::WarningCode;
}
else
{
return $rc;
}
} ### end command_bcp
#****************************************
sub command_sqr
#****************************************
{
if (not defined($ENV{SQRDIR}))
{
$Batch::Batchrun::Msg = 'SQRDIR environment variable missing! It must be defined.';
return $Batch::Batchrun::ErrorCode;
}
#SQR [program] [username/password] [-flags...] [pars...] [@file...]
#
#where
# program = Report filename
# username = Database username
# password = Database password
# -A = Append to existing output file
# -Bn = Fetch n rows at a time
# -Burst:{xx} = Generate .LIS using specified burst mode (S,T or P)
# -Dn = Display report while processing, pause every n lines
# -DEBUGxx = Compile #DEBUG[x] lines
# -DNT:{xx} = Set the default numeric type (Decimal,Integer,Float)
# -E[file] = Direct errors to {program}.ERR or specified file
# -F[dir/file] = Use [dir]{program}.LIS or specified file for output
# -Idir_list = Directory list to be searched for include files
# -ID = Display copyright banner
# -KEEP = Keep the .SPF file(s) after program run
#-LL{s|d}{c|i} = Load-Lookup: S=SQR, D=DB, C=Case Sensitive, I=Insensitive
# -Mfile = Maximum sizes declared in file
# -NOLIS = Do not generate .LIS file(s) from .SPF file(s)
# -O[file] = Direct log messages to console or specified file
#-PRINTER:{xx} = Force listing files to be for HT, LP, HP or PS printers
# -RS = Save run time file in {program}.sqt
# -RT = Use run time file (skip compile)
# -S = Display cursor status at end of run
# -Tn = Test report for n pages, ignore 'order by's
# -XB = Do not display the program banner
# -XI = Do not allow user interaction during program run
# -XL = Do not logon to database (no SQL in program)
# -XTB = Do not trim blanks from LP .LIS files
# -XNAV = Do not put navigation bar into .HTM file
# -XTOC = Do not generate Table Of Contents
# -ZIF[file] = Complete pathname of the initialization file to use
# -ZMF[file] = Complete pathname of the message file to use
# pars = Report parameters for ASK and INPUT commands
# @file = File containing report parameters, one per line
#***************************************************
# Check for required fields
#*****************************************************
if ( $Batch::Batchrun::Control{$Batch::Batchrun::Counter}{CurrentCommandParm} !~ /program/i and
$Batch::Batchrun::Control{$Batch::Batchrun::Counter}{CurrentCommandParm} !~ /user/i and
$Batch::Batchrun::Control{$Batch::Batchrun::Counter}{CurrentCommandParm} !~ /server/i )
{
$Batch::Batchrun::Msg = 'Missing one or more required parameters for sqr';
return $Batch::Batchrun::ErrorCode;
}
my %tmphash = %{$Batch::Batchrun::Control{'CurrentCommandParm'}};
# Required
my $program = $tmphash{PROGRAM};
my $user = $tmphash{USER};
my $server = $tmphash{SERVER};
# optional
my $password = $tmphash{PASSWORD};
my $log = $tmphash{LOG};
my $errors = $tmphash{ERRORS};
my $output = $tmphash{OUTPUT};
my $flags = $tmphash{FLAGS};
my $parameters = $tmphash{PARAMETERS};
my $parfile = $tmphash{PARFILE};
$log =~ s/^\s*//o;
$errors =~ s/^\s*//o;
$output =~ s/^\s*//o;
$flags =~ s/^\s*//o;
$parameters =~ s/^\s*//o;
$parfile =~ s/^\s*//o;
# Batchrun only options
#my $ignore_errors = $tmphash{IGNORE_ERRORS};
my $show_errors = $tmphash{SHOW_ERRORS};
print "PROGRAM: $program\n";
print "USER: $user\n";
print "SERVER: $server\n";
print "LOG: $log\n";
print "ERRORS: $errors\n";
print "OUTPUT: $output\n";
#****************************************************
# Figure out which program to run
( run in 0.555 second using v1.01-cache-2.11-cpan-39bf76dae61 )