Page 1 of 2

Attach DSJ.JOBPID during job

Posted: Wed Mar 07, 2007 2:43 pm
by travissolt
Basically I would like to attach the PID from UNIX into our job so that the Change Data Capture log entries will contain the PID. I have looked at the DSMacro's in the transformer and they do not contain a very robust list of system variables. I have seen similar discussions on-line but no definitive answers (unless I missed them).
Thanks

Posted: Wed Mar 07, 2007 2:51 pm
by DSguru2B
Which PID would you be interested in. The one that initiates your job? When you run a job, you will see several pid's for that one particular job.

Posted: Wed Mar 07, 2007 2:53 pm
by travissolt
The one initiating the job should work.

Posted: Wed Mar 07, 2007 3:44 pm
by ray.wurlod
Capture your PID using echo $$ within a before-job subroutine.

Posted: Wed Mar 07, 2007 4:30 pm
by travissolt
Yeah I figured that if it was not available in the job I would have to grab it out of unix. Thanks

Posted: Wed Mar 07, 2007 4:48 pm
by ray.wurlod
You could employ the Transformer stage function GetEnvironment($$) when intializing a stage variable (for the Transformer stage's process ID) or GetEnvironment($PPID) for the job's process ID.

Posted: Wed Mar 07, 2007 5:09 pm
by travissolt
Cool thanks ill give it a shot

Posted: Thu Mar 08, 2007 11:31 am
by travissolt
Can I pass a variable from an ExecSH into datastage? My plan would be to pass echo $$ into a variable which I could then call within data stage. Is this possible?

Posted: Thu Mar 08, 2007 11:33 am
by DSguru2B
ray.wurlod wrote:You could employ the Transformer stage function GetEnvironment($$) when intializing a stage variable (for the Transformer stage's process ID) or GetEnvironment($PPID) for the job's process ID.
That does'nt work for you :?:

Posted: Thu Mar 08, 2007 11:38 am
by travissolt
I looked up GetEnvironment in the help and this is all it tells me.


The following table lists the functions available in the Utility category (square brackets indicate an argument is optional):

Name
Description
Arguments
Output

GetEnvironment
Return the value of the given environment variable
environment variable (string)
result (string)




I also tried to find it in the transformer and it is not listed in the macros,system variables,functions etc... Without any info on how to use the GEtEnvironment in the help guide I am stumped

Posted: Thu Mar 08, 2007 11:44 am
by travissolt
I went back to the transformer and noticed that the stage variable selection is grayed out so maybe I do not have access to use that item. Or perhaps I need to set one up prior to it becoming available in the transformer.

Posted: Thu Mar 08, 2007 11:49 am
by travissolt
Slowly but surely im catching on. I see i can set a system variable in the transformer properties.

Posted: Thu Mar 08, 2007 11:50 am
by DSguru2B
Right click ont he greyed area and define a stage variable. WHen you do, open the window , right click, go to functions, its under utility. Pass $$ as parameter to GetEnvironment().

Posted: Thu Mar 08, 2007 11:57 am
by travissolt
I tried to right click on the stage variable and it would not work. I can set one up in the transformer properties where it asks for NAME...INITIAL VALUE...SQLTYPE...EXTENDED...Precision...SCALE...DESCRIPTION once defined there the system variable option becomes ungrayed and I can use the variable I set up. I do not see the UTILITY option although I found it in the help section.

Posted: Thu Mar 08, 2007 12:01 pm
by DSguru2B
Yes, where you see NAME...Initial Value bla bla bla, specify a name, give an initial value of 0 specify it as integer. Hit ok. Then in the transformer you will see your stage variable on the right hand side on the top. If you dont see it, click the fourth icon from the right. That icon, present at the top, hides and shows stage variables. Inside the derivation of the stage variable you will have to right click and go to functions, extent Utility and click on GetEnvironment(). THats the only option under Utility.