Erase() public method

Erases the current key
This method wraps the native ups_cursor_erase function.
Erases a key from the Database. If the erase was successfull, the Cursor is invalidated, and does no longer point to any item. In case of an error, the Cursor is not modified.
If the Database was opened with the flag UpsConst.UPS_ENABLE_DUPLICATE_KEYS, this function erases only the duplicate item to which the Cursor refers.
/// /// /// if the Cursor does not point to any item /// /// if you tried to erase a key from a read-only Database /// ///
public Erase ( ) : void
return void
Esempio n. 1
0
 private void EraseNegative()
 {
     Cursor c = new Cursor(db);
     try {
         c.Erase();
     }
     catch (DatabaseException e) {
         Assert.AreEqual(UpsConst.UPS_CURSOR_IS_NIL, e.ErrorCode);
     }
 }
Esempio n. 2
0
        private void GetDuplicateCount()
        {
            Cursor c = new Cursor(db);
            byte[] k1 = new byte[5]; k1[0] = 5;
            byte[] r1 = new byte[5]; r1[0] = 1;
            byte[] r2 = new byte[5]; r2[0] = 2;
            byte[] r3 = new byte[5]; r2[0] = 2;
            c.Insert(k1, r1);
            Assert.AreEqual(1, c.GetDuplicateCount());

            c.Insert(k1, r2, UpsConst.UPS_DUPLICATE);
            Assert.AreEqual(2, c.GetDuplicateCount());

            c.Insert(k1, r3, UpsConst.UPS_DUPLICATE);
            Assert.AreEqual(3, c.GetDuplicateCount());

            c.Erase();
            c.MoveFirst();
            Assert.AreEqual(2, c.GetDuplicateCount());
        }
Esempio n. 3
0
 private void Erase()
 {
     Cursor c = new Cursor(db);
     byte[] k1 = new byte[5]; k1[0] = 5;
     byte[] r1 = new byte[5]; r1[0] = 1;
     c.Insert(k1, r1);
     c.Erase();
 }