Datastage Transform

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
sarat.srinivas@tcs.com
Participant
Posts: 26
Joined: Fri Jul 13, 2007 6:33 am

Datastage Transform

Post by sarat.srinivas@tcs.com »

Hi All,

I want to write a transform to check whether a file exists or not in the given location. So, please help me how can I write the Basic code for checking the existance of a file in a transform.

Thanks in advance.

Regards,
ETL Developer.
V.Sarat Srinivas
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You have specified "Parallel" by wish to write a function [not a transform] in BASIC - that would be for a Server job. Which is it?
The BASIC function would be straightforward, using a DSExecute() call to the UNIX call of your choice to see if the file exists, then parsing the result and returning a true or false to the calling transform stage.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Re: Datastage Transform

Post by sud »

A crude way is to try to open the file and if that fails then something is wrong with it:

Code: Select all

FUNCTION_NAME = "ReadFromFile"

InFile = "/path/to/file/whatafile.txt"

OpenSeq InFile To InputFile
  On Error Call DSLogFatal("Error Opening File ":InFile,FUNCTION_NAME)
Then
  ReadSeq TextLine From InputFile
  ..........
  ..........
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Post by AmeyJoshi14 »

Hi,
One more method! :)
We were facing the same issue ,so inorder to handle this ,we have added an extra column with name(in sequential file(source file)) name as PATHNAME which is having the value of the file along with path.

In the transformer stage variable we checked whether particular file exist with the help of environment varaible(parameter name) if exist then do some transformations else pass the input as it is to output. :!:

Code: Select all

IF
DSLink18.PATHNAME=(parameter name)
THEN
1
ELSE
0
And as suggested by AndrW you can use Before job subrountine to check the whether file is present.There are many ways, one of the method is by using "dsjob -paraminfo" command . :wink:
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

DSWaitForFile() is also useful.
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

How to find the no of Mondays in a week?

Post by swerajan »

HI all

I need a find the no of mondays each month has got using datastage, The month differs and is not a hardcoded one. Please help me out in finding the count
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: Please don't hijack posts. This has nothing to do with the original problem, so please start a new post in the correct forum based on your job type - PX or Server.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply