Updating Records in Table

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
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Updating Records in Table

Post by pradkumar »

Hi

I am having my job as follows:

I/P -->TX(lookup + constraint in TX for INSERT AND UPDATE)-->(NEWKEY GENEARTION(for insert new rows) --> Target table

I am adding a flag in TX SAYING THAT IT IS NEW OR NOT (using "Y" for NEW and "Y" for OLD). Initially I gave "Y" for flag and inserted all records in target table.

My question is if Flag = "N", then it is an old record and needs to be updated. How to accomplish this?
Pradeep Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Another link into the database stage, with the rule "update existing rows only".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Right now I am having only two links and
I am giving the rule
for Insert as : Insert new rows only
for UPDATE AS: Update existing rows only

Is this correct
Pradeep Kumar
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Re: Updating Records in Table

Post by ShaneMuir »

pradkumar wrote: I am having my job as follows:

I/P -->TX(lookup + constraint in TX for INSERT AND UPDATE)-->(NEWKEY GENEARTION(for insert new rows) --> Target table

My question is if Flag = "N", then it is an old record and needs to be updated. How to accomplish this?
pradkumar wrote: Right now I am having only two links and
I am giving the rule
for Insert as : Insert new rows only
for UPDATE AS: Update existing rows only

Is this correct
Looks/sounds good - but I do have one question - how are you determining your flag?
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

For First Insertion I am assigining the Flag to "Y"..(NEW)
If user changes the current_ind in target table to "N"
my job should be update only that record with flag set to "N"
Pradeep Kumar
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

For First Insertion I am assigining the Flag to "Y"..(NEW)
If user changes the current_ind in target table to "N"
my job should be update only that record with flag set to "N"
Pradeep Kumar
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

pradkumar wrote:For First Insertion I am assigining the Flag to "Y"..(NEW)
If user changes the current_ind in target table to "N"
my job should be update only that record with flag set to "N"
I only ask as the above assumes that you have the key to update an existing record.
I just thought i would check that this is the case, as you mentioned that the key is generated on insert. So long as you have the key then you should have no problems.
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

pradkumar wrote:Right now I am having only two links and
I am giving the rule
for Insert as : Insert new rows only
for UPDATE AS: Update existing rows only
You have done correctly by taking 2 links.

make flag column also as key column in datastage.

keep in insert link Flag = 'Y' and Update link Flag = 'N'


Thanks,
Anupam
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

For First Insertion I am assigining the Flag to "Y"..(NEW)
If user changes the current_ind in target table to "N"
my job should be update only that record with flag set to "N"
Pradeep Kumar
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

pradkumar wrote:For First Insertion I am assigining the Flag to "Y"..(NEW)
If user changes the current_ind in target table to "N"
my job should be update only that record with flag set to "N"
Yes I got this bit the first time.

To update your target table though you will need the key for the row to update. If you are looking for a flag of 'N' in the target table how are you firstly identifying the row to look for? Is the key of the target table available in your input?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What are the constraint expressions for the two links in your Transformer stage? What is the derivation expression for your flag (the actual expression, not what it does)? What, precisely, is the problem that you are trying to solve?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

At present these are the expressions which I am using for Insert and Update


Insert : IsNull(Customer_lkp.Customer_KEY)
Update: Not(IsNull(Customer_lkp.Customer_KEY))
Pradeep Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In that case you don't need the "Yes"/"No" flag.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Post by shilpa79 »

while updating why donot you compare the lookup and I/p columns
and the current Indicator=' Y' and If ur getting the same columns it will not update anything.If any columns changes then it will get updated
with the end_date and Ind="N"

I donot know whether I am on the same page.
Post Reply