Page 1 of 1

getting execute command stage output

Posted: Tue Aug 07, 2012 1:26 pm
by bobbysridhar
Hi,
I have execute command activity stage from which I am getting accountnumbers. How to pass all the accounts in to a user variable using user variable activity.
I tried using Field(Execute_Command_83.$CommandOutput,@FM,1) in the expression of user variable activity.
But it is only giving first account only. How to get all the account numbers which are result of execute command activity stage.

Posted: Tue Aug 07, 2012 4:28 pm
by chulett
First you'd have to explain for us how you want them retrieved from the command output. Do you want to bring them out all at once? In some sort of delimited list? One at a time because you are looping? It would be helpful to know how the list is being generated and what you plan on doing with it so we can steer you in the right direction.

Not a lot of information to go on at the moment, I'm afraid.

Posted: Tue Aug 07, 2012 5:42 pm
by ray.wurlod
The fourth argument of your Field() function is actually specifying the return of only one field. So it's doing exactly what you're asking it to do.

Posted: Tue Aug 07, 2012 8:06 pm
by bobbysridhar
I want to retrieve them all at once.
Pls explain me how to change the argument to retrieve all account numbers.

Posted: Tue Aug 07, 2012 9:24 pm
by chulett
The Field() function is documented. Check the "online" help in the Designer for the discussion of the fourth field that Ray mentioned. You've omitted it so it defaulted.

Posted: Wed Aug 08, 2012 6:32 am
by chulett
I've been wondering... perhaps we don't understand what "all at once" means. You use Field() to get them one at a time, using that with a proper 4th argument would be the same as simply taking $CommandOutput as a string. I'm guessing that's not really what you want. :?

Posted: Wed Aug 08, 2012 7:51 am
by bobbysridhar
Hi,
Business give me a query to get the accountnumbers. the query will be dynamic. I am extracting the query into a file using a parllel job. That file contains the accountnumbers.
I am using execute command stage to extract those accountnumbers from file. I need to pass these accountnumbers to a parameter value in sequence job to run the subsequent jobs.
which function I need to use to get all these accountnumbers in a uservariable activity stage.
please help me.

Posted: Wed Aug 08, 2012 10:33 am
by chulett
Still not enough information.

What format are they listed in your file? What format do you need them in the parameter? You are making us guess, which is never good. Here's mine!

You have them in a file like this:

111111
222222
333333

And you need them in the parameter like this:

111111,222222,333333

Am I close? If so you don't need Field(), you need to Convert() all @FM to commas. If not, specifics please.

Posted: Wed Aug 08, 2012 11:07 am
by bobbysridhar
I need it the way you specified.
Can you more elaborate the convert function.

Posted: Wed Aug 08, 2012 11:17 am
by chulett
Can you not look up the syntax? Off the top of my head, it would be:

Convert(YourField,@FM,",")

But the arguments might be in the wrong order.

Posted: Wed Aug 08, 2012 3:02 pm
by ray.wurlod
Craig's syntax is correct. I usually do that in a user variable, which means that I have a delimited list to pass to the StartLoop activity.

Note that the final line terminator will mean that you have an empty line at the end. You may like to adjust for this either in the command itself (for example pipe through grep -v to remove lines that begin with CRLF) or in the user variable activity (for example using Left() function).

Posted: Wed Aug 08, 2012 4:33 pm
by Kryt0n
If these account numbers are to be used in a job, I presume to filter a table, could you not simply use the file in the job and join to the table? Or is the table too large compared to the expected account number list? If so, then as you were...

Posted: Sat Sep 01, 2012 12:43 pm
by bhasds
Hi bobbysridhar,

The below command in execute command activity can give you the output.
Then you can pass the command output to the start loop activity(space as delimiter) and to the job

Command-

Code: Select all

cat  filename|xargs| tr -d '\n'
Please correct me if I am wrong.

Re: getting execute command stage output

Posted: Thu Dec 10, 2015 10:44 am
by ep_datastage
Thanks for your help. Figured it out and it works as I was hoping/expecting.

Thanks again