I
I
Inteli Sense2012-04-29 20:22:28
Programming
Inteli Sense, 2012-04-29 20:22:28

Prepared Statements

Hello hackers…

There is a code…

paste2.org/p/2000519

And I can’t understand the situation that it provokes, then I ask you…

If the type in the database is equal to 1, then the first case will work and the record will eventually be deleted with this code:

stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXTERNAL_MAIL);
stmt->setUInt32(0, id);
trans->Append(stmt);


If case 2 works, then the record is deleted only under a certain condition.
If the condition did not work, the record will not be deleted even if it is triggered:
} while (result->NextRow());

For some reason, it will return the same non-deleted record and, as a result, we get a closed loop until the condition works for this row - but you need the line to be skipped and the next line to be processed ...

The NextRow () function looks like this:
bool PreparedResultSet::NextRow()
{
    /// Only updates the m_rowPosition so upper level code knows in which element
    /// of the rows vector to look
    if (++m_rowPosition >= m_rowCount)
        return false;

    return true;
}


Please tell me what I'm doing wrong, because in C ++ there is a tree ... If I had no problems with English-language forums, I would not contact you - but here I am also a log ...

thanks to everyone who can take the time

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hint, 2012-04-29
@Aios

In my opinion, you misunderstand the code (the problem is somewhere else). Whether the line is removed or not, the loop will still terminate. Records are not deleted from the result (result) during the execution of the loop body (even if SQL with DELETE is added to the transaction). But the next time the SendExternalMails method is called, the rows will be selected again and again fall into the result if they were not deleted earlier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question