Row by row processing in sequence job

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
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Row by row processing in sequence job

Post by sjordery »

Hi All,

please give me solution regarding this.
From the following data I have to send e mail

supplier,flag1,flag2
a,1,0
b,0,1

my reqierment
if flag1=1 then send email to supplier a that the flag1=1
if flag1=0 then send email to supplier a that flag1=0

same for flag2

for this definitely I have to perform sequence job as the email notification is avaliable only in sequence job.
but i have to refer each row from the main job.

please let me know how I will refer each row from the main job in the sequence job.

looking for your valuable suggestions.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Do you need to send individual mails for each record and for each field to supplier or you wish to accumulate the content and send in a single mail. If you wish to accumulate, what is the format that you are expecting?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Hi ,

Actually I want to send two mails for each record(for each supplier).
For example

sname,flag1,flag2
--------------------
a,1,0
b,0,1

============
for these two records I have to send 4 mails to 2 suppliers
like to supplier a I have to send two mails,and to supplier b I have to send two mails mentioning their flag1 and flag 2 values
So for this I have to store these values some where so that the sequence. job can reffer.

The sequence also must run once for each record in the main job which returns above two rows.

So please give the solution fro this.

Another issue is that how to process each record from a job in sequence job because sequence job runs only once for each job nt each record.

so please let me know.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sequence jobs do not process records - they run other jobs or activities, so in general you get the notion of processing records in one out of your head.

However - if you are on a recent 7.5.x version, then you have the UserVariables Activity stage along with the Start Loop and End Loop stages. You could use them to read your flat file into a delimited List Loop so as to repeat a series of steps 'For Each Thing in List' - to quote the stage.

So your loop could execute once for each record and send emails as appropriate. Not saying this is the 'end all' solution, as you'll still need something in place to know each supplier's email address and how to properly build your emails. Perhaps a small server job you call in the loop to look that up and stash it in the job's User Status area?

The devil *is* in the details.

ps. Some people I know would just script the entire process. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

okay I got the idea.
yes I am using the recent 7.5 version.
but my source is not flat file its a relational database.
so please let me know start loop and end loop will work or not in this case.
supplier email id I can get by joing with another table.

I am representing my design idea and an issue related it.

1-1st I will design one job which take the data from the supplier table(Suppliername,flag1,flag2)and put it into a dataset.

2-In a sequence job I ll take the 1st job and connect to a start loop activity to process each record from the data set.

3-This start loop will be connected to another job activity(the job related to this activity will take the single record and extratct the supplier mail by joining).

4-email notification activity will be connected to the 3 rd job activity.

5-after 4 th step end loop activity will be connected.


but problem here is that where I will store the value of the flag and supplier name,mail id so that email notificationn activity will catch those values and send mail.

can I use user variable for this,but user variable activity is only supporting to some system variables only.

please suggest me
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I doubt you'll be able to use the Notification Activity stage, doesn't seem like it will support your needs. Consider writing a custom routine where you can pass in the pertinent details and leverage either DSSendMail directly or DSExecute your operating system's mailx command.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Actually, picking up from Craig's suggestion, write a Basic routine which sends mail using DSSendMail() and consider doing this in a server job. If you are sending two emails per record, I am guessing you dont have huge amount of data, yes ???
Simply do this in a server job.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

okay

yes I have few records in the table.
My requirement is to develop the job using parallel extender nt server.
If I have to use dssend mail routine activity for this please be specific that what the routine will do in this case.

please suggest.....
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

For sending mail, you need to either choose JobSequence or Basic Routine, where both run in Sequential mode (not in parallel mode).
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

okay

I think I have to build one routine n I have to place this in after job sub routine stage.
Can you explain in diferent steps what the routine will do in this scenario.

Please reply
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

After job subroutine will also be executed only once after the job has finished executing.
As suggested, create a BASIC routine and execute that routine in JobSequence.
Read the file using OpenSeq function and read each row and each field, and use DSSendMail to send mail. You ll get the syntax and details of these commands in BASIC manual.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

okay thanks for your valuable suggestions.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

sjordery wrote:yes I have few records in the table. My requirement is to develop the job using parallel extender not server.
[sigh] Shouldn't you be using the appropriate tool for the job? Don't you have more than one tool in your toolbox? You need to read a teeny number of records and send emails and you are "required" to do this in a PX job? :roll:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Just do it in parallel job huh :?
Any particular reason why? Don't let them tell you how to do your job, just ask them what needs to be done and get it done.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply