loading as per date value

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
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

loading as per date value

Post by dr46014 »

hi all
i have got a flat file to load into a table along with date..the flat file has different segments where the date value and its corresponding set of records is given..then another date value and another set of records...how to read such a file..
i m giving the format of file below

generation date:11/11/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
generation date:12/12/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Welcome Aboard :)

A complicated requirement for your first post!
How do you want your output to be.
Can you give a sample of how your output should look like?
We can go ahead from there.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

Post by dr46014 »

thanks for your response..
the output should be a table consisting of 5 columns.3 are the fields given in the flat file.the 4th one is the generation date which is given as the header of rhe block of records and the 5th one is the load date.
plz suggest me an approach to solve it 8)
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Re: loading as per date value

Post by I_Server_Whale »

dr46014 wrote:hi all
i have got a flat file to load into a table along with date..the flat file has different segments where the date value and its corresponding set of records is given..then another date value and another set of records...how to read such a file..
i m giving the format of file below

generation date:11/11/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
generation date:12/12/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
.
Welcome aboard :)

I appreciate the way you framed your question and also the neat & clean sample file.

It is pretty easy to read such a file. Use a sequential file stage, read the incoming record as one field. Make sure that you define the length of this field equal to the maximum length of your incoming record.

Later in your transformation. you can use the field function to retrieve relevant information based on your output requirements.

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
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

As mentioned by Whale, read it as single varchar field, parse it in a transformer. Check for "generation date:" and store the date into a stage variable, and populate this variable in 4th column until you get a records with "generation date:". The 5th can be populated with SYSDATE or Date() in datastage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can do this by reading the entire record as one column and then split it inside the transformer as Whale suggested.
Define a stage variable

Code: Select all

GenDate  |   if in.Link Matches 'generation...' then Field(in.Link,":",2)   
                   else GenDate
Now your columns will be

Code: Select all

Col1 | Field(in.Link,",",1)
Col2 | Field(in.Link,",",2)
Col3 | Field(in.Link,",",3)
Col4 | GenDate
Col5 | DSJobStartDate
Now your first three columns will be null for the line 'Generation Date:...'
So you need to constraint it by putting a second transformer infront of this transformer and specify a constraint

Code: Select all

IsNull(link.Col1) = 0
I think that should work.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

Post by dr46014 »

thaks all you people for your immediate response.i hav a small doubt that how can read the file when i encounter the second generation value...
if u people suggest me code of the field function it will be very helpful

this is a really awesome community....i got the solution within 30mins..
one again thanks to all u people
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

dr46014 wrote:if u people suggest me code of the field function it will be very helpful
Field is an inbuilt function in Datastage.

This forum has a nice search functionality too which you can use to get most of your solutions.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I gave you a complete solution as a welcome. The stage variable will take care of the second, third and so on, all the generation values. Make sure the first line in your file is Generation Date.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

Post by dr46014 »

i got the point..
now i ll implement it..
i i have any further queries i ll ask you people
Post Reply