// Delete objects from the database via a delete_iterator

class Example
{
  public:                                // tablename.columnname:
	int exampleInt;                 // DB_EXAMPLE.INT_VALUE
	string exampleStr;              // DB_EXAMPLE.STRING_VALUE
	double exampleDouble;           // DB_EXAMPLE.DOUBLE_VALUE
	long exampleLong;               // DB_EXAMPLE.EXAMPLE_LONG
	TIMESTAMP_STRUCT exampleDate;   // DB_EXAMPLE.EXAMPLE_DATE

	Example(int exInt, const string &exStr, double exDouble, long exLong,
		const TIMESTAMP_STRUCT &exDate) :
	   exampleInt(exInt), exampleStr(exStr), exampleDouble(exDouble), exampleLong(exLong),
	   exampleDate(exDate)
	{ }

};

class BCAExampleObj
{
public:
	void operator()(BoundIOs &boundIOs, Example &rowbuf)
	{
		boundIOs["STRING_VALUE"] == rowbuf.exampleStr;
		boundIOs["EXAMPLE_DATE"] == rowbuf.exampleDate;
	}
};


// Delete rows matching the specified Example objects from the database
void DeleteData()
{
	// construct view
	DBView<Example>
	view("DB_EXAMPLE", BCAExampleObj());

	// build a deleter for the view

	// *** SQL Query Generated for this delete_iterator: ***
 	// "DELETE FROM DB_EXAMPLE WHERE EXAMPLE_DATE = (?) AND STRING_VALUE = (?) "
	
	DBView<Example>::delete_iterator exampleDeleter = view;

	Example deleteMe;

	// now set Example object indicating which rows we want to delete
	deleteMe.exampleStr = "Example";

	TIMESTAMP_STRUCT y2k = {2000, 1, 1, 0, 0, 0, 0};
	deleteMe.exampleDate = y2k;

	// execute the delete
	*exampleDeleter = deleteMe;
	exampleDeleter++;

	cout << exampleDeleter.GetLastCount() << " rows deleted!" << endl;

	// now can perform other deletes using the same delete iterator
	
	// now set Example object and params indicating which rows we want to delete

	TIMESTAMP_STRUCT today = {1999, 9, 29, 0, 0, 0, 0};

	// execute the delete
	*exampleDeleter = Example(3, "operator->()works", 0.0, 0, today);
	exampleDeleter++;

	cout << exampleDeleter.GetLastCount() << " rows deleted!" << endl;
}