Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 13:56
Show Gist options
  • Select an option

  • Save earnhardt3rd/a0d0a6d39bc7e245da19c81631a3f2f5 to your computer and use it in GitHub Desktop.

Select an option

Save earnhardt3rd/a0d0a6d39bc7e245da19c81631a3f2f5 to your computer and use it in GitHub Desktop.
require 'getopts.pl';
Getopts('m:d:t');
my $MODE = uc($opt_m) || "";
my $DEBUG = $opt_d || 0;
if (defined $opt_t) { my %TEST = &D_USD_SA_POLICY();}
1;
sub D_USD_SA_POLICY {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Web Service SA Policy";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
my @SA_POLICY = &_PDM_EXTRACT("select id,code,description from SA_Policy");
if (scalar(@SA_POLICY) > 0) {
print " Select SA POLICY to extract and add to package\n";
@SA_POLICY = &fromARRAY(@SA_POLICY);
if (scalar(@SA_POLICY) > 0) {
my $saPolicyList="";
for (my $i=0;$i<=scalar(@SA_POLICY)-1 ;$i++) {
my ($saPId,$saPCode,$saPDesc) = split(',',$SA_POLICY[$i]);
if ($saPolicyList eq "") {
$saPolicyList="'$saPId'";
} else {
$saPolicyList.=",'$saPId'";
}
}
my $probTypeInc = &Ask("Do you want to include Problem Types?","Yes","No");
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract -f \"select * from SA_Policy where id in ($saPolicyList)\" >> %data%\n";
if ($probTypeInc eq "Yes") {
print DAFH "pdm_extract -f \"select * from SA_Prob_Type where id in ($saPolicyList)\" >> %data%\n";
}
close(DAFH);
}
} else {
print " ERROR! Unable to continue data build without results from extract!\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment