Sorry By mistake i posted into wrong forum. hence i am posting it again
-----------------------------------------------------------------------------------
Is it possible to create files dynamically based on the some input column value. For example
suppose the the input consist of two columns country_cd and city_cd.
and the input stores the information abt 5 distinct country and their respective city as follow
Country_cd city_cd
===========================
cntry1 city1
cntry1 city2
cntry2 city2
cntry2 city3
cntry3 city4
cntry4 city5
cntry5 city5
what i require here is one seperate file should be created for each county and respective country records should go to the corresponding file.
like the file cntry1.txt should have folllowing records:
Country_cd city_cd
===========================
cntry1 city1
cntry1 city2
Pease let me know if this is possible to do in parallel jobs.
Create Dynamic file
Moderators: chulett, rschirm, roy
Create Dynamic file
Birendra
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 33
- Joined: Sat Jul 02, 2005 2:27 am
- Location: Bangalore
Hi,
This can be done using a DataStage job and a script which can be called as an after job routine.
Steps:
1. Create a column Srrgt_Dist_Ctry_Cd. This value should be same for the country and should increment for the next country. Hence, use a transformer to create the below output:
Country_cd city_cd Srrgt_Dist_Ctry_Cd
===========================
cntry1 city1 1
cntry1 city2 1
cntry2 city2 2
cntry2 city3 2
cntry3 city4 3
cntry4 city5 4
cntry5 city5 5
2. Write a script and read the Srrgt_Dist_Ctry_Cd in the last line of the file to know the number of distinct records.
3. Read the column values into variables in the script and use a for loop to achieve what you desire.
CAUTION: The script would take long if the number of records are high.
This can be done using a DataStage job and a script which can be called as an after job routine.
Steps:
1. Create a column Srrgt_Dist_Ctry_Cd. This value should be same for the country and should increment for the next country. Hence, use a transformer to create the below output:
Country_cd city_cd Srrgt_Dist_Ctry_Cd
===========================
cntry1 city1 1
cntry1 city2 1
cntry2 city2 2
cntry2 city3 2
cntry3 city4 3
cntry4 city5 4
cntry5 city5 5
2. Write a script and read the Srrgt_Dist_Ctry_Cd in the last line of the file to know the number of distinct records.
3. Read the column values into variables in the script and use a for loop to achieve what you desire.
CAUTION: The script would take long if the number of records are high.
warm regards,
Ajith GK
Ajith GK
-
- Premium Member
- Posts: 644
- Joined: Sat Aug 26, 2006 3:59 pm
- Location: Mclean, VA
Here is the screenshot.bkumar103 wrote:But there is two problem:
1. The no of country code is not constant. Next day there might be 6 distinct country code.
2. The country_cd is not known. I am expaecting the file should be created with the coutryname.txt
![Image](http://img258.imageshack.us/img258/6280/transds4.jpg)
In the Transformer, declare 2 stage variables called
Code: Select all
If (PrecountryCd<> countryCd) Then 'N' Else 'Y' : Var1
Country_Cd : Precountrycd
Specify all file names as parameters. When run for the first time, the output file contains the following records.
Code: Select all
cntry1 city1 1
cntry1 city2 1
Code: Select all
cntry2 city2 2
cntry2 city3 2
cntry3 city4 3
cntry4 city5 4
cntry5 city5 5
Attitude is everything....
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: