![]() |
Collapse All | Expand All | Show Default |
| GenHtmlJobLog
DataStage Job Report Generated 2005-02-15 08:26:49pm |
|  - Job Design   |
|
|---|
|  - Job Information   |
|  - Job Properties (8)  |
| Property | Value |
| Object Type | Server  |
| Short Description | Last Changed: 12-13-2004  |
| Full Description | Job: GenHtmlJobLog
------------------------------------------------------------------------------------- Non-technical description: tbd ------------------------------------------------------------------------------------- Business rules: tbd ------------------------------------------------------------------------------------- Rules for restarting this job: Just rerun. ------------------------------------------------------------------------------------- Parameters: 1. EmailFlag 2. EmailTo 3. JobNameToLog 4. DebugSw ------------------------------------------------------------------------------------- Sources: tbd ------------------------------------------------------------------------------------- Targets: tbd ------------------------------------------------------------------------------------- Modification History: ------------------------------------------------------------------------------------- UserId Date Version Modification Description ------------------------------------------------------------------------------------- kduke 12-13-2004 1 Created job. -------------------------------------------------------------------------------------   |
| Category | EtlStats  |
| Multiple Instance | True  |
| Job Version Number | 40.1.2  |
| Hash File Cache Sharing | False  |
| Job Control | * -----------------------------------------------------------------
* Job: GenHtmlJobLog * ----------------------------------------------------------------- * Description: * Generate Html from a SQL statement. * ------------------------------------------------------------ * Parameters: * 1. EmailFlag * 2. JobNameToLog * 3. EmailTo * 4. DebugSw * ----------------------------------------------------------------- * Created by : 2004-11-29 Kim Duke * Last Modified : 2005-01-05 by Kim. Added check parent logic. * ----------------------------------------------------------------- DEFFUN EmailToRtn(JobCategory) CALLING "DSU.EmailToRtn" * ----------------------------------------------------------------- JobName = "GenHtmlJobLog" Title = 'Generate Html from a Sql statement' Now = oconv(@DATE, "D4-YMD[4,2,2]"):' ':oconv(@TIME, "MTHS") ThisDay = convert('-','',oconv(@DATE, "D4-YMD[4,2,2]")) NotUsed = '' If System(91) = 0 Then Shell = "UNIX" Sep = '/' OtherSep = '\' End Else Shell = "DOS" Sep = '\' OtherSep = '/' End FilePath = '.\' LogoPath = 'OurLogo.jpg' SqlDsn = 'localuv' SqlUser = '' SqlPwd = '' MaxRecs = 100 * DebugSw = @TRUE convert OtherSep to Sep in LogoPath convert OtherSep to Sep in FilePath SqlPath = FilePath:"SqlScripts" DirName = SqlPath open "DS_JOBS" to DsJobs else stop read JobRec from DsJobs, JobNameToLog else Call DSLogWarn(JobNameToLog:" not in DS_JOBS.", "JobControl") goto TheEnd end JobNo = JobRec<5> JobCategory = JobRec<3> FileName = JobNameToLog:'_Log' * ----------------------------------------------------------------- * Build Sql * ----------------------------------------------------------------- SqlStmt = '' SqlStmt< 1> = 'select' SqlStmt< 2> = ' TIMESTAMP,' SqlStmt< 3> = ' SEVERITY,' SqlStmt< 4> = ' FULL.TEXT' SqlStmt< 5> = 'from' SqlStmt< 6> = ' RT_LOG':JobNo SqlStmt< 7> = 'where' SqlStmt< 8> = ' EVAL "@ID" NOT LIKE ':"'//%'" * ----------------------------------------------------------------- * Get only MaxRecs of the last run * ----------------------------------------------------------------- if not(DebugSw) then HashFileName = "RT_LOG":JobNo open HashFileName to RtLog then RtLogId = '//JOB.STARTED.NO' read RtLogStartRec from RtLog, RtLogId else RtLogStartRec = 0 end RtLogId = '//SEQUENCE.NO' read RtLogEndRec from RtLog, RtLogId else RtLogEndRec = 1 end StartId = RtLogStartRec<1,1> EndId = RtLogEndRec<1,1> - 1 if (EndId - StartId) > MaxRecs then SqlStmt<-1> = " AND @ID BETWEEN ":StartId:" AND ":(StartId+10):" " SqlStmt<-1> = " AND @ID BETWEEN ":(EndId-(MaxRecs-11)):" AND ":EndId:" " end else SqlStmt<-1> = " AND @ID >= ":StartId:" " end end else Call DSLogWarn(HashFileName:" is empty.", "JobControl") goto TheEnd end close RtLog end SqlStmt<-1> = 'order by ' SqlStmt<-1> = ' TIMESTAMP' SqlStmt<-1> = ';' * convert char(13):char(10):@VM:@FM:@SVM to " " in SqlStmt SqlStmt = change(SqlStmt, @FM, char(13):char(10)) Call DSLogInfo("SqlStmt: " : SqlStmt, JobName) * ----------------------------------------------------------------- * Setup GenHtmlFromSql, run it, wait for it to finish, and test for success * ----------------------------------------------------------------- hJob1 = DSAttachJob("GenHtmlFromSql.":FileName, DSJ.ERRFATAL) If NOT(hJob1) Then Call DSLogFatal("Job Attach Failed: GenHtmlFromSql", "JobControl") Abort End xEmailTo = EmailTo if EmailTo = '' or index('All,Kim,Ron,Sharon',EmailTo,1)=0 then xEmailTo = EmailToRtn(JobCategory) end ErrCode = DSSetParam(hJob1, "FilePath", FilePath) ErrCode = DSSetParam(hJob1, "LogoPath", LogoPath) ErrCode = DSSetParam(hJob1, "FileName", FileName) ErrCode = DSSetParam(hJob1, "SqlStmt", SqlStmt) ErrCode = DSSetParam(hJob1, "SqlDsn", SqlDsn) ErrCode = DSSetParam(hJob1, "SqlUser", SqlUser) ErrCode = DSSetParam(hJob1, "SqlPwd", SqlPwd) ErrCode = DSSetParam(hJob1, "DebugSw", DebugSw) ErrCode = DSSetParam(hJob1, "EmailFlag", EmailFlag) ErrCode = DSSetParam(hJob1, "EmailTo", xEmailTo) ErrCode = DSSetParam(hJob1, "MsgJobName", JobNameToLog) ErrCode = DSSetParam(hJob1, "EmailHeader", JobNameToLog:' log file') ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL) ErrCode = DSWaitForJob(hJob1) Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then * Fatal Error - No Return Call DSLogFatal("Job Failed: GenSqlFromSql", "JobControl") End * ----------------------------------------------------------------- TheEnd:   |
|  - Parameters (4)  |
| Parameter Name | Prompt | Default Value | Help Text |
| EmailFlag  | EmailFlag  | 1  |   |
| EmailTo  | EmailTo  | xxx  |   |
| JobNameToLog  | JobName to get log from  | GenHtmlFromSqlDriver  |   |
| DebugSw  | DebugSw  | 0  |   |
|  - Stages (0)  |
|  - Source Stages (0)  |
| No stages |
|  - Processing Stages (0)  |
| No stages |
|  - Target Stages (0)  |
| No stages |
|  - Source Stages (0)  |
|  - Processing Stages (0)  |
|  - Target Stages (0)  |