Beispiel #1
0
 public int update() {
   int count;
   session.getUser().checkRight(table, Right.INSERT);
   session.getUser().checkRight(table, Right.UPDATE);
   setCurrentRowNumber(0);
   if (list.size() > 0) {
     count = 0;
     for (int x = 0, size = list.size(); x < size; x++) {
       Expression[] expr = list.get(x);
       Row newRow;
       try {
         newRow = createRow(expr, x);
         if (newRow == null) {
           continue;
         }
       } catch (DbException ex) {
         throw setRow(ex, count + 1, getSQL(expr));
       }
       setCurrentRowNumber(++count);
       merge(newRow);
     }
   } else {
     ResultInterface rows = query.query(0);
     count = 0;
     table.fire(session, Trigger.UPDATE | Trigger.INSERT, true);
     table.lock(session, true, false);
     while (rows.next()) {
       Value[] values = rows.currentRow();
       Row newRow;
       try {
         newRow = createRow(values);
         if (newRow == null) {
           continue;
         }
       } catch (DbException ex) {
         throw setRow(ex, count + 1, getSQL(values));
       }
       setCurrentRowNumber(++count);
       merge(newRow);
     }
     rows.close();
     table.fire(session, Trigger.UPDATE | Trigger.INSERT, false);
   }
   return count;
 }