DSGetLinkInfo Problem/Confusion

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

palmeal,

I think you are close. You just neglected the DSAttachJob call.

If you code along the lines:

Code: Select all

LJobName = 'MyJob'
LStageName = 'MyStage'
LLinkName = 'MyLink'

   JobHandle = DSAttachJob(LJobName,DSJ.ERRFATAL)
   IF NOT(JobHandle) OR JobHandle=DSJE.BADHANDLE THEN CALL DSLogFatal('Bad attach to job "':LJobName:'".','MyFunction')
   Ans  = DSGetLinkInfo(JobHandle,LStageName,LLinkName,DSJ.LINKROWCOUNT)
   IF (Ans<0)
   THEN
      CALL DSLogWarn('Unable to retrieve rows through link "':LLinkName:'" in stage "':LStageName:'" for Job "':LJobName:'".',ProgramName)
      Ans = 0
   END ;** of if-then something went wrong
   Dummy = DSDetachJob(JobHandle) ;** close up the job
palmeal
Participant
Posts: 122
Joined: Thu Oct 14, 2004 7:56 am
Location: Edinburgh, Scotland

Post by palmeal »

Thanks Arnd

This is where I think I went wrong earlier on today when my Job Sequence wouldn't die.
My Job Sequence was running (called job_seq1) and I tried to do a DSAttachJob("job_seq1"). Obviously that was wrong as discussed earlier.

Should the Job Name in the DSAttachJob be the underlying Server Job that I am calling ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The name of the job that you are going to open is that which contains the stage & link that you are trying to get information for. If your function is called as an after-job subroutine then you would use DSJ.ME as the JobHandle.

If you want to avoid the hang and also use multi-instanciation then you can code:

Code: Select all

   MyJobName     = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)
   MyJobInstance = DSGetJobInfo(DSJ.ME,DSJ.JOBINVOCATIONID)
   IF (MyJobInstance) THEN MyJobName := '.':MyJobInstance ;** make a full jobname if a multi-instance call
   IF (MyJobName=LJobName) THEN Ans = DSJ.ME ;** return the DSJ.ME mnemonic code to the caller
   ELSE
      Ans = DSAttachJob(LJobName,LErrorMode)
   END ;** of if-then-else trying to open own job
to work around the potential problem of hanging while trying to attach to yourself.
palmeal
Participant
Posts: 122
Joined: Thu Oct 14, 2004 7:56 am
Location: Edinburgh, Scotland

Post by palmeal »

Thanks again Arnd - I'll give this a try and see how I get on - won't be able to feedback until Tuesday though.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Good luck to you up in the far northern part of the island.
palmeal
Participant
Posts: 122
Joined: Thu Oct 14, 2004 7:56 am
Location: Edinburgh, Scotland

Post by palmeal »

Couldn't get this to work unfortunately - despite being able to return the job name, short/long description, stageName and LinkName the rowcount returned was always 0. Have given up just now and just gone for a 'wc -l' and an awk statement.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Palmeal,

Craig caught it and I missed it! You cannot get the link count information from Sequences, only from Jobs.

-Arnd.
Post Reply