Page 1 of 2
Send email while rejecting Records
Posted: Sat Mar 16, 2013 2:57 pm
by hargun
Hi,
i have a sequential file and i am inserting the records to the Target DB2 table and also have a reject link to throw out the rejected records.
I need an email when the records get rejected.How do i can do this in Datastage?
Posted: Sat Mar 16, 2013 3:47 pm
by chulett
After the job completes, you check the row count down the link or the size of the file and send an email if it has been written to. A Sequence job is probably best to control this but it could be done via an After Job routine or batch file.
Posted: Sun Mar 17, 2013 2:48 am
by prasson_ibm
You can write a server routine to count the rows in reject link.
Design a sequence job like first your main job activity runs then e-mail notification activity stage.call a routine in job activity with custom condition option.
Posted: Sun Mar 17, 2013 7:54 am
by chulett
Just want to emphasize there's no "while rejecting records" part to this but doing so afterwards is common and straight-forward.
Posted: Sun Mar 17, 2013 4:33 pm
by ray.wurlod
Actually you can do it while rejecting records, but do you really want to send a separate email for each record rejected? The recipient(s) will quickly begin to hate you if you do. Therefore I'll not be explaining the technique.
Posted: Sun Mar 17, 2013 5:20 pm
by hargun
thanks Ray for your response
yes each time mail should be send to the recipient .
Posted: Sun Mar 17, 2013 5:49 pm
by chulett
Seriously? So if 200 records were rejected you'd like to send 200
separate emails?
Now you've got me curious. Since I would never implement any such thing, perhaps Ray can share with us the mailbomb technique? From a purely informational / educational standpoint, of course!
Posted: Sun Mar 17, 2013 6:33 pm
by hargun
Chullet,
Everytime job run and on each run if records rejected then email needs to be send one time for every run not for each individual rejectes records.
Posted: Sun Mar 17, 2013 7:16 pm
by ray.wurlod
That's a kinder approach.
The suggestions given earlier are appropriate - either a Routine activity in the controlling sequence to get the link row count on the reject-handling link followed by a Notification activity to send the email, or an after-job subroutine to do the same.
The mailbomb technique is a BASIC Transformer stage fed by the reject-handling link, with a call to a routine that invokes DSSendMail().
Posted: Sun Mar 17, 2013 11:11 pm
by chulett
I figured we were having a communication issue and you already had the solution you needed.
Thanks Ray... simple enough.
Posted: Sun Mar 17, 2013 11:59 pm
by ray.wurlod
I thought you might have worked "Spamalot" into the thread somewhere there, Craig.
Especially as it's playing in Denver (Buell Theater) next week.
http://www.denvercenter.org/buy-tickets ... about.aspx
Posted: Mon Mar 18, 2013 12:10 am
by chulett
Yes indeed, it is! I really should go.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Mon Mar 18, 2013 6:06 am
by venkateshrupineni
use the below procedure,
jobactivity -> Execute condition -> UV Activity -> neted condition -> notification mail
Execute condition:-
cd reject file path;cat reject file|wc -l (if u r not passing metadat)
UV activity > if nested condition.commnad o/p > 0 then 1 else 0
nested condition -> UV.activity = 1
then link to notification activity it will drop an e-mail.
oterwise u can directly hadle it in uv activity level by using routine DSSendmailwithsubject
Thanks,
Posted: Mon Mar 18, 2013 1:41 pm
by rameshrr3
I do use a "spam generator" email job to send info messages to each office ( with a contact 'email list' thats vertically pivoted list of comma seperated email ids) if their records had a lookup failure - and I use exactly Ray's approach , but its a server job.
For a pure parallel approach , Im curious if an Unix Wrap stage ( Or External Filter ?? ) that calls mailx on a 'per row basis' can be made to work .
Posted: Mon Mar 18, 2013 3:10 pm
by rameshrr3
Im now thinking , the fact that an Unix Wrapped stage requires the command to be 'pipe-safe' precludes any usage of it on a per row mode.