Updating records in Oracle on the basis of Max Date.

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
sambit
Participant
Posts: 52
Joined: Mon Sep 05, 2005 4:59 am

Updating records in Oracle on the basis of Max Date.

Post by sambit »

Hi Guys,
I will appreciate if someone can help me out of this problem. I am trying to update few records ito Oracle thru DS server job as per the requirement mentioned below.

I/P Data :

Cust_Id Ack_Ind Ack_Dt
1 Y 2007-10-15
2 N 2007-10-15

Oracle DB Data :-

Cust_Id Ack_Ind Ack_Dt Load_Dt
1 N 2007-09-15 2007-09-13
1 Y 2007-06-15 2007-05-13
2 Y 2007-10-15 2007-09-13
2 N 2007-06-15 2007-05-13

Requirement :-
I want to update the Ack_Dt and Ack_Ind for the cust_Ids in the table with the value in the I/P file for the max(Load_Dt) as mentioned in BOLD.

Expected O/P in Oracle DB :-

Cust_Id Ack_Ind Ack_Dt Load_Dt
1 Y 2007-10-15 2007-09-13
1 Y 2007-06-15 2007-05-13
2 N 2007-10-15 2007-09-13
2 N 2007-06-15 2007-05-13


It will be great if you can let me know how can I do so thru DS server.
Thanks !!!
Sambit
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Aggregator stage?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sambit
Participant
Posts: 52
Joined: Mon Sep 05, 2005 4:59 am

Post by sambit »

Thanks Ray for the quick reply. But I am supposed to do that in the Update query where the data in the Oracle DB will be updated for that row only where we have the max(Load-Dt).

I hope I am clear with the requirement.
Thanks !!!
Sambit
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Updating records in Oracle on the basis of Max Date.

Post by sachin1 »

hello dear,

job design

database---->T1---> hashfile

lookup from hashfile to transformer T2 (equi join constraint)

inputfile-----> T2-------------------->Oci-stage(User-defined Sql)




you need to first find distinct Cust_Id from database into hash file,
then put a constraint into transformer to get equi-join i mean to say all matching Cust_Id from your input file.

In your Oracle OCI stage use user-defined SQL for updating records,


update table_name set Ack_Dt = (incoming date binding number) where (Cust_Id,Ack_Dt) in (select Cust_Id,max(Ack_Dt) Ack_Dt from table_name where Cust_Id=:1 group by Cust_Id)

it works fine
sambit
Participant
Posts: 52
Joined: Mon Sep 05, 2005 4:59 am

Post by sambit »

Thanks Sachin...
all I am facing the problem is in the OCI stage. It is not allowing me to have custom SQL statements. So I am unable to code the update statement with subquery in it.
Thanks !!!
Sambit
Post Reply