Logic for extract generation

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

Logic for extract generation

Post by dr46014 »

I have a table name cust_eqx_acct_dim.I am maintaining a type 2 SCD in the table.The columns in the table are :
CUST_EQX_ACCT_DIM_KEY
EQUIFAX_CUST_ID
CURRENT_ACCOUNT_NBR
EFFECTIVE_END_DATE
LOAD_DATE
CLIENT_ID

When a new record with a new EQUIFAX_CUST_ID is inserted the EFFECTIVE_END_DATE field is set to NULL.If there is some change in existing EQUIFAX_CUST_ID then EFFECTIVE_END_DATE is made the system date for the previous record and the new record gets inserted with EFFECTIVE_END_DATE as NULL.This is the logic i am using for implementing type 2 dimension.I have developed the job for loading cust_eqx_acct_dim.So now my requirement is generating both onetime and weekly extracts for the newly entered customer.Extract is nothing but a flat file containing only two fields EQUIFAX_CUST_ID and CURRENT_ACCOUNT_NBR.Its relatively easier to generate onetime extract selecting those two fields where EFFECTIVE_END_DATE is NULL.But for weekly extracts i mean to say both for inserted nad updated record i need the extracts in every week.I need both records which are new to the Table and which are existing but some field gets change i.e updated recoreds.

Can u please suggest some logic for implementing both the onetime and weekly extract.Suggest me atleast 2-3 methods for achieving it.
kris
Participant
Posts: 160
Joined: Tue Dec 09, 2003 2:45 pm
Location: virginia, usa

Re: Logic for extract generation

Post by kris »

dr46014 wrote: Can u please suggest some logic for implementing both the onetime and weekly extract.Suggest me atleast 2-3 methods for achieving it.
There is no field that would give you week's worth of data as you are not storing any record of when the actual record is being updated.

Easiest way would be to have a date field 'UPDATE_DATE' in the table and you populate it with sysdate whenever you update a record.

That way you can extract using where EFFECTIVE_END_DATE is NULL and UPDATE_DATE>=(SYSDATE-7)

Hope this helps!

Kris~
~Kris
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I would write a trigger that would fire upon every insert and it would go if pk is present, update the EFFECTIVE_END_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 »

DSguru2B wrote:I would write a trigger that would fire upon every insert and it would go if pk is present, update the EFFECTIVE_END_DATE .
can u please explain the concept in detail.that trigger concept..
if i add a new column to the table like update_date..wat it exactly does.will it be populated for aal the records or only updated records.if it is the case i will not be able to get the latest records
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Its a plain and simple concept. It will be trigger for insert that will scan the table for incoming pk. If the pk is found and the EFFECTIVE_END_DATE is NULL then it will update the record and put current timestamp for EFFECTIVE_END_DATE and insert the new record with NULL.
If you are not familiar with triggers I suggest you stick with doing it in Datastage. You asked for 2 or 3 methods of getting this done, hence i suggested a different approach.
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 »

Hi All
Sorry for the late response from my side.I have a little chang in my requirement.I m having a Staging table with the following columns
EQUIFAX_CUST_ID
CURRENT_ACCOUNT_NBR
CLIENT_ID
This staging table is only to load weekly data and the main table is for maintaining type 2 dimension with the following columns
CUST_EQX_ACCT_DIM_KEY
EQUIFAX_CUST_ID
CURRENT_ACCOUNT_NBR
EFFECTIVE_END_DATE
LOAD_DATE
CLIENT_ID
I have the jobs to load the dimension table and staging table with proper logic.But my requirement is i need to keep the records in two flat files for newly inserted record and updated records.
Tell me some approach.I have to use the tables as source and flat files as target.So that i can easily know which records are inserted and which are updated..
Please share some logic with use of stages....It would be better if any one provide me the layout of the job
Thank you all
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

              HashedFile    HashedFile
                 |              ^
                 |              |
                 V              |
new data ---->  Transformer Stage  ---->  DimTable (inserts)
                                   ---->  FlatFile (inserts)
                                   ---->  DimTable (updates)
                                   ---->  FlatFile (updates)
The Hashed File is pre-loaded with an image of the dimension table, but keyed on the natural key rather than the surrogate key. The Transformer stage looks after maintaining that, determining existence, determining change, and issuing inserts and updates. This logic could be split over multiple stages for ease of maintenance.

Inserts are both new records and new versions of existing records.

Updates are both changed records and expired versions of existing records.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

Post by dr46014 »

could not get u
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For just a few cents per day you can read premium posts, and help to pay for DSXchange's bandwidth.

Or is it that you're searching for the mysterious "u" cited often on DSXchange but whose identity remains to be definitively established?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply