dtl


// Delete objects from the database via a delete_iterator

// using a dynamic view



// Delete rows matching the specified Example objects from the database

// using a dynamic view

void DeleteDynamicData()

{

	// construct view

	DynamicDBView<> view("DB_EXAMPLE", "STRING_VALUE, EXAMPLE_DATE");



	// build a deleter for the view



	// *** SQL Query Generated for this delete_iterator:" ***

 	// "DELETE FROM DB_EXAMPLE WHERE EXAMPLE_DATE = (?) AND STRING_VALUE = (?) "



	DynamicDBView<>::delete_iterator exampleDeleter = view;



	variant_row deleteMe(view.GetDataObj());



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

	deleteMe["STRING_VALUE"] = string("Example");



	TIMESTAMP_STRUCT y2k = {2000, 1, 1, 0, 0, 0, 0};

	deleteMe["EXAMPLE_DATE"] = y2k;



	// execute the delete

    *exampleDeleter = deleteMe;

	exampleDeleter++;



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



	// now can perform other deletes using the same deleter object



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



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

	deleteMe["STRING_VALUE"] = string("operator->() works");

	deleteMe["EXAMPLE_DATE"] = today;

	

	// execute the delete

	*exampleDeleter = deleteMe;

	exampleDeleter++;



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

}


[DTL Home]

Copyright © 2002, Michael Gradman and Corwin Joy.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

SourceForge Logo

This site written using the ORB. [The ORB]