Page 2 of 3

Posted: Wed Jun 29, 2011 4:17 am
by ray.wurlod
Probably. Try it and let us know. You might also like to time the two approaches with the same set of data. (You may be surprised.)

Posted: Wed Jun 29, 2011 4:37 am
by pandeesh
In the case of hash file, i have used GetHashValueByKey() in user variabl activity stage.
but is there any functions or routines available for reading the value from sequential file?

Thanks

Posted: Wed Jun 29, 2011 7:30 am
by chulett
'cat' is one simple way. (Windows equivalent would be 'type')

Posted: Wed Jun 29, 2011 11:40 am
by pandeesh
chulett wrote:'cat' is one simple way. (Windows equivalent would be 'type')
Is it possible to use cat or type in user variable activity stage?

i need to pass the result of cat or type as parameter to SKG stage.

is it possible using ExecSh?
thanks!

Posted: Wed Jun 29, 2011 1:17 pm
by chulett
Yes.

Posted: Wed Jun 29, 2011 6:32 pm
by pandeesh
Craig,

if i give 'type filename' in user variable activity stage,it gives syntax error.(i have tested in datastage 7.5.x installed in windows)

Thanks

Posted: Wed Jun 29, 2011 8:11 pm
by chulett
It's a "shell" command, you can't just type it there and expect it to work. So that means using ExecSH in a routine and then using that routine in the UVA stage which will capture the output of the command when you pass it back out.

Posted: Wed Jun 29, 2011 8:47 pm
by ray.wurlod
Without writing a routine you can't execute shell commands directly from a User Variables activity. Use an upstream Execute Command activity.

Posted: Thu Jun 30, 2011 2:09 am
by pandeesh
Actually i have tried with sequential file in stead of hash file.

i have created a sequential file with initial value of 1.

In the sequence i have placed a routine activity stage befor user variable activity stage,

In that routine activity stage i have called ExecSh and passed 'cat filename' as input argument.

In the user variable activity stage i have used 'routine.$ReturnValue as user variable.

While executing , the output SK are starting form 0.

But i am expecting from 1.

In the log ,i am able to see:

Code: Select all

CopyOfskg_seq..JobControl (ExecSH): Executed command: cat /work/crm/tem
*** Output from command was: ***
1

What i feel is $? value for that cat command is passed to the User variable and then thats passed as the key for SKG stage.

In stead of $? value,how to pass the actual result of cat command?

Thanks

Posted: Thu Jun 30, 2011 2:51 am
by ray.wurlod
You're not stripping the mapped newline from the command output. Search DSXchange for examples of how to do so.

Posted: Thu Jun 30, 2011 4:21 am
by pandeesh
Hi Ray,

I have tried like rtn.Returnvalue[1] in the user variable stage.
But still it's starting from 0.

Thanks

Posted: Thu Jun 30, 2011 7:17 am
by chulett
Angle brackets, not square brackets.

Posted: Thu Jun 30, 2011 9:26 am
by chulett
pandeesh wrote:I have tried rtn.<$ReturnValue> .But it gives "Expected Expression".
I'm curious why in the world you would have tried that? All I meant was for you to replace one set of brackets for another, not completely change the expression. :?

What happens when you try rtn.$Returnvalue<1> there?

Making some assumptions here, one is that "rtn" is the name of the Routine Activity stage in question and that you accidentally left off the $ in your first example. I have no idea what "below symbol" you found in your googling as all I see are two boxes, doesn't really matter though as you are correct in that I meant use <> rather than [] for the array element notation.

Posted: Thu Jun 30, 2011 9:56 am
by pandeesh
sorry craig!!

For rtn.$ReturnValue<1> only i have got Expected Expression

Posted: Thu Jun 30, 2011 4:40 pm
by ray.wurlod
Show us your routine code. In particular, what value are you putting into the Ans variable?

But why are you using a Routine activity at all? Surely an Execute Command activity would be more appropriate?