looping for each record

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

looping for each record

Post by karthikraju »

i need to perform a for loop logic for each of my input record. can i write this logic in a procedure and call it.

please let me know what is the best option.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You may want to look into the option of Loops in Job Sequence. If you choose that path, you can check the posts discussed on the same.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

But i need to perform the loop operation for each record.
if i am right,in job sequence i can only run the entire job in loops.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can write a stored procedure, yes, you can even write a C function. What exactly do you want to do?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

I want to know will there a hit on performance if i am using a store procedure.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

May be there is a way to do in loops, but difficult to say, without getting a complete picture of what you are trying to do.
Can you elaborate please.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

karthikraju wrote:I want to know will there a hit on performance if i am using a store procedure.
Depends upon your input. Keep in mind that the stored procedure will be called for each record. A C routine will be faster.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

i need to implement the following logic in loop


i get a 10 digit value in string format a the input.
i should take each digit places from 1 to 10 and divide them with 2. if my remainder is 0 then i need to store it in a variable and keep adding it up till my loop is finished.
at the end of my loop that value becomes my 11th digit.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A check digit, in other words. Best to do that in C, I would think...
-craig

"You can never have too many knives" -- Logan Nine Fingers
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

Can you please let me know how to compile and link it the job.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What compiler option do you have. If you have aCC, then you can use acc +Z yourfunction.c
That will create the object file. Create a px routine from the manager, give it a name, external function name will be the name of your c function. Give the path of the object file.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

can you let me know where can i check my compiler options.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Depending upon your compiler, you will provide the options. It will be present in APT_COMPILEROPT environment variable.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
karthikraju
Participant
Posts: 24
Joined: Tue Jan 24, 2006 12:40 am

Post by karthikraju »

i got the following options in APT_COMPILEROPT and my compiler is g++.

-O -fPIC -Wno-deprecated -c
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Rather than asking "will it work?" why not try it?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply