Michael
Michael

Reputation: 1164

How to update several tables in one query?

I would like to update multiple tables in one SQL statement.

I am trying to execute the query:

UPDATE TABLE_A, TABLE_B SET TABLE_A.FIELD_A = 0, TABLE_B.FIELD_B = 0;

But I am getting the exception:

java.sql.SQLException: ORA-00971: missing SET keyword

What is wrong in my query? I use Oracle 11 if it is important.

Upvotes: 0

Views: 2294

Answers (1)

user1011046
user1011046

Reputation: 204

You cannot update multiple tables in single query.

You can write a stored procedure to update both tables. Have the two UPDATEs wrapped within a transaction.

Upvotes: 4

Related Questions