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.
Datastage Transform
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 26
- Joined: Fri Jul 13, 2007 6:33 am
Datastage Transform
V.Sarat Srinivas
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.
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.
Re: Datastage Transform
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.
-
- Participant
- Posts: 334
- Joined: Fri Dec 01, 2006 5:17 am
- Location: Texas
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.
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 :wink:](./images/smilies/icon_wink.gif)
One more method!
![Smile :)](./images/smilies/icon_smile.gif)
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.
![Exclamation :!:](./images/smilies/icon_exclaim.gif)
Code: Select all
IF
DSLink18.PATHNAME=(parameter name)
THEN
1
ELSE
0
![Wink :wink:](./images/smilies/icon_wink.gif)
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)
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)
How to find the no of Mondays in a week?
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
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