// 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["INT_VALUE"] == rowbuf.exampleInt;
		boundIOs["STRING_VALUE"] == rowbuf.exampleStr;
		boundIOs["DOUBLE_VALUE"] == rowbuf.exampleDouble;
		boundIOs["EXAMPLE_LONG"] == rowbuf.exampleLong;
		boundIOs["EXAMPLE_DATE"] == rowbuf.exampleDate;
	}
};

class ExampleParamObj
{
    public:
       	int lowIntValue;
	string strValue;
};

class BPAParamObj
{
public:
	void operator()(BoundIOs &boundIOs, ExampleParamObj &paramObj)
	{
		boundIOs[0] == paramObj.strValue;
		boundIOs[1] == paramObj.lowIntValue;
	}

};


// Delete rows matching the specified Example objects from the database
void DeleteData()
{
	// construct view
	DBView<Example, ExampleParamObj>
	view("DB_EXAMPLE", BCAExampleObj(), "OR STRING_VALUE = (?) OR INT_VALUE = (?)", BPAParamObj());

	// build a deleter for the view

	// *** SQL Query Generated for this delete_iterator:" ***
	// *** (Note: All column and field names that were generated by the BCA are alphabetized due to our implementation) ***
 	// "DELETE FROM DB_EXAMPLE WHERE EXAMPLE_DATE = (?) AND STRING_VALUE = (?) "
	// "OR STRING_VALUE = (?) OR INT_VALUE = (?)"

	DBView<Example, ExampleParamObj, BCAExampleObj, BPAParamObj>::delete_iterator
	exampleDeleter = view;

	// now set the parameters indicating which rows we want to delete
	exampleDeleter->exampleStr = "Example";

	TIMESTAMP_STRUCT y2k = {2000, 1, 1, 0, 0, 0, 0};
	exampleDeleter->exampleDate = y2k;

	exampleDeleter.Params().strValue = "Find Me";
	exampleDeleter.Params().lowIntValue = 18;

	// execute the delete
	exampleDeleter++;

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

	// now can perform other deletes using the same deleter object
	// make sure to put in your new values for the parameters
	// for the delete

	// now set the parameters indicating which rows we want to delete

	TIMESTAMP_STRUCT today = {1999, 9, 29, 0, 0, 0, 0};
	*exampleDeleter = Example(3, "operator->()works", 0.0, 0, today);

	// execute the delete
	exampleDeleter++;

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