aspose file tools*
The moose likes JDBC and the fly likes Can we update multiple tables in a single update query? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can we update multiple tables in a single update query?" Watch "Can we update multiple tables in a single update query?" New topic
Author

Can we update multiple tables in a single update query?

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Can we update multiple tables in a single update query?


No Kaustubh No Fun, Know Kaustubh Know Fun..
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

No. At least not in Oracle


[My Blog]
All roads lead to JavaRanch
Bharath Raja
Ranch Hand

Joined: Jan 21, 2009
Posts: 111
Kaustubh G Sharma wrote:Can we update multiple tables in a single update query?


have you idea about triggers


Life is either daring something or nothing - Helen Keller
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Yes i know lil bit about triggers but never used it
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4464
    
    8

Christophe Verré wrote:No. At least not in Oracle

But you can in MySQL. So it depends on your database.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Thanks .. Gotcha
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

Christophe Verré wrote:No. At least not in Oracle

It is certainly possible in Oracle using key-preserved views ("updatable joins"). See what Tom Kyte has to say about it.

Then there is the multitable insert, which is usually used in ETL processing (read input data once and insert it into many tables, avoiding multiple full scans over external tables for example).
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

Bharath Raja wrote:have you idea about triggers

Triggers may appear to be cool, but no, I wouldn't advise to use drivers. There is no execution order specified for triggers and once there are more than a handful of them, any troubleshooting is a nightmare.

Stored procedure would be much better way in this case, if someone wanted to implement the logic in the database.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can we update multiple tables in a single update query?