Equate Function in Routine

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
Christina Lim
Participant
Posts: 74
Joined: Tue Sep 30, 2003 4:25 am
Location: Malaysia

Equate Function in Routine

Post by Christina Lim »

Hallo all,
Equate Function is used to Equate the Routine Name to a literal string and others as the first code.
By doing this, I cannot access it from the drop down list of routines in transformer. But once I've removed the EQUATE function, this function appears in the routines list.

Can anyone explain what is the main use of EQUATE function? And what impact will it bring to the codes by having it or excluding it?

Thanz
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Routines only appear in the drop-down list if the Routine has been successfully compiled. You may also need to refresh the Transformer (from the menu, or use Ctrl-R).

Equate is used in two ways, to define a constant or to define a single-line macro. The first two examples define contants.

Code: Select all

Equate PI To 3.141592
Equate TAB To Char(9)  ; * evaluate Char(9) at compile time
Here's an example of a single-line macro, which is replaced by its definition when the routine is compiled.

Code: Select all

Equate NowTimeStamp Lit "Oconv(Date(),'D-YMD[4,2,2]'):' ':Oconv(Time(),'MTS:')"
The difference is the word "Lit" (or, if you enjoy typing, "Literally") in the Equate declaration.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Christina Lim
Participant
Posts: 74
Joined: Tue Sep 30, 2003 4:25 am
Location: Malaysia

Post by Christina Lim »

Hallo Ray,

These routines are successfully compiled. Even though the transformer is refreshed, the routines with the Equate function does not seems to appear in the Routines list.

Is it a good practice to use the EQUATE function to define constants in the arguments and the routine name?

Code: Select all

    Equate RoutineName To 'ConvPosvToNeg'
    Equate num    To number

    If num < 0 Then
    	Ans = NEG(num)
    End Else
      Ans = num
    End
The above code does not appears in the routines list in the transformer. (It has been compiled successfully)

Code: Select all

    If num < 0 Then
    	Ans = NEG(num)
    End Else
      Ans = num
    End
The above code appears in the routines list in the transformer. (It has been compiled successfully)

Can you explain what causes these?

Thanz
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is each routine of type "transform function"? Only transform functions are visible in the DS Routines list.

I'd be a bit concerned, too, that you've overloaded the name of an intrinsic function (Num) in an Equate declaration.

It's better, in my view, to use assignment statements or literal Equate declaration (Equate TheNumber Lit "Arg1") if you're seeking to avoid side effects in your Routine arguments.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Christina Lim
Participant
Posts: 74
Joined: Tue Sep 30, 2003 4:25 am
Location: Malaysia

Post by Christina Lim »

Hallo Ray,

I apologize for the late reply. Appreciate your advise.

Code: Select all

    If num < 0 Then 
       Ans = NEG(num) 
    End Else 
      Ans = num 
    End 
The above code appears in the routines list in the transformer. (It has been compiled successfully)
Changes in routines require the dsjob that calls this routine to be re-compiled. At the same time, it will slows down the performance it the source data is huge.

Since I cannot put logic to user-defined TRANSFORMS, I've created new transform which call routines from the drop down DSRoutines.

If there are any changes to the routines, do I still need to recompile my dsjobs?

Appreciate your clarification on this.
Thank you.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Jobs do not need to be recompiled if Routines change. Routines are stand-alone components, which are compiled separately.

Jobs DO need to be recompiled if Transforms change. Transforms are encapsulated expressions which become part of the in-line job code when used. Transforms are not compiled separately.

Note the difference between a Transform (which is in the Transforms branch of the Repository, and is not compiled separately) and a transform function (which is one kind of Routine, and is stored in the Routines branch of the Repository, and which is compiled separately).

Incidentally, your code has re-invented the Abs() function to return the absolute value of a number.

Code: Select all

Ans=Abs(Number)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Christina Lim
Participant
Posts: 74
Joined: Tue Sep 30, 2003 4:25 am
Location: Malaysia

Post by Christina Lim »

:shock: I've shared the wrong information with peers.

That would mean I'm facing a big problem here.
Is there any commands/ways to know what job calls particular transform?
For example, select from DS_JOBS, etc.
Else I need to trace 1000 datastage jobs to revert the changes.

How do I get the lists of VOC syntax?
Klaus Schaefer
Participant
Posts: 94
Joined: Wed May 08, 2002 8:44 am
Location: Germany
Contact:

Post by Klaus Schaefer »

Usage analysis is doing that for you. Go to the manager. Mark the transform/routine you are looking for. Klick right mouse button and choose "usage analysis". You will receive a the list of jobs using the specific transform/routine.

Klaus
Christina Lim
Participant
Posts: 74
Joined: Tue Sep 30, 2003 4:25 am
Location: Malaysia

Post by Christina Lim »

This is exactly what I am looking for.

Thank you very much Klaus.
Post Reply