Error handling inside of a server BASIC routine

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
mchaves
Participant
Posts: 50
Joined: Mon Aug 08, 2005 9:59 pm
Location: Sydney
Contact:

Error handling inside of a server BASIC routine

Post by mchaves »

Hi Folks,
Just want to borrow your brains. Is there a way to handle errors/exception
inside a server routine (DataStage basic)? I have the function below, and it throws a fatal error when the link doesn't exist which make the job abort.

Routine name : GetRowCount

$INCLUDE DSINCLUDE JOBCONTROL.H
hJob = DSAttachJob(JobName, DSJ.ERRFATAL)

RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)

ErrCode = DSDetachJob(hJob)

Ans = RowCount
A bad fishing day is much better than a great day at work
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The second argument of DSAttachJob() specifies error handling. If you use DSJ.ERRNONE you have to handle error conditions yourself.

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

hJob = DSAttachJob(JobName, DSJ.ERRNONE)

CheckName = DSGetJobInfo(hJob, DSJ.JOBNAME)

If CheckName = DSJE.BADHANDLE
Then

    Ans = @NULL
    ErrMsg = "Unable to attach job " : Quote(JobName) : "."
    Call DSLogWarn(ErrMsg, "GetRowCount")

End
Else

   RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
   ErrMsg = ""

   Begin Case

        Case RowCount = DSJE.BADSTAGE
             ErrMsg = "Stage " : Quote(StageName) : " is not a stage in this job."

        Case RowCount = DSJE.BADLINK
             ErrMsg = "Link " : Quote(LinkName) : " is not a link connected to stage " : Quote(StageName) : "."

   End Case

   If ErrMsg = ""
   Then
 
        Ans = RowCount
 
   End
   Else
 
        Ans = @NULL
        Call DSLogWarn(ErrMsg, "GetRowCount")

   End

End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply