Determining Update or Insert New

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
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

Determining Update or Insert New

Post by asitagrawal »

Hi,

My targt table has 2 fields:
CREATED_EW_DTTM and LASTUPD_EW_DTTM.

Now, I am using 'Update Existing or Insert New' action for writing to this table.

So, my aim is:
If the row is new then I ll assign CREATED_EW_DTTM = DSJobStartTimestamp and LASTUPD_EW_DTTM = DSJobStartTimestamp.
Else if it is just an update then the CREATED_EW_DTTM shud remain the same and the LASTUPD_EW_DTTM shud be DSJobStartTimestamp.

My strategy is like this:

Before writing to the table, I shud do a reference lookup to determin what will be nature of the row (by suing DSLikkn.NOTFOUND etc.) or Use some Hashfile.

Is this the only way or there is some other way to determine the action being new or update??
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Not really. You have to determine which is new in the job and then insert else update. These 2 need to be 2 different links.
Mamu Kim
dannyna
Participant
Posts: 7
Joined: Fri Jun 10, 2005 12:15 am

Re: Determining Update or Insert New

Post by dannyna »

Well, this can be handled also by using DB constraints, means update the table key else insert the row.
But I recomend to use your strategy for perfomane reasons.

Danny

My targt table has 2 fields:
CREATED_EW_DTTM and LASTUPD_EW_DTTM.

Now, I am using 'Update Existing or Insert New' action for writing to this table.

So, my aim is:
If the row is new then I ll assign CREATED_EW_DTTM = DSJobStartTimestamp and LASTUPD_EW_DTTM = DSJobStartTimestamp.
Else if it is just an update then the CREATED_EW_DTTM shud remain the same and the LASTUPD_EW_DTTM shud be DSJobStartTimestamp.

My strategy is like this:

Before writing to the table, I shud do a reference lookup to determin what will be nature of the row (by suing DSLikkn.NOTFOUND etc.) or Use some Hashfile.

Is this the only way or there is some other way to determine the action being new or update??[/quote]
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

Post by asitagrawal »

kduke wrote:Not really. You have to determine which is new in the job and then insert else update. These 2 need to be 2 different links.
Plz tell me how to determine in the job itself whether the row is new or existing one?
jdulaney
Charter Member
Charter Member
Posts: 13
Joined: Thu Feb 02, 2006 1:32 pm

Post by jdulaney »

asitagrawal wrote:
kduke wrote:Not really. You have to determine which is new in the job and then insert else update. These 2 need to be 2 different links.
From the column names, it looks like you are using PeopleSoft 8.9 tables. If you use the DRS, you do not need to determine whether this is an update or a new row. You can choose "update or insert" or "insert or update" and the DRS will handle it for you. Look at any existing job to see how this is handled.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perform a lookup against the target table. If the row exists it's an update; if the row does not exist it's an insert. You may find it more efficient to perform the lookup against a hashed file containing the keys from the target table.
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