dtl


// Copy all rows from table1 to table2.

// Potentially, these two tables could be in different databases.

void DynamicCopy(tstring table1, tstring table2, DBConnection &conn1, DBConnection &conn2) {

{

	DynamicDBView<>::Args arg1, arg2;

	arg1.tables(table1).fields("*").conn(conn1);

	arg2.tables(table2).fields("*").conn(conn2);



	DynamicDBView<> view1(arg1), view2(arg2);



	DynamicDBView<>::insert_iterator write_it = view2;



	// Copy database fields by name, converting types as needed. 

	// This assumes fields in the two tables have the same name.

	copy(view1.begin(), view1.end(), write_it);

}


[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]