本文整理汇总了C++中RSqlStatement::Reset方法的典型用法代码示例。如果您正苦于以下问题:C++ RSqlStatement::Reset方法的具体用法?C++ RSqlStatement::Reset怎么用?C++ RSqlStatement::Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSqlStatement
的用法示例。
在下文中一共展示了RSqlStatement::Reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SqlServerMultiInsertTest
/**
@SYMTestCaseID PDS-SQLITE3SEC-UT-4034
@SYMTestCaseDesc SQL server multi-insert performance test.
The test inserts 1000 records in a single transaction and stores
the execution time for later use (comparison and printing).
@SYMTestPriority High
@SYMTestActions SQL server multi-insert performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ11320
*/
static void SqlServerMultiInsertTest(const char aInsertSql[], TInt aInsertRecCnt)
{
TheTest.Next( _L("@SYMTestCaseID:PDS-SQLITE3SEC-UT-4034"));
(void)KillProcess(KSqlSrvName);
TInt err = TheDb.Open(KTestDbName);
TEST2(err, KErrNone);
RSqlStatement stmt;
err = stmt.Prepare(TheDb, TPtrC8((const TUint8*)aInsertSql));
TEST2(err, KErrNone);
TUint32 fc = FastCounterValue();
err = TheDb.Exec(_L8("BEGIN"));
TEST(err >= 0);
for(TInt i=0;i<aInsertRecCnt;++i)
{
err = stmt.BindInt(0, i + 1);
TEST2(err, KErrNone);
err = stmt.Exec();
TEST2(err, 1);
err = stmt.Reset();
TEST2(err, KErrNone);
}
err = TheDb.Exec(_L8("COMMIT"));
TEST(err >= 0);
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiInsert, FastCounterValue() - fc);
stmt.Close();
TheDb.Close();
}
示例2: fetchNext
bool QSymSQLResultPrivate::fetchNext(bool initialFetch)
{
int res;
if (skipRow) {
// already fetched
Q_ASSERT(!initialFetch);
skipRow = false;
return skippedStatus;
}
skipRow = initialFetch;
res = stmt.Next();
switch(res) {
case KSqlAtRow:
return true;
case KSqlAtEnd:
stmt.Reset();
return false;
case KSqlErrGeneral:
// KSqlErrGeneral is a generic error code and we must call stmt.Reset()
// to get the specific error message.
stmt.Reset();
q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult",
"Unable to fetch row"), QSqlError::ConnectionError, res));
q->setAt(QSql::AfterLastRow);
return false;
case KSqlErrMisuse:
case KSqlErrBusy:
default:
// something wrong, don't get col info, but still return false
q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult",
"Unable to fetch row"), QSqlError::ConnectionError, res));
stmt.Reset();
q->setAt(QSql::AfterLastRow);
return false;
}
return false;
}
示例3: WriteGroupMembersL
/**
Persist the items belonging to curent group into group table
@param aGroup referece to a contact group
*/
void CPplGroupsTable::WriteGroupMembersL(const CContactItem& aGroup)
{
if (aGroup.Type() != KUidContactGroup)
{
return;
}
const TContactItemId KGroupId(aGroup.Id() );
// make sure we clear out any previous, out-of-date data
TBool lowDiskErr(EFalse);
DeleteItemL(KGroupId, lowDiskErr);
if (lowDiskErr)
{
User::Leave(KErrDiskFull);
}
// build the RSqlStatement
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
stmnt.PrepareL(iDatabase, iInsertStmnt->SqlStringL() );
const TInt KGroupIdIndex(KFirstIndex); // first parameter in query...
const TInt KMemberIdIndex(KGroupIdIndex + 1); // ...and the second parameter
// copy and sort the member id array so we can see if there are duplicates
const CContactIdArray* contactIdArray = static_cast<const CContactGroup&>(aGroup).ItemsContained(); //does not take the ownership
const TInt arrayCount = contactIdArray->Count();
CArrayFixFlat<TContactItemId>* sortedList = new(ELeave) CArrayFixFlat<TContactItemId>(KArrayGranularity);
CleanupStack::PushL(sortedList);
for(TInt loop = 0;loop < arrayCount; ++loop)
{
sortedList->AppendL((*contactIdArray)[loop]);
}
TKeyArrayFix key(0,ECmpTInt);
sortedList->Sort(key);
// insert the group-member relationships
const TInt KCountStmntParamIndex(KFirstIndex); // first and only parameter in query
const TInt listLen(sortedList->Count() );
TInt lastId(0);
for (TInt i = 0; i < listLen; ++i)
{
TInt itemId((*sortedList)[i]);
//check if a contact item with itemId id really exists in contact database
RSqlStatement countStmnt;
CleanupClosePushL(countStmnt);
countStmnt.PrepareL(iDatabase, iCountContactsStmnt->SqlStringL() );
User::LeaveIfError(countStmnt.BindInt(KCountStmntParamIndex, itemId) );
TInt count = 0;
TInt err = KErrNone;
if((err = countStmnt.Next() ) == KSqlAtRow)
{
count = countStmnt.ColumnInt(iCountContactsStmnt->ParameterIndex(KSqlCount) );
}
else
{
User::LeaveIfError(err);
}
if(count == 0)
{
User::Leave(KErrNotFound);
}
CleanupStack::PopAndDestroy(&countStmnt);
// only insert this if we haven't already seen it
if (itemId != lastId || i == 0)
{
User::LeaveIfError(stmnt.BindInt(KGroupIdIndex, KGroupId) );
User::LeaveIfError(stmnt.BindInt(KMemberIdIndex, itemId) );
User::LeaveIfError(stmnt.Exec() );
User::LeaveIfError(stmnt.Reset() );
}
lastId = itemId;
}
CleanupStack::PopAndDestroy(2, &stmnt); // and sortedList
}