getting execute command stage output

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
bobbysridhar
Premium Member
Premium Member
Posts: 41
Joined: Sun Mar 09, 2008 8:12 pm

getting execute command stage output

Post 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.
k.v.sreedhar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bobbysridhar
Premium Member
Premium Member
Posts: 41
Joined: Sun Mar 09, 2008 8:12 pm

Post by bobbysridhar »

I want to retrieve them all at once.
Pls explain me how to change the argument to retrieve all account numbers.
k.v.sreedhar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
bobbysridhar
Premium Member
Premium Member
Posts: 41
Joined: Sun Mar 09, 2008 8:12 pm

Post 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.
k.v.sreedhar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
bobbysridhar
Premium Member
Premium Member
Posts: 41
Joined: Sun Mar 09, 2008 8:12 pm

Post by bobbysridhar »

I need it the way you specified.
Can you more elaborate the convert function.
k.v.sreedhar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post 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...
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post 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.
ep_datastage
Participant
Posts: 24
Joined: Wed Apr 16, 2014 11:11 am
Location: United States

Re: getting execute command stage output

Post by ep_datastage »

Thanks for your help. Figured it out and it works as I was hoping/expecting.

Thanks again
Post Reply