Problem with Update query

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
abby
Participant
Posts: 13
Joined: Fri Dec 30, 2005 1:00 am

Problem with Update query

Post by abby »

Hi folks,

I am trying to execute a simple update query like :

Update <tablename>
Set <column_name> = <new_value> where
<column_name> = <old_value>

But, I am stuck up when the column to be changed is a part of composite key for that table. Since, the generated query for Update statement will pass only one value to the above mentioned query i.e. for new as well as old column value by replacing the '?' with the input link data.

Currently, my approach to update a composite key column is first to drop the complete row from the table and then re-inserting the deleted row information with the modified composite key column.

At this point, I'm unable to pass two different values to the same column while the Update query is formed by the DataStage. :(

Also, to ensure that no data is lost while delete and insert operation is done on a particular table I'm looking for an alternate solution.

Could anyone please advise me how to execute an Update statement when composite key columns are involved. :?:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can you not use Custom / User Defined SQL to accomplish this? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,

If i get your issue correctly, cant you update based on two columns,
like
Update <tablename>
Set <column_name> = <new_value> where
<column_name> = <old_value> and <Column_name01> = <old_value_01>

Where the Column_name01 would be one of your key, provided if you can manage to give the value(old_vlaue_01) sequentially.

-Kumar
jzparad
Charter Member
Charter Member
Posts: 151
Joined: Thu Apr 01, 2004 9:37 pm

Post by jzparad »

The number of columns used in the where clause is simply the number of columns you define as keys in the Database stage. You shouldn't have to use a user-defined query.
Jim Paradies
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You do, as the same column name needs to be mentioned twice in the query.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jzparad
Charter Member
Charter Member
Posts: 151
Joined: Thu Apr 01, 2004 9:37 pm

Post by jzparad »

Sorry. You're right!

Misread the problem.
Jim Paradies
Post Reply