VoltTable customer = itemresults[item_id.length + 2];
final double w_tax = itemresults[item_id.length].fetchRow(0).getDouble(0);
final int D_TAX_COL = 0, D_NEXT_O_ID = 1;
final int C_DISCOUNT = 0;
final VoltTableRow tempRow = itemresults[item_id.length + 1].fetchRow(0);
final double d_tax = tempRow.getDouble(D_TAX_COL);
final double c_discount = itemresults[item_id.length + 2].fetchRow(0).getDouble(C_DISCOUNT);
final long d_next_o_id = tempRow.getLong(D_NEXT_O_ID);
final long ol_cnt = item_id.length;
final long all_local = isAllLocal ? 1 : 0;
voltQueueSQL(incrementNextOrderId, d_next_o_id + 1, d_id, w_id);
voltQueueSQL(createOrder, d_next_o_id, d_id, w_id, c_id, timestamp,
Constants.NULL_CARRIER_ID, ol_cnt, all_local);
voltQueueSQL(createNewOrder, d_next_o_id, d_id, w_id);
voltExecuteSQL();
// values the client is missing: i_name, s_quantity, brand_generic, i_price, ol_amount
final VoltTable item_data = item_data_template.clone(2048);
double total = 0;
for (int i = 0; i < item_id.length; ++i) {
final long ol_supply_w_id = supware[i];
final long ol_i_id = item_id[i];
// One getStockInfo SQL statement for each district
voltQueueSQL(getStockInfo[d_id-1], ol_i_id, ol_supply_w_id);
}
final VoltTable[] stockresults = voltExecuteSQL();
assert stockresults.length == item_id.length;
for (int i = 0; i < item_id.length; ++i) {
final long ol_number = i + 1;
final long ol_supply_w_id = supware[i];
final long ol_i_id = item_id[i];
final long ol_quantity = quantity[i];
assert stockresults[i].getRowCount() == 1 : "Cannot find stock info for item; should not happen with valid database";
final VoltTableRow itemInfo = items[i];
final VoltTableRow stockInfo = stockresults[i].fetchRow(0);
final int I_PRICE = 0, I_NAME = 1, I_DATA = 2;
final byte[] i_name = itemInfo.getStringAsBytes(I_NAME);
final byte[] i_data = itemInfo.getStringAsBytes(I_DATA);
final double i_price = itemInfo.getDouble(I_PRICE);
final int S_QUANTITY = 0, S_DATA = 1, S_YTD = 2, S_ORDER_CNT = 3, S_REMOTE_CNT = 4, S_DIST_XX = 5;
long s_quantity = stockInfo.getLong(S_QUANTITY);
long s_ytd = stockInfo.getLong(S_YTD);
long s_order_cnt = stockInfo.getLong(S_ORDER_CNT);
long s_remote_cnt = stockInfo.getLong(S_REMOTE_CNT);
final byte[] s_data = stockInfo.getStringAsBytes(S_DATA);
// Fetches data from the s_dist_[d_id] column
final byte[] s_dist_xx = stockInfo.getStringAsBytes(S_DIST_XX);
// Update stock
s_ytd += ol_quantity;
if (s_quantity >= ol_quantity + 10) {
s_quantity = s_quantity - ol_quantity;