Upscaledb.Database.InsertRecNo C# (CSharp) Method

InsertRecNo() public method

Inserts a Database Item into a Record Number Database
This method wraps the native ups_db_insert function.
This function inserts a record as a new Database item.
/// /// /// if you tried to insert a key in a read-only Database /// ///
public InsertRecNo ( Transaction txn, byte record, int flags ) : byte[]
txn Transaction An optional Transaction object
record byte The record of the new item
flags int Optional flags for this operation.
return byte[]
        public byte[] InsertRecNo(Transaction txn, byte[] record, int flags)
        {
            int st;
            byte[] key = null;
            lock (this)
            {
            st = NativeMethods.InsertRecNo(handle,
                      txn != null ? txn.Handle : IntPtr.Zero,
                      ref key, record, flags);
            }
            if (st != 0)
            throw new DatabaseException(st);
            return key;
        }

Same methods

Database::InsertRecNo ( byte record ) : byte[]
Database::InsertRecNo ( byte record, int flags ) : byte[]

Usage Example

Ejemplo n.º 1
0
        private void InsertRecNo()
        {
            Upscaledb.Environment env = new Upscaledb.Environment();
            Database db = new Database();
            byte[] r1 = new byte[5];
            byte[] r2;
            try
            {
                env.Create("ntest.db");
                db = env.CreateDatabase(1, UpsConst.UPS_RECORD_NUMBER);
                r1[0] = 1;
                var k = db.InsertRecNo(r1);
                r2 = db.Find(k);
                checkEqual(r1, r2);

                r1[0] = 2;
                k = db.InsertRecNo(r1);
                r2 = db.Find(k);
                checkEqual(r1, r2);

                r1[0] = 3;
                k = db.InsertRecNo(r1);
                r2 = db.Find(k);
                checkEqual(r1, r2);
            }
            catch (DatabaseException e)
            {
                Assert.Fail("unexpected exception " + e);
            }
            db.Close();
            env.Close();
        }