我嘗試了一些代碼插入到oracle多個表中。但它不執行。 任何人都可以幫助我嗎?是否可以使用PreparedStatement在Oracle上插入多個表?
這裏是我的代碼:
String sql = "insert all"
+ "into t_stock_purchase values(?,?,?,?)"
+ "into t_stocks values(?,?,?)"
+ "into t_stock_status(godownname,itemname,receivedfrom,receiveddate,receivedqty,availablebal) values(?,?,?,?,?,?)"
+ "select 1 from dual";
ps = con.prepareStatement(sql);
int rowCount = PurchaseTable.getRowCount();
System.out.println("Row Count = "+rowCount);
for (int i = 0; i < rowCount; i++) {
ps.setString(1, partyNameLable);
ps.setString(2, dateLable);
ps.setString(3, (String) PurchaseTable.getValueAt(i, 0));
ps.setInt(4, (int) PurchaseTable.getValueAt(i, 1));
ps.setString(5, "Purchase");
ps.setString(6, (String) PurchaseTable.getValueAt(i, 0));
ps.setInt(7, (int) PurchaseTable.getValueAt(i, 1));
ps.setString(8, "Purchase");
ps.setString(9, (String) PurchaseTable.getValueAt(i, 0));
ps.setString(10, partyNameLable);
ps.setString(11, dateLable);
ps.setInt(12, (int) PurchaseTable.getValueAt(i, 1));
ps.setInt(13, (int) PurchaseTable.getValueAt(i, 1));
ps.execute();
}
是不是正確的方式?如果有任何符合候選條件,請提供給我。
在此先感謝。
不執行平均,面對任何錯誤? – venkat
它不顯示任何錯誤,同時記錄沒有插入到數據庫中。 – Thirunavukkarasu
是否達到了循環?即確保rowCount值大於零。 – venkat