IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Equivalent Query for batch Program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Thu Mar 12, 2009 7:19 pm
Reply with quote

hi all,

Can somebody help me out and provide me equivalent query for the below.

UPDATE TABLE_1
INNER JOIN TABLE_2 ON
TABLE_1.COLUMN-1 = TABLE_2.COLUMN-1
SET TABLE_1.COLUMN-2 = TABLE_2.COLUMN-2.

Regards
Bhairon Singh Rathore
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Mar 13, 2009 11:41 am
Reply with quote

Code:
UPDATE TABLE1
   SET TABLE1.COL2 = (SELECT TABLE2.COL2
                      FROM TABLE2
                    WHERE TABLE2.COL1=TABLE1.COL1)
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Mar 13, 2009 12:03 pm
Reply with quote

hi Bharath,

I don't think this will work .....

In Below Query

SELECT TABLE2.COL2
FROM TABLE2
WHERE TABLE2.COL1=TABLE1.COL1

1) how can you put column from table1 without joining it with table2 icon_question.gif
2) After join also how will this query verify that this is updating Right row of the table1 icon_idea.gif

Thanks Anyway.
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri Mar 13, 2009 12:49 pm
Reply with quote

Hi bhairon singh rathore,
Can you access the table2 at first and move the corresponding field to a Working storage and hence can you update that field to the Table1 column.
is that help?
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Mar 13, 2009 12:55 pm
Reply with quote

Hi Anand,

Yes we can do it thru a cursor very easily.... but i need some equivalent query , if possible for the same .
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri Mar 13, 2009 1:39 pm
Reply with quote

Hi bhairon singh rathore,
How you are going to update that field by Spufi or Eztrieve or etc...
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Mar 13, 2009 3:11 pm
Reply with quote

Quote:
hi Bharath,

I don't think this will work .....



That Query works NO MATTER WHAT YOU THINK. Please care enough to run and check rather than making statement based on instincts. There are a lot more things in DB2 than what me or you can think. Use the query for your benefit or don't but don't give out verdicts based on your thoughts.

Quote:
1) how can you put column from table1 without joining it with table2
2) After join also how will this query verify that this is updating Right row of the table1


Good questions. Have you ever heard of the term subquery? If not, its time to learn them.

Please go thru the link if you really care enough to learn.
Subqueries
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts RC query -Time column CA Products 3
No new posts Help in Automating Batch JCL jobs mon... JCL & VSAM 3
Search our Forums:

Back to Top