Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Equivalent Query for batch Program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Equivalent Query for batch Program
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    Post subject:
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    Post subject: Reply to: Equivalent Query for batch Program
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    Post subject: Reply to: Equivalent Query for batch Program
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    Post subject: Reply to: Equivalent Query for batch Program
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    Post subject: Reply to: Equivalent Query for batch Program
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us