Lookup being used on table which gets update in the same job

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
sachinnilose
Premium Member
Premium Member
Posts: 12
Joined: Wed Jul 29, 2009 2:47 am
Location: Germany

Lookup being used on table which gets update in the same job

Post by sachinnilose »

Hello,

I need to lookup on the same table which is being updated/Inserted in the job. My business requirement can't support me to break the job and do update/Insert in separate job.
What design I should use for achieving the desired result.

1). Is the updated records from source being looked up for next source record.

2). What commit interval I need to set at target.

3). Is there any way I can force Datastage to read uncommitted data at reference link.


I am using Oracle enterprise stage for target and reference lookup with Oracle 10g.

Thanks in advance.

Regards,
Sachin
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How can a "business requirement" dictate a job design? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Resist stupid requirements!

Your professional opinion is that the optimal approach is to separate inserts from updates.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

why do you need to lookup the same table, which is being insert/update??
why can't directly use UPSERT.
sachinnilose
Premium Member
Premium Member
Posts: 12
Joined: Wed Jul 29, 2009 2:47 am
Location: Germany

Post by sachinnilose »

Sorry for not being clear on my requirments.

I need to perform a lookup on the same table which I am Inserting/updating using upsert in the same job.

design is:
source ---> lookup tartget ----->Insert/update target


Say source has 2 records

EMPNO ENAME
7368 DEV
7369 SMITH
7369 SMITH


My requirment is first record should be inserted with an additional column FLAG= 'I'.
If we get another record with the same key it should be updated with the column FLAG = 'U'.

Desired target
EMPNO ENAME FLAG
7368 DEV I
7369 SMITH U


Lookup table desc is:
EMPNO
ENAME
FLAG

The job is not running as expected in the parallel environment as parallel job.
Same job is working fine as a server job.

Sachin
nishadkapadia
Charter Member
Charter Member
Posts: 47
Joined: Fri Mar 18, 2005 5:59 am

Post by nishadkapadia »

As suggested earlier by experts it is best advised to split, however
following could achieve the purpose.

You could first identify the Inserts/Updates by doing a look-up,hence
for your example
EMPNO ENAME
7368 DEV (Insert)
7369 SMITH (Insert)
7369 SMITH (insert)

Subsequently, within a transformer you could assign incremental numbers
grouped by employee number which would result as

EMPNO ENAME
7368 DEV (Insert) 1
7369 SMITH (Insert) 1
7369 SMITH (Insert) 2


Identify max for each group and subsequently join with above to isolate
those records and you should have it...

However, would rather go by the suggested advice given earlier
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

My requirment is first record should be inserted with an additional column FLAG= 'I'.
If we get another record with the same key it should be updated with the column FLAG = 'U'.
If the record with EMPNO=7368 is already there in table, it should also be updated??
so it can be :
Desired target
EMPNO ENAME FLAG
7368 DEV U
7369 SMITH U

I believe it can be done without lookup,
identifiy the duplicate key records mark them with 'U' FLAG and keep unique records.
and then user define query in UPSERT Load in the target.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

If you have a RAM thats large enough, you can go with looking up and Insert Update to the same target in one job. We have many small diemensions that get loaded this way ( upto 300000 records). You can Lookup from a table and Insert/Update the table in one job, But you cannot read and update/insert in the same job : Got the difference?
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

rameshrr3 wrote:You can Lookup from a table and Insert/Update the table in one job, But you cannot read and update/insert in the same job
The user wants the currently inserted row available in the lookup whilst referring for next record.

This is different from reading reference into memory.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just a thought - there may be a solution using the SCD 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.
Post Reply