dtl


// Execute an arbitrary query and prompt for any parameters

void ExecQuery(string sql)

{

	DynamicDBView<> view(sql, "");

	DynamicDBView<>::sql_iterator sql_it(view);



	// Show query

	cout << sql << "\n\n";

	

	// Prompt user for any parameters

	for (size_t i = 0; i < sql_it.GetBoundParamCount(); i++)

	{

		cout << "Please enter the value for parameter number " << i << "\n";

		string param;

		cin >> param;



		// get param

		sql_it.Params()[i] = param;

	}



	// Force an execute in case there is no result set, e.g. INSERT, DELETE

	*sql_it = view.GetDataObj();



	// Print results

	while (sql_it != view.end())

	{

		cout << *sql_it << "\n";

		++sql_it;

	}

}



void ExecQueryExample() {

	ExecQuery("SELECT * from DB_EXAMPLE WHERE INT_VALUE = (?)");

}


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