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

Can I update two Tables in a Single Query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top