User-defined update statement in DB2 UDB API Stage

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
vkhandel
Participant
Posts: 35
Joined: Wed Oct 04, 2006 12:12 am
Location: Pune

User-defined update statement in DB2 UDB API Stage

Post by vkhandel »

I have a requirement wherein I have to update the DB2 (on AS400) tables from the input dataset by passing the update statement as parameter.

The input dataset schema is like -
COL1, COL2, COL3, KEYCOL1, KEYCOL2, KEYCOL3

And say the target table schema is like -
COLA, COLB, COLC, KEYCOLA, KEYCOLB, KEYCOL3

Could someone suggest how should I built and pass the UPDATE statement as a parameter to DB2 API Stage in this case?

The whole job is in RCP mode.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

I have tried passing SQL statements as parameters to read data from tables but so far never to update/insert. But I am assuming it should still be similar for user defined update/inserts. Auto generated Update statements within the DB2 stage usually look like this

Code: Select all

UPDATE TABLE SET TABLE.COLUMN = ORCHESTRATE.INPUT_VALUE WHERE TABLE.KEY = ORCHESTRATE.INPUT_KEY
Once you have the auto generated sql you have to copy the "non orchestrate" part and pass it as a parameter to your job and use those parameters in your user defined SQL. In this case you might need two parameters. Let us know if it works.
Kris

Where's the "Any" key?-Homer Simpson
vkhandel
Participant
Posts: 35
Joined: Wed Oct 04, 2006 12:12 am
Location: Pune

Post by vkhandel »

Thanks for the suggestion "Kris". That didn't worked though .. :((
As a workaround, I am updating table by generating UPDATE statements at run-time for each target table and directly executing them from UNIX.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

vkhandel wrote:Thanks for the suggestion "Kris".
Not sure what "Kris" implies :?
Kris

Where's the "Any" key?-Homer Simpson
Post Reply