Page tree
Skip to end of metadata
Go to start of metadata
###################################################################################
#
# AW_StartJob($jobname varchar(64) input, $run_mode varchar(10) intput,$G_LOAD_TYPE varchar(7) input,
#           extractlow date in/out, extracthigh date in/out)
#
# $jobstatus : varchar(12)
# $runstatus : varchar(12)
# $ret : varchar(10)
#

#
# get information about previous run
#
$jobstatus = sql('DWH_DS',  'select Status from AW_JobExecution where
    Name = {$jobname}' );
$jobstatus = nvl($jobstatus, 'none');

#
# get new starting extraction date based on last run
#

if (  (NOT( $run_mode = 'RESET') ) AND (NOT( $load_type = 'FIRST' )))
begin
 # save starting extraction date, in case not found:
 $seed_extractlow = $extractlow;

 $extractlow = NULL;
 if ($jobstatus = 'done')
  # $extractlow is set to ExtractHigh for the last successful run.
  $extractlow_str = sql('DWH_DS', 'select ExtractHigh from AW_JobExecution where
     Name = {$jobname} ');
 if ($jobstatus = 'started')
  # this flow is being restarted, use the start timestamp from the last invocation.
  $extractlow_str = sql('DWH_DS', 'select ExtractLow from AW_JobExecution where
     Name = {$jobname}');
 if ($jobstatus = 'none' or $extractlow_str = NULL)
  $extractlow = $seed_extractlow;
 else
  $extractlow = to_date($extractlow_str, 'YYYY.MM.DD');

end

#
# update information to indicate that job has 'started'
#
if ($jobstatus =  'none')
 # the first invocation. Add a row to AW_JobExecution
 $ret = sql('DWH_DS', 'insert into AW_JobExecution (Name,
  ExtractLow, ExtractHigh, Status) values ({$jobname},  {to_char($extractlow, \'YYYY.MM.DD\')},
        {to_char($extracthigh,\'YYYY.MM.DD\')}, \'started\')'
    );
else
 # restarting a prior execution. Update row in AW_JobExecution
 $ret = sql('DWH_DS', 'update  AW_JobExecution set Status = \'started\',
  ExtractLow = {to_char($extractlow, \'YYYY.MM.DD\')},
  ExtractHigh = {to_char($extracthigh,\'YYYY.MM.DD\')}  where
  Name = {$jobname}');

return ($ret);



  • No labels