Page 1 of 1

Equate Function in Routine

Posted: Wed Jul 21, 2004 12:58 am
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

Posted: Wed Jul 21, 2004 5:59 am
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.

Posted: Wed Jul 21, 2004 7:50 pm
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

Posted: Thu Jul 22, 2004 2:38 pm
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.

Posted: Thu Aug 05, 2004 9:55 pm
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.

Posted: Thu Aug 05, 2004 10:06 pm
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)

Posted: Thu Aug 05, 2004 11:59 pm
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?

Posted: Fri Aug 06, 2004 1:08 am
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

Posted: Fri Aug 06, 2004 1:22 am
by Christina Lim
This is exactly what I am looking for.

Thank you very much Klaus.