Del (Delete) Operation

In the previous section we reviewed the BnagDB objects and dealing with them. Now using the objects we will perform some operations. This section will review the *del* operation

del

API - without transaction

FILEOFF_T del(char *key);

FILEOFF_T del(FDT *key);

FILEOFF_T del(LONG_T key);

FILEOFF_T del(int key);

API - with transaction

FILEOFF_T del(char *key, void *txn_handle);

FILEOFF_T del(FDT *key, void *txn_handle);

FILEOFF_T del(LONG_T key, void *txn_handle);

Now we will delete the values for given keys. Assume that db objects have been created earlier as shown previously

	char *k = "my key";
	FILEOFF_T rval = 0;
	if((rval = conn->del(k)) < 0)
		bangdb_logger("error for delete key k");
	else if(rval == 1)
		bangdb_logger("key does not exist\n");
	else
		bangdb_logger("delete successful\n");
		
	//with transaction
	bangdb_txn txn;
	db->begin_transaction(&txn);

	//conn1 is connection to table
	conn1->del(k1, &txn);
	
	//conn1 is connection to table
	conn2->del(k2, &txn);
	
	db->commit_transaction(&txn);
	
	//note we have left out the error condition check for del and commit
	

API - without transaction

int Del(byte[] key)

int Del(string key)

long Del(long key)

API - with transaction

int Del(byte[] key, Transaction txn)

int Del(string key, Transaction txn)

Now we will delete the values for given keys. Assume that db objects have been created earlier as shown previously

	byte[] k = Encoding.UTF8.GetBytes("my key");
	int rval = 0;
	if((rval = conn.Del(k)) < 0)
		Console.Write("error for delete key k\n");
	else if(rval == 1)
		Console.Write("key does not exist\n");
	else
		Console.Write("delete successful\n");
		
	//with transaction
	Transaction txn = new Transaction();
	db.BeginTransaction(txn);

	//conn1 is connection to table
	conn1.Del(k1, txn);
	
	//conn1 is connection to table
	conn2.Del(k2, txn);
	
	db.CommitTransaction(ref txn);
	
	//note we have left out the error condition check for del and commit
	

API - without transaction

int del(String key)

int del(byte[] key)

public long del(byte[] key);

API - with transaction

int del(String key, Transaction txn)

int del(byte[] key, Transaction txn)

Now we will delete the values for given keys. Assume that db objects have been created earlier as shown previously

	byte[] k = "my key".getBytes();
	int rval = 0;
	if((rval = conn.del(k)) < 0)
		BangDBCommon.bangdb_logger("error for delete key k");
	else if(rval == 1)
		BangDBCommon.bangdb_logger("key does not exist");
	else
		BangDBCommon.bangdb_logger("delete successful");
		
	//with transaction
	Transaction txn = new Transaction();
	db.beginTransaction(txn);

	//conn1 is connection to table
	conn1.del(k1, txn);
	
	//conn1 is connection to table
	conn2.del(k2, txn);
	
	db.commitTransaction(txn);
	
	//note we have left out the error condition check for del and commit