unsigned CMssqlConnection::ExecuteAndReturnIdentity(const char *string, ...)
{
	cvs::string str;
	va_list va;

	va_start(va,string);
	cvs::vsprintf(str,64,string,va);
	va_end(va);

	str += " select @@IDENTITY";

	CSqlRecordsetPtr rs = _Execute(str.c_str());

	if(Error() || rs->Closed() || rs->Eof())
		return 0;
	return *rs[0];
}
Exemple #2
0
unsigned CDb2Connection::ExecuteAndReturnIdentity(const char *string, ...)
{
	cvs::string str;
	va_list va;

	va_start(va,string);
	cvs::vsprintf(str,64,string,va);
	va_end(va);

	str = "begin atomic;" + str;
	str += " select identity_val_local(); end";

	CSqlRecordsetPtr rs = _Execute(str.c_str());

	if(Error() || rs->Closed() || rs->Eof())
		return 0;
	return *rs[0];
}