eMail attached file if record count is greater than zero

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jandersen
Premium Member
Premium Member
Posts: 8
Joined: Wed Feb 18, 2004 3:45 pm

eMail attached file if record count is greater than zero

Post by jandersen »

I would like to email a file attachment only if the number of rows is greater than zero.

If someone has done this with Version 7 I would greatly appreciate to know how.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

As per me, You will have to write a routine where you count the number of records in the file first( one way would be using DSGetLinkInfo and calculate the number of records passing through the link into the sequential file) and then if it is greater than zero call DSSendmail routine in that routine and attach the file. Then you can use this routine in a JobSequence.
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or just conditionally link to the Notification Activity stage from there based on the routine's return code.
-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 »

Welcome Aboard 8)

As Kris mentioned, you will need to write a Basic routine to handle this.
Look into your BASIC guide and search for the STATUS command. Your concern will be the 6th field in the dynamic array that the STATUS command returns. Something like

Code: Select all

OPENSEQ Arg1 TO myfile
      ELSE CALL DSLogWarn("Error opening file ":Arg1)
STATUS mystat FROM myfile THEN
Ans =  mystat<6,1,1>
CLOSESEQ myfile
where Arg1 = fully qualified path to your file
It will return you the file size. If it is non zero, then let the flow go to the notification activity with the attachment of the file.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

DSguru2B wrote:Welcome Aboard 8)
:?
It's been a while jandersen is on board :wink:
Kris

Where's the "Any" key?-Homer Simpson
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Welcome as in "Congrats in gathering up the courage and posting your very first message". :P
And o yea one more thing, "I saved a bunch of money by switching to geico" :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

jandersen

Which part do you need help with the email attachment or the getting the row counts?
Mamu Kim
newtier
Premium Member
Premium Member
Posts: 27
Joined: Mon Dec 13, 2004 5:50 pm
Location: St. Louis, MO

Re: eMail attached file if record count is greater than zero

Post by newtier »

jandersen wrote:I would like to email a file attachment only if the number of rows is greater than zero.

If someone has done this with Version 7 I would greatly appreciate to know how.
Look in the Routines (from DS Manager), possibly under the Utility or SDK section. There may be an example there (called something like SendEmail).
Rick H
Senior Consultant
Post Reply