Why not only do:

conn.beginTrans();
//Statments
conn.commit();  or conn.rollback();

-----Original Message-----
From: David Shanes [mailto:dshanes@;san.rr.com]
Sent: October 31, 2002 12:12
To: [EMAIL PROTECTED]
Subject: SQL UPDATE question


Filter: SQL, UPDATE

Is there a way to do the following in one single statement? I know I can
get all of the info from the three tables in a single query using
joins...


// Start a transaction
conn.setAutoCommit(false);
// Do the work.
stmt = conn.createStatement();

// Update general acct info
sSQL = "UPDATE t_account " +
       "SET fkCustomerId=" + cdVO.getIdCustomer() + ", " +
           "dateCreated=" + cdVO.getDateCreated() + ", " +
           "dateClosed=" + cdVO.getDateClosed() + ", " +
           "balance=" + cdVO.getBalance() + " " +
       "WHERE id=" + cdVO.getIdAccount() + ";";
stmt.executeUpdate(sSQL);

// Update investment specific acct info
sSQL = "UPDATE t_accountinvestment " +
       "SET investmentObjective=" + cdVO.getObjective() +" " +
       "WHERE id=" + cdVO.getIdAccount() + ";";
stmt.executeUpdate(sSQL);

// Update cd specific acct info
sSQL = "UPDATE t_accountcd " +
       "SET dateMaturity=" + cdVO.getDateMaturity() + ", " +
           "isDivReinvested=" + cdVO.getIsDivReinvested() + " " +
       "WHERE id=" + cdVO.getIdAccount() + ";";
stmt.executeUpdate(sSQL);

conn.commit();



Thanks,
David


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to