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
 

 

Can I update two Tables in a Single Query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ankvardhan

New User


Joined: 05 Sep 2008
Posts: 14
Location: Mumbai

PostPosted: Wed Feb 18, 2009 2:32 pm    Post subject: Can I update two Tables in a Single Query
Reply with quote

Hi,

My Question is, if i have two tables say: Table1 & Table2 and b/w both the tables there is a Refrential Integrity is maintained.
So is it posible to Update both the Simultaneously,
I run the Query :
UPDATE TABLE1 TABLE2
SET DATE ='01/15/2009'
WHERE NAME = 'JC'

Please assist ...!!
Back to top
View user's profile Send private message

aishwarya_20

New User


Joined: 19 Nov 2008
Posts: 57
Location: pune

PostPosted: Wed Feb 18, 2009 2:36 pm    Post subject:
Reply with quote

Could you please tell me on which column the referential integrity is maintained. I don't think that you can update both tables simultaneously. Anyone please correct me if i am wrong.
Back to top
View user's profile Send private message
ankvardhan

New User


Joined: 05 Sep 2008
Posts: 14
Location: Mumbai

PostPosted: Wed Feb 18, 2009 2:45 pm    Post subject: Query
Reply with quote

Hi,

ok , lets there are columns Column1 (date) of table1 which is also present as Column2 (Date) in table2, i tried to update the above defined Columns with a single Query, but its giving me an Error of Ref. Integrity.

This means in a single query its not allowing me to Update the Date Column of both the Tables.
For this what should i have to do, whether run the Queries independently to Update it OR there is any other soution from your side.

Thanks,
Ank
Back to top
View user's profile Send private message
aishwarya_20

New User


Joined: 19 Nov 2008
Posts: 57
Location: pune

PostPosted: Wed Feb 18, 2009 2:50 pm    Post subject:
Reply with quote

Yes, you need to write two queries for updating two tables. But you should first see what check is there in referential integrity definition i.e. there are lot of options as UPDATE on CASCADE etc. so that child column would be updated on basis of parent referential column.
Back to top
View user's profile Send private message
ankvardhan

New User


Joined: 05 Sep 2008
Posts: 14
Location: Mumbai

PostPosted: Wed Feb 18, 2009 3:00 pm    Post subject:
Reply with quote

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

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Feb 18, 2009 3:59 pm    Post subject:
Reply with quote

fyi ... There is no CASCADE for update .... only DELETE has a CASCADE option ... In your case there should not be any restriction on UPDATE ... update the two tables separately with 2 different queries ...
Back to top
View user's profile Send private message
aishwarya_20

New User


Joined: 19 Nov 2008
Posts: 57
Location: pune

PostPosted: Wed Feb 18, 2009 4:08 pm    Post subject:
Reply with quote

Thanks Ashimer, i was not sure...But Two queries are needed.
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 0 Tue Jan 17, 2017 12:15 am
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


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