Update tabla through Oracle Stage

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
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Update tabla through Oracle Stage

Post by Devyani Sarkar »

How do I achieve Update as TFM --> Oracle Stage.
Query: UPDATE Meta_Ftp_Adapter SET col1=:1 WHERE col1=:2
Since DStage does not let two columns with same name in the col definitions.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Within DataStage use different column names. The first column in the grid replaces the parameter marker :1, the second replaces :2, and so on. Make sure that the one to appear in the WHERE clause is marked as Key.
Choose user-defined SQL as the preferred method, then create the UPDATE statement that you indicated. You may get a warning about metadata mismatch, but it will work.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Post by Devyani Sarkar »

Thanks Ray,
I was doing exactly you have mentioned. The stop comes then the required task is to update the same column which appears in the where clause as shown
UPDATE Table SET col1=:1 WHERE col1=:2.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

I am not sure whether you have successfully implemented the logic described by Ray or whether you are having problems.

You need to use 2 columns in your link to update - say fld1 and fld2. One of them (say fld2) is to be marked as key. The datatype for both fields must be identical to that of col1.

In your update SQL, you say,

update tablename set col1 = :1 where col1 = :2
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Post by Devyani Sarkar »

Thanks Ray my code works.

Can we implement UPDATE Table SET col1=rowid ?
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You must be able to do that (as long as col1 has datatype to hold the value).

But why will anyone require to issue such a command as rowid may change upon the update itself.
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Post by Devyani Sarkar »

I have this requirement where I have a column named rowid_id which holds the value of rowid of the record. I could not achieve this, hence if anyone has some solution to it. Thanks.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Can you explain why you have it, what you wish to achieve from it and how you are approaching it so we can try to find a solution or alternative way.
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Post by Devyani Sarkar »

The Datamodel and already existing design has it working. We do the task Oracle query by Cognos. We are over to porting DStage environment, Hence I need to achive it in DStage so let me know if you can implement the update. Thanks.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Did you try running it outside DataStage?

If you can, then you can include the SQL as a post-job script.

But still, I believe such an update cannot be utlized as rows may migrate during updates or or migration or rebuild process.

Let us know if you encounter any difficulty in this.
Devyani Sarkar
Participant
Posts: 26
Joined: Thu Apr 15, 2004 12:54 am

Post by Devyani Sarkar »

My question was to know if I can implement the update by Dstage? :-)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Devyani Sarkar wrote:I have this requirement where I have a column named rowid_id which holds the value of rowid of the record.
This is a... strange... requirement. I have no idea what value you would bring to the table by pulling the ROWID out into a data field. :?

However, it can be done. Keep in mind the fact that ROWID is a psuedo-column, so the only way I know you can achieve this is by pulling it out and putting it in a VARCHAR2 or CHAR field. Use the ROWIDTOCHAR function to get it out and into a 'saveable' format. Of course, there's a CHARTOROWID function to get it put back.

Or is your 'existing design' storing it in a different datatype?
-craig

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