DSRoutine

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

pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

DSRoutine

Post by pradkumar »

Hi

I am having ajob sequence. One of the job activity in the job sequence has a job in the following way:

STPstage--->Sequential File.

So now the sequential file is storing the output of procedure as Error num = 1 or 0. But my sequence is runing irrespective of whether the procedure fails or success.

Now I would like to read the output from the file and check if it is 0 then the next job activity should be triggered else job sequence should get aborted.

How to accomplish this
Pradeep Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: DSRoutine

Post by chulett »

pradkumar wrote:So now the sequential file is storing the output of procedure as Error num = 1 or 0. But my sequence is runing irrespective of whether the procedure fails or success.
Of course - it does not have a clue that a '1' to you means there was a problem. The job ran just fine so the Sequence goes on with life.

You have a couple of options. One would be to add your '1' as a Fatal Error on the Error Codes tab of the SP stage. When one of them is detected, the job aborts.

Or use an Execute Command stage to 'cat' or 'echo' the contents of the file to std out. You can then interrogate $CommandOutput<1> from the stage in a Custom trigger and send it down the proper link based on the value found.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Thanks

Actually the error can be anything and not only 1.

I developed a routine as follows:

$INCLUDE DSINCLUDE JOBCONTROL.H

EQUATE RoutineName TO 'GetErrorNum'
EQUATE filename TO FileName

* Attempt to open the Error file.
OpenSeq filename TO SeqFile Else
Call DSLogFatal("Error opening ":filename,RoutineName)
End

* Attempt to read the named record from the file.
ReadSeq errornum From SeqFile Else
Call DSLogFatal ("Error Retrieving ErrorNum from ":FileName, RoutineName)
End

CloseSeq SeqFile

If errornum = 0 Then
errornum = 0
End

Ans = errornum

In the job sequence:

Success
proc1---->routineactivity-------->job2
|(Fail)
|
Mail


In the trigger apge of routine activity I am mentioning the filename in single quotes.
I am using Return Value conditional = 0 for sucess link
and Failed for other link.

But even though the procedure gets executed I am getting a Failed mail.
Pradeep Kumar
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Did you test the routine individually by passing the 'FileName' to it?

Does it return the right code when tested?

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pradkumar wrote:Actually the error can be anything and not only 1.
Ok, just going on the fact that you said "the sequential file is storing the output of procedure as Error num = 1 or 0".
pradkumar also wrote:I developed a routine as follows:
Would have been simpler to just "type filename" in an Execute Command stage and check the CommandOutput variable. :wink:
pradkumar lastly wrote:But even though the procedure gets executed I am getting a Failed mail.
Then it is not returning a zero... and you need to figure out why. Suggest you add a call (or two) to DSLogInfo and write some fun things into the job's log like your value of errornum just before you pass it back. That and anything else you think might be of use.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

I am unable to get a clear picture of how to implement using Command Activity Stage

Could you give me some more ideas plz
Pradeep Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Since you are on a Windows server, you literally put "type" as the Command and the filename (or the job parameter you are using for the filename) in the Parameters section. That's it.

Then you use the Activity Variable "StageName.$CommandOutput<1>" as the LHS of a custom trigger - and compare that to whatever comes from the command: '0', '1', whatever and branch accordingly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

I am sorry for my mistake. My files ares tored in unix box.

And The procedure returns "0" if success and can return any oracle error number if not sucesss.

Is there anything similar to type(windows) in UNIX.

Is it cat?
Last edited by pradkumar on Wed Dec 20, 2006 10:43 pm, edited 2 times in total.
Pradeep Kumar
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yup.Its cat.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

I am using cat in command and file name in parameter.
I am using in the stage as follows:
Expression type = Custom COnditional
Expression value : Execute_Command_12.$CommandOutput ='0' (for one link)

Execute_Command_12.$CommandOutput<>'0' (for naother link)

Even though my procedure gets executed succesfully, the sequence is passing to fail link.

Moreover when I see my log I am getting the following:
*** No output from command ***

Any suggestions plz?
Pradeep Kumar
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

At the unix level, try running the cat command and see whats present there.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

The ouptut is

0
Pradeep Kumar
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Check for new line character or some other character concatinated along with that.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

I checked it kumar. THere is no such character
Pradeep Kumar
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

In the command activity stage you have to give the fully qualified path of the file.

Code: Select all

cat /Dir1/Dir2/Dir3/myfile.txt
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply