How to store Job start time,end time,job name in Oracle
Moderators: chulett, rschirm, roy
hi craig ,
I gave the valid path as input and also has the access rights.
when i tried to create a file in the routine and tried to open the file in the directory i am getting an error Failed to open the directory, but the File is creating but getting an error, instead if i give directory path and file name as input parameters , it is working fine . i.e the file is already exisited and i am writing the log into file.
thanks in adavance
I gave the valid path as input and also has the access rights.
when i tried to create a file in the routine and tried to open the file in the directory i am getting an error Failed to open the directory, but the File is creating but getting an error, instead if i give directory path and file name as input parameters , it is working fine . i.e the file is already exisited and i am writing the log into file.
thanks in adavance
EtlStats is not an external app. It is a bunch of DataStage jobs and routines. All you need is to make the job DSJobReportDb and change it to output to a sequential file. It is a simple job. It runs dsjob -report XML to get row counts inot an XML file. It extracts 3 things from the XML file. The first is job name, start time and end time. The second is row counts. The third is parameter names and values. Delete the row counts and parameter names.
DSJobReportDbDriver runs the above job over and over for every job in the project if you use 'ALL' for the job name. Import these 2 jobs and the routines they call or rewrite the routines and you are done. DSJobReportDbDriver could easily be rewritten to run dsjob -ljobs.
DSJobReportDbDriver runs the above job over and over for every job in the project if you use 'ALL' for the job name. Import these 2 jobs and the routines they call or rewrite the routines and you are done. DSJobReportDbDriver could easily be rewritten to run dsjob -ljobs.
Mamu Kim
-
- Participant
- Posts: 110
- Joined: Mon Jan 11, 2010 4:22 am
Kiran ,
the code is
you have to input parameters as Diectory path, filename fo eg:
C:\windows,xxx.txt
where C:\windows is the directory path and xxx.txt is the file name
but this one has to have a file ceated before you run the routine
the code is
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
ErrorCode = 0
JobHandle = DSJ.ME
JobName1 = DSGetJobInfo(JobHandle,DSJ.JOBNAME)
JobStarted1 = convert(" :-","_",DSGetJobInfo(JobHandle,DSJ.JOBSTARTTIMESTAMP))
JobEnd1 = convert(" :-","_",DSGetJobInfo(JobHandle,DSJ.JOBLASTTIMESTAMP))
call DSLogInfo("Job Name: ":JobName1,"Job")
call DSLogInfo("Job Start TimeStamp : ":JobStarted1, "Job")
call DSLogInfo("Job End TimeStamp : ":JobEnd1, "Job")
DirName = Field(InputArg,",",1)
DirName2 = Field(InputArg,",",2)
StartTimeStamp = DSGetJobInfo (DSJ.ME, DSJ.JOBSTARTTIMESTAMP)
EndTimeStamp = DSGetJobInfo (DSJ.ME, DSJ.JOBLASTTIMESTAMP)
GetLogSum = DSGetLogSummary(DSJ.ME,DSJ.LOGANY,StartTimeStamp,EndTimeStamp,0)
OPENSEQ DirName:'\':DirName2 TO H.FileName THEN
WRITESEQ GetLogSum to H.FileName else
call DSLogWarn("Failed to write file ":" to directory ":DirName, "GetJobLog")
end
end
else
call DSLogWarn("Failed to open directory ":DirName, "GetJobLog")
end
CLOSESEQ H.FileName
C:\windows,xxx.txt
where C:\windows is the directory path and xxx.txt is the file name
but this one has to have a file ceated before you run the routine
-
- Participant
- Posts: 110
- Joined: Mon Jan 11, 2010 4:22 am
Hi Sunny
Below is the code which wries the log details into .txt file
The input argument is only the directory name.Here no need to create the file before.
Below is the code which wries the log details into .txt file
The input argument is only the directory name.Here no need to create the file before.
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
ErrorCode = 0
DirName = InputArg
Suffix = ".txt"
JobHandle = DSJ.ME
JobName = DSGetJobInfo(JobHandle,DSJ.JOBNAME)
JobStarted = convert(" :-","_",DSGetJobInfo(JobHandle,DSJ.JOBSTARTTIMESTAMP))
JobEnd = convert(" :-","_",DSGetJobInfo(JobHandle,DSJ.JOBLASTTIMESTAMP))
FileName = JobName:"_":JobStarted
FileName := Suffix
call DSLogInfo("Job Name: ":JobName,"Job")
call DSLogInfo("Job Start TimeStamp : ":JobStarted, "Job")
call DSLogInfo("Job End TimeStamp : ":JobEnd, "Job")
StartTimeStamp = DSGetJobInfo (JobHandle, DSJ.JOBSTARTTIMESTAMP)
EndTimeStamp = DSGetJobInfo (JobHandle, DSJ.JOBLASTTIMESTAMP)
GetLogSum = DSGetLogSummary(JobHandle,DSJ.LOGANY,StartTimeStamp,EndTimeStamp,0)
Openpath DirName to t.fvar then
write GetLogSum to t.fvar, FileName else
call DSLogWarn("Failed to write file ":FileName:" to directory ":DirName, "GetJobLog")
end
end
else
call DSLogWarn("Failed to open directory ":DirName, "GetJobLog")
end
close t.fvar
Hi,
Is there anyway that we can use the above code in Sequence job or do we need to use this only in individual job. If i can use it in sequence how can we use it in sequence as there is no option called after job subroutine.
And can anyone tell me if i want to delete the file which is created from the above routine after the job has executed , is there anyway that we can add some code to check if the job has no errors then to delete the file automatically.
Thanks in advance
Is there anyway that we can use the above code in Sequence job or do we need to use this only in individual job. If i can use it in sequence how can we use it in sequence as there is no option called after job subroutine.
And can anyone tell me if i want to delete the file which is created from the above routine after the job has executed , is there anyway that we can add some code to check if the job has no errors then to delete the file automatically.
Thanks in advance