Erase() public static method

public static Erase ( IntPtr handle, IntPtr txnhandle, byte data, int flags ) : int
handle System.IntPtr
txnhandle System.IntPtr
data byte
flags int
return int
コード例 #1
0
        /// <summary>
        /// Erases a Database Item
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_db_erase function.
        /// <br />
        /// This function erases a Database item. If the item with the
        /// specified key does not exist in the Database, error code
        /// <see cref="UpsConst.UPS_KEY_NOT_FOUND" /> is thrown.
        /// <br />
        /// Note that this method can not erase a single duplicate key.
        /// If the key has multiple duplicates, all duplicates of this key
        /// will be erased. Use <see cref="Cursor.Erase" /> to erase a
        /// specific duplicate key.
        /// </remarks>
        /// <param name="txn">The optional Transaction</param>
        /// <param name="key">The key of the item to delete</param>
        /// <exception cref="DatabaseException">
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_KEY_NOT_FOUND"/>
        ///     if the key was not found</item>
        ///   <item><see cref="UpsConst.UPS_WRITE_PROTECTED"/>
        ///     if you tried to insert a key in a read-only Database</item>
        ///   </list>
        /// </exception>
        public void Erase(Transaction txn, byte[] key)
        {
            int st;

            lock (this) {
                st = NativeMethods.Erase(handle,
                                         txn != null ? txn.Handle : IntPtr.Zero, key, 0);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
        }