Environement variable in PX transform

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
MAT
Participant
Posts: 65
Joined: Wed Mar 05, 2003 8:44 am
Location: Montréal, Canada

Environement variable in PX transform

Post by MAT »

Hi,

I would like to use an environment variable in a transformer stage within a PX job. The function GetEnvironment should handle that operation but it does not work on my system. Has anybody tried something similar?

Thanks

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

Post by ray.wurlod »

Have you tried creating a job parameter and using that?
On the parameters grid there is a command button for loading an environment variable for the job parameter. The convention is that the environment variable name is preceded by a "$".

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
bigpoppa
Participant
Posts: 190
Joined: Fri Feb 28, 2003 11:39 am

Post by bigpoppa »

OSH or PX GUI?

I'm pretty sure it is possible to do what you want in PX, but I don't remember how. For the time being, you can cheat by going into the OSH Script and using regular sh commands to access env vars.

- BP
MAT
Participant
Posts: 65
Joined: Wed Mar 05, 2003 8:44 am
Location: Montréal, Canada

Post by MAT »

Hi,

I can use a job parameter without difficulty. I think the problem must come from the conversion string to decimal. the data I am using is numeric and a env variable being a string, I need to convert it to decimal. I use the function StringToDecimal(%string%,[%rtype%]). I put my string in but I am not sure what is the optional param rtype??? If I ignore it (Ex: StringToDecimal($SurKey) )I get the error message: Expected expression when compiling. Do you know what goes in rtype or if anything else might be wrong with what I do.

Thanks

MAT
bigpoppa
Participant
Posts: 190
Joined: Fri Feb 28, 2003 11:39 am

Post by bigpoppa »

MAT,

The rtypes are listed in the documentation. I don't remember what rtype values are, but one might be 'roundzero' or 'trunc'. I *think* rtype is an ENUM that stands for the type of rounding value.

It seems like you should be able to be able to use the func w/o the rtype though. To see if buggy code is being generated for your transform, you can always look at the generated transform code. I think the code is in the RT_SC** directory for your job, and it's named something like TransformerXXX.trx.

If you think there is a problem, definitely track it with ASCL. I thought that I had encountered a similar bug a while ago and that it had already been fixed.
MAT
Participant
Posts: 65
Joined: Wed Mar 05, 2003 8:44 am
Location: Montréal, Canada

Post by MAT »

Hi all,

If anyone is interested in the rtypes used in various PX functions, here they are:

Rtype. The rtype argument is a string, and should contain one of the following:
* ceil. Round the source field toward positive infinity. E.g, 1.4 -> 2, -
1.6 -> -1.
* floor. Round the source field toward negative infinity. E.g, 1.6 -> 1,
-1.4 -> -2.
* round_inf. Round or truncate the source field toward the nearest
representable value, breaking ties by rounding positive values
toward positive infinity and negative values toward negative
infinity. E.g, 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2.
* trunc_zero. Discard any fractional digits to the right of the rightmost
fractional digit supported in the destination, regardless of
sign. For example, if the destination is an integer, all fractional
digits are truncated. If the destination is another decimal with a
smaller scale, round or truncate to the scale size of the destination
decimal. E.g, 1.6 -> 1, -1.6 -> -1.
The default is trunc_zero.
Date, Time, and Timestamp functions that take a format string (e.g., timetostring(
time, stringformat)) need specific formats:
For a date, the format components are:
%dd two digit day
%mm two digit month
%yy two digit year (from 1900)
%year_cutoffyy
two digit year from year_cutoff (e.g. %2000yy)
%yyyy four digit year
%ddd three digit day of the year
The default format is %yyyy-%mm-%dd
For a time, the format components are:
%hh two digit hour
%nn two digit minutes
%ss two digit seconds
The default is %hh:%nn:%ss
A timestamp can include the components for date and time above. The
default format is %yyyy-%mm-%dd %hh:%nn:%ss.
Post Reply