handling multiple queries
Posted by: ms
Date: August 05, 2005 09:04AM

Hi,

Is it possible to issue multiple queries in one 'stmt.executeUpdate' call by separating them with a semicolon?

Or should I just use transactions?

I have some code that does the following (each 'newspaper' row has a foreign key to the papercodes.id column:

Connection con = getBroker().getConnection();
String query = "DELETE FROM papercodes WHERE id in
(select papercodeid from newspapers where id = 2";

Statement stmt = con.createStatement();
query = "DELETE FROM newspapers WHERE id=2";

But what happens if statement 1 succeeds but statement two fails (due to connection or whatever?). I am left with a bad newspaper....

So I guess I should use transactions to handle this?

Options: ReplyQuote


Subject
Written By
Posted
handling multiple queries
ms
August 05, 2005 09:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.