Delete data from a table based on four non-key columns

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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Which DB2 stage? Shouldn't need anything 'custom' for this as there is (typically) a "Delete existing rows only" update action or equivalent available. Don't confuse "key" columns with indexes or primary keys, they are basically just columns to bind into the where clause.
-craig

"You can never have too many knives" -- Logan Nine Fingers
suresh_dsx
Participant
Posts: 160
Joined: Tue May 02, 2006 7:49 am

Post by suresh_dsx »

DB2 Stage: DB2 UDB API

Tried with custom sql using two different options. But unable to delete data from a table.

Code: Select all

Delete from temp_table1 where col1= orchstrate.col1,co2= orchestrate.col2, col3= orchestrate.col3, col4= orchestrate.col4;

Code: Select all

Delete from temp_table1 where col1= orchstrate.col1 and co2= orchestrate.col2 and  col3= orchestrate.col3 and  col4= orchestrate.col4;
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why do you feel the need to do anything custom here? Why not leverage the 'Delete existing rows only' update action? That should be all you need.
-craig

"You can never have too many knives" -- Logan Nine Fingers
suresh_dsx
Participant
Posts: 160
Joined: Tue May 02, 2006 7:49 am

Post by suresh_dsx »

Now it working fine with the below options

query type

Generate update action from options and columns tabs

Update action

delete existing rows only


thanks for the help
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Good.

Save the 'custom' SQL for those times when you have no other choice and as a Best Practice let the stages generate the SQL for you whenever possible. Those who come after you will be ever so grateful. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply