Processing each record using a loop

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
Victoria
Participant
Posts: 21
Joined: Mon Nov 12, 2007 1:44 pm

Processing each record using a loop

Post by Victoria »

Hi,

I am using Server edition. I have a database table which I query. Say the query returns 5 records, I need to process each record through a job. I believe I need to use a Loop here. But I do not know how to do that. I am new to DS so if you can just tell me in detail how to proceed.

Thanks in advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Jobs automatically process records 'in a loop' without you having to do anything special. Meaning, each record will go from the first stage to the last stage individually and in order. An obvious simplification but generally correct.

So just build your job and don't worry about any 'loops'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Victoria
Participant
Posts: 21
Joined: Mon Nov 12, 2007 1:44 pm

Post by Victoria »

Hmm, ok.. but I need to feed in the record (just one column) to an Execute Command stage. For instance, I have 3 records with values:
TOM
DICK
HARRY

I need to pass each as parameter to an Execute Command stage. How do I make a parameter equal to the row value?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, let's start over. The Execute Command stage is a Sequence job stage. My post was for Server jobs. It would be best if you fully explained exactly what it is you are trying to accomplish. The more details you give, the more relevant the answer will be.

Looping in a Sequence job is accomplished using (typically) the UserVariables stage to get a delimited list of the values to process and then the Start/End Loop stages to process each value one at a time. The pdf manuals discuss these stages or you can search the forums for, say... "UserVariables" to find other conversations on this topic.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Post by ag_ram »

Victoria wrote:I have a database table which I query. Say the query returns 5 records, I need to process each record through a job. I believe I need to use a Loop here.
I suppose that your requirement is to extract records from a database which individually later to be sent to Execute Command Activity as parameter to that Command.

My suggestion:

1. Create a Server Job which extracts the records from the database then use the UserStatus method to store the input records into user status area.(refer post)

2. Create a Job Sequence with Job Activity and Execute Command Activity and the Looping Activities then configure that with appropriate parameters. (individual record could be Job-parameterised to be sent as Command line parameter to the Command )
Post Reply